Skip to content

Commit 8a83e84

Browse files
committed
WIP: Change: Ci: following guidelines
1 parent e2a5c9d commit 8a83e84

13 files changed

+362
-182
lines changed

.github/install-openvas-dependencies.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ apt-get update && apt-get install --no-install-recommends --no-install-suggests
1010
clang-tools \
1111
cmake \
1212
curl \
13+
git \
1314
lcov \
1415
libgnutls28-dev \
1516
libgpgme-dev \

.github/workflows/build-container.yml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
11
name: Build Container
22

3-
on:
4-
push:
5-
branches: [ main, stable, oldstable, middleware ]
6-
tags: ["v*"]
7-
paths:
8-
- .github/workflows/build-container.yml
9-
- .docker/build.Dockerfile
10-
pull_request:
11-
branches: [ main, stable, oldstable, middleware ]
12-
paths:
13-
- .github/workflows/build-container.yml
14-
- .docker/build.Dockerfile
15-
workflow_dispatch:
16-
repository_dispatch:
17-
schedule:
18-
# rebuild image every sunday
19-
- cron: "0 0 * * 0"
3+
on: [workflow_call]
204

215
jobs:
226
build:

.github/workflows/build.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: "Build"
2+
3+
on: [workflow_call]
4+
5+
jobs:
6+
OpenVAS:
7+
runs-on: ubuntu-latest
8+
container: greenbone/gvm-libs:stable
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: install dependencies
12+
run: |
13+
sh .github/install-openvas-dependencies.sh
14+
- name: build
15+
run: |
16+
cmake -Bbuild -DCMAKE_C_COMPILER=/usr/share/clang/scan-build-14/libexec/ccc-analyzer
17+
scan-build -o ~/scan-build-report cmake --build build
18+
- name: Upload scan-build report
19+
uses: actions/upload-artifact@v3
20+
with:
21+
name: scan-build-report
22+
path: ~/scan-build-report/
23+
retention-days: 7
24+
OpenVAS_Daemon:
25+
uses: ./.github/workflows/build-rust.yml

.github/workflows/build_and_test.yml

Lines changed: 0 additions & 61 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: "Linting"
2+
3+
on: [workflow_call]
4+
5+
jobs:
6+
OpenVAS:
7+
runs-on: ubuntu-latest
8+
container: greenbone/gvm-libs:stable
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: install dependencies
12+
run: |
13+
sh .github/install-openvas-dependencies.sh
14+
- name: Formatting
15+
run: |
16+
clang-format --dry-run --Werror -i -style=file {src,misc,nasl}/*.{c,h}
17+
- name: unit-tests
18+
run: |
19+
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release
20+
CTEST_OUTPUT_ON_FAILURE=1 cmake --build build -- tests test
21+
OpenVAS_Daemon:
22+
runs-on: ubuntu-latest
23+
defaults:
24+
run:
25+
working-directory: rust
26+
steps:
27+
- uses: actions/checkout@v4
28+
- run: sudo apt update && sudo apt-get install -y libpcap-dev
29+
- run: rustup update stable && rustup default stable || rustup default stable
30+
- run: cargo install cargo-audit
31+
- run: cargo install typos-cli
32+
- name: unit-tests
33+
run: cargo test --lib --tests --workspace
34+
- name: Clippy
35+
run: cargo clippy -- -D warnings
36+
- name: Audit
37+
run: cargo audit
38+
- run: typos
39+
- name: Formatting
40+
run: cargo fmt --check
File renamed without changes.

.github/workflows/control.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main]
6+
tags: ["v*"]
7+
pull_request:
8+
workflow_dispatch:
9+
repository_dispatch:
10+
schedule:
11+
# rebuild image every sunday
12+
- cron: "0 0 * * 0"
13+
14+
jobs:
15+
build:
16+
uses: ./.github/workflows/build.yml
17+
linting:
18+
uses: ./.github/workflows/ci.yml
19+
smoketests:
20+
needs: [build]
21+
uses: ./.github/workflows/smoketest.yml
22+
container:
23+
needs: [smoketests]
24+
uses: ./.github/workflows/push-container.yml

.github/workflows/ddependabot.yml

Whitespace-only changes.

.github/workflows/nasl.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
name: Container
2+
3+
on: [workflow_call]
4+
5+
jobs:
6+
production-image:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v4
11+
- name: "set IS_VERSION_TAG"
12+
run: |
13+
echo "IS_VERSION_TAG=${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }}" >> $GITHUB_ENV
14+
# set defaults
15+
echo "IS_LATEST_TAG=false" >> $GITHUB_ENV
16+
- name: "set IS_LATEST_TAG"
17+
if: ( env.IS_VERSION_TAG )
18+
run: |
19+
# find the latest version that is not ourself
20+
export LATEST_VERSION=$(git tag -l | grep -v '${{ github.ref_name }}' | sort -r --version-sort)
21+
# get major minor patch versions
22+
IFS='.' read -r latest_major latest_minor latest_patch << EOF
23+
$LATEST_VERSION
24+
EOF
25+
IFS='.' read -r tag_major tag_minor tag_patch << EOF
26+
${{ github.ref_name }}
27+
EOF
28+
# remove leading v
29+
latest_major=$(echo $latest_major | cut -c2-)
30+
tag_major=$(echo $tag_major | cut -c2-)
31+
echo "$tag_major >= $latest_major"
32+
if [[ $tag_major -ge $latest_major && ($tag_minor -ne 0 || $tag_patch -ne 0) ]]; then
33+
# set this tag to latest and stable
34+
echo "IS_LATEST_TAG=true" >> $GITHUB_ENV
35+
fi
36+
- name: "Setup meta information (IS_VERSION_TAG: ${{ env.IS_VERSION_TAG }}, IS_LATEST_TAG: ${{ env.IS_LATEST_TAG }} )"
37+
id: meta
38+
uses: docker/metadata-action@v5
39+
with:
40+
images: ${{ github.repository }}
41+
labels: |
42+
org.opencontainers.image.vendor=Greenbone
43+
org.opencontainers.image.base.name=greenbone/gvm-libs
44+
flavor: latest=false # no auto latest container tag for git tags
45+
tags: |
46+
# when IS_LATEST_TAG is set create a stable and a latest tag
47+
type=raw,value=latest,enable=${{ env.IS_LATEST_TAG }}
48+
type=raw,value=stable,enable=${{ env.IS_LATEST_TAG }}
49+
# if tag version is set than create a version tags
50+
type=semver,pattern={{version}},enable=${{ env.IS_VERSION_TAG }}
51+
type=semver,pattern={{major}}.{{minor}},enable=${{ env.IS_VERSION_TAG }}
52+
type=semver,pattern={{major}},enable=${{ env.IS_VERSION_TAG }}
53+
# if we are on the main branch set edge
54+
type=edge,branch=main
55+
# use branch-sha otherwise for pushes to branches other then main (will not be uploaded)
56+
type=raw,value={{branch}}-{{sha}},enable=${{ github.ref_type == 'branch' && github.event_name == 'push' && github.ref_name != 'main' }}
57+
# use pr-$PR_ID for pull requests (will not be uploaded)
58+
type=ref,event=pr
59+
- name: Login to DockerHub
60+
if: github.event_name != 'pull_request'
61+
uses: docker/login-action@v3
62+
with:
63+
username: ${{ secrets.DOCKERHUB_USERNAME }}
64+
password: ${{ secrets.DOCKERHUB_TOKEN }}
65+
66+
- uses: actions/download-artifact@v3
67+
with:
68+
name: rs-binaries
69+
path: assets
70+
- run: mkdir -p assets/linux/amd64
71+
- run: mkdir -p assets/linux/arm64
72+
- run: mv assets/openvasd-aarch64-unknown-linux-gnu assets/linux/arm64/openvasd
73+
- run: mv assets/openvasd-x86_64-unknown-linux-gnu assets/linux/amd64/openvasd
74+
- run: mv assets/nasl-cli-aarch64-unknown-linux-gnu assets/linux/arm64/nasl-cli
75+
- run: mv assets/nasl-cli-x86_64-unknown-linux-gnu assets/linux/amd64/nasl-cli
76+
- name: Set up QEMU
77+
uses: docker/setup-qemu-action@v3
78+
- name: Set up Docker Buildx
79+
uses: docker/setup-buildx-action@v3
80+
- name: Build and push
81+
uses: docker/build-push-action@v5
82+
with:
83+
context: .
84+
push: ${{ github.event_name != 'pull_request' && (github.ref_type == 'tag' || github.ref_name == 'main') }}
85+
file: .docker/prod.Dockerfile
86+
build-args: |
87+
REPOSITORY=${{ github.repository }}
88+
platforms: linux/amd64,linux/aarch64
89+
tags: ${{ steps.meta.outputs.tags }}
90+
labels: ${{ steps.meta.outputs.labels }}
91+
92+
- name: "Setup meta information debian:oldstable"
93+
id: old_stable_meta
94+
uses: docker/metadata-action@v5
95+
with:
96+
images: ${{ github.repository }}
97+
labels: |
98+
org.opencontainers.image.vendor=Greenbone
99+
org.opencontainers.image.base.name=greenbone/gvm-libs
100+
flavor: latest=false # no auto latest container tag for git tags
101+
tags: |
102+
# for the images provided for debian:oldstable we just provide
103+
# oldstable on an new version or oldstable-edge when it is on main.
104+
# oldstable-branch-sha on a branch
105+
type=raw,value=oldstable,enable=${{ env.IS_LATEST_TAG }}
106+
type=raw,value=oldstable-edge,enable=${{ github.ref_name == 'main' }}
107+
type=raw,value=oldstable-{{branch}}-{{sha}},enable=${{ github.ref_type == 'branch' && github.event_name == 'push' && github.ref_name != 'main' }}
108+
type=ref,event=pr
109+
- name: Build and push Container image
110+
uses: docker/build-push-action@v5
111+
with:
112+
context: .
113+
push: ${{ github.event_name != 'pull_request' && (github.ref_type == 'tag' || github.ref_name == 'main') }}
114+
file: .docker/prod-oldstable.Dockerfile
115+
platforms: linux/amd64,linux/arm64
116+
tags: ${{ steps.old_stable_meta.outputs.tags }}
117+
labels: ${{ steps.old_stable_meta.outputs.labels }}
118+
119+
- name: "Setup meta information debian:testing"
120+
id: test_meta
121+
uses: docker/metadata-action@v5
122+
with:
123+
images: ${{ github.repository }}
124+
labels: |
125+
org.opencontainers.image.vendor=Greenbone
126+
org.opencontainers.image.base.name=greenbone/gvm-libs
127+
flavor: latest=false # no auto latest container tag for git tags
128+
tags: |
129+
# for the images provided for debian:testing we just provide
130+
# testing on an new version or testing-edge when it is on main.
131+
# testing-branch-sha on a branch
132+
type=raw,value=testing,enable=${{ env.IS_LATEST_TAG }}
133+
type=raw,value=testing-edge,enable=${{ github.ref_name == 'main' }}
134+
type=raw,value=testing-{{branch}}-{{sha}},enable=${{ github.ref_type == 'branch' && github.event_name == 'push' && github.ref_name != 'main' }}
135+
type=ref,event=pr
136+
- name: Build and push Container image
137+
uses: docker/build-push-action@v5
138+
with:
139+
context: .
140+
push: ${{ github.event_name != 'pull_request' && (github.ref_type == 'tag' || github.ref_name == 'main') }}
141+
file: .docker/prod-testing.Dockerfile
142+
platforms: linux/amd64,linux/arm64
143+
tags: ${{ steps.test_meta.outputs.tags }}
144+
labels: ${{ steps.test_meta.outputs.labels }}

0 commit comments

Comments
 (0)