Skip to content

Commit 36d8635

Browse files
authored
ci: Improve workflow files (#111)
* Update workflow files * Fix yaml lint errors * Setup node and install deps when building stackable-cockpitd * Update actions, remove old workflow file * Bump checkout action version * Adjust cockpit and stackablectl workflow triggers * Fix double quote issue * Rework workflow triggers again Because workflow_run is weird and doesn't trigger on branches other than the default one like 'main' or 'master'. In conclusion: This trigger is weirdly designed and pretty much useless. * Only target package stackable-cockpit when setting version * Run Cockpit Web workflow when CI changes * Minor formatting
1 parent 602c168 commit 36d8635

File tree

8 files changed

+382
-470
lines changed

8 files changed

+382
-470
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 416 deletions
This file was deleted.
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
# =============
2-
# This file is automatically generated from the templates in stackabletech/operator-templating
3-
# DON'T MANUALLY EDIT THIS FILE
4-
# =============
51
---
62
name: Security audit
73

84
on:
95
schedule:
10-
- cron: '15 4 * * *'
6+
- cron: "15 4 * * *"
117
workflow_dispatch:
128

139
jobs:
1410
audit:
1511
runs-on: ubuntu-latest
1612
steps:
17-
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
13+
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
1814
- uses: actions-rs/audit-check@35b7b53b1e25b55642157ac01b4adceb5b9ebef3 # renovate: tag=v1.2.0
1915
with:
2016
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/web.yaml renamed to .github/workflows/pr_cockpit-web.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
---
22
name: web
33
on:
4-
push:
5-
branches:
6-
- main
7-
- staging
8-
- trying
9-
- "renovate/**"
10-
tags:
11-
- '[0-9][0-9].[0-9]+.[0-9]+'
124
pull_request:
13-
merge_group:
5+
paths:
6+
- ".github/workflows/pr_cockpit-web.yml"
7+
- "package.json"
8+
- "yarn.lock"
9+
- "web"
1410

1511
jobs:
1612
build-web:
1713
name: Web frontend built
1814
runs-on: ubuntu-latest
1915
steps:
20-
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
16+
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
2117
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
2218
with:
2319
node-version: 18
@@ -29,7 +25,7 @@ jobs:
2925
name: Validate web formatting
3026
runs-on: ubuntu-latest
3127
steps:
32-
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
28+
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
3329
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
3430
with:
3531
node-version: 18

.github/workflows/pr_cockpit.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
---
2+
name: Pull Request Cockpit
3+
4+
on:
5+
pull_request:
6+
paths:
7+
- ".github/workflows/pr_cockpit.yml"
8+
- "rust/stackable-cockpitd"
9+
- "rust/stackable-cockpit"
10+
- "docs/modules/cockpit"
11+
- "docs/modules/ROOT"
12+
- "Cargo.lock"
13+
- "deploy"
14+
- "docker"
15+
- "go.sum"
16+
17+
env:
18+
RUST_VERSION: 1.70.0
19+
CARGO_TERM_COLOR: always
20+
CARGO_INCREMENTAL: "0"
21+
CARGO_PROFILE_DEV_DEBUG: "0"
22+
RUSTFLAGS: "-D warnings"
23+
RUSTDOCFLAGS: "-D warnings"
24+
RUST_LOG: "info"
25+
DEV_REPO_HELM_URL: https://repo.stackable.tech/repository/helm-dev
26+
27+
jobs:
28+
general-checks:
29+
name: General Pull Request Checks
30+
uses: ./.github/workflows/pr_general.yml
31+
32+
reviewdog-checks:
33+
name: Reviewdog Pull Request Checks
34+
uses: ./.github/workflows/pr_reviewdog.yml
35+
36+
check-charts:
37+
name: Helm Chart Check
38+
runs-on: ubuntu-latest
39+
needs:
40+
- general-checks
41+
- reviewdog-checks
42+
steps:
43+
- name: Checkout Repository
44+
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
45+
with:
46+
submodules: recursive
47+
48+
- name: Setup Helm
49+
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
50+
with:
51+
version: v3.6.2
52+
53+
- name: Setup Rust
54+
uses: dtolnay/rust-toolchain@0e66bd3e6b38ec0ad5312288c83e47c143e6b09e # v1
55+
with:
56+
toolchain: ${{ env.RUST_VERSION }}
57+
58+
- name: Setup Rust Cache
59+
uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0
60+
with:
61+
key: pr-stackable-cockpit-chart
62+
63+
- name: Regenerate Charts
64+
run: make regenerate-charts
65+
66+
- name: Checking that Helm Charts are up-to-date
67+
run: git diff --exit-code
68+
69+
- name: Helm Charts not up-to-date
70+
if: ${{ failure() }}
71+
uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 # v6
72+
with:
73+
script: |
74+
core.setFailed('Committed Helm charts were not up to date, please regenerate and re-commit!')
75+
76+
publish:
77+
name: Publish Docker Image
78+
runs-on: ubuntu-latest
79+
env:
80+
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
81+
outputs:
82+
IMAGE_TAG: ${{ steps.printtag.outputs.IMAGE_TAG }}
83+
needs:
84+
- check-charts
85+
steps:
86+
- name: Checkout Repository
87+
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
88+
with:
89+
submodules: recursive
90+
91+
- name: Setup Rust
92+
uses: dtolnay/rust-toolchain@0e66bd3e6b38ec0ad5312288c83e47c143e6b09e # v1
93+
with:
94+
toolchain: ${{ env.RUST_VERSION }}
95+
96+
- name: Setup Rust Cache
97+
uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0
98+
with:
99+
key: pr-stackable-cockpit-chart
100+
101+
- name: Update Version
102+
run: |
103+
cargo install cargo-edit --version 0.11.11
104+
cargo set-version --offline --package stackable-cockpit 0.0.0-pr${{ github.event.pull_request.number }}
105+
106+
# Recreate charts and publish charts and docker image. The "-e" is needed as we want to override the
107+
# default value in the makefile if called from this action, but not otherwise (i.e. when called locally).
108+
# This is needed for the HELM_REPO variable.
109+
- name: Publish Docker Image and Helm Chart
110+
run: make -e publish
111+
- id: printtag
112+
name: Output Image Name and Tag
113+
run: echo "IMAGE_TAG=$(make -e print-docker-tag)" >> "$GITHUB_OUTPUT"

.github/workflows/pr_general.yml

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
---
2+
name: Pull Request General
3+
4+
on: workflow_call
5+
6+
env:
7+
RUST_VERSION: 1.70.0
8+
CARGO_TERM_COLOR: always
9+
CARGO_INCREMENTAL: "0"
10+
CARGO_PROFILE_DEV_DEBUG: "0"
11+
RUSTFLAGS: "-D warnings"
12+
RUSTDOCFLAGS: "-D warnings"
13+
RUST_LOG: "info"
14+
15+
jobs:
16+
run_udeps:
17+
name: Run Cargo Udeps
18+
runs-on: ubuntu-latest
19+
env:
20+
RUSTC_BOOTSTRAP: 1
21+
steps:
22+
- name: Install host dependencies
23+
run: |
24+
sudo apt-get update
25+
sudo apt-get install protobuf-compiler krb5-user libkrb5-dev libclang-dev liblzma-dev libssl-dev pkg-config
26+
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
27+
with:
28+
submodules: recursive
29+
30+
- uses: dtolnay/rust-toolchain@0e66bd3e6b38ec0ad5312288c83e47c143e6b09e # v1
31+
with:
32+
toolchain: ${{ env.RUST_VERSION }}
33+
34+
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
35+
with:
36+
node-version: 18
37+
cache: yarn
38+
- run: yarn install --frozen-lockfile
39+
40+
- uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0
41+
with:
42+
key: udeps
43+
- run: cargo install cargo-udeps
44+
- run: cargo udeps --workspace
45+
46+
run_cargodeny:
47+
name: Run Cargo Deny
48+
runs-on: ubuntu-latest
49+
strategy:
50+
matrix:
51+
checks:
52+
- advisories
53+
- bans licenses sources
54+
# Prevent sudden announcement of a new advisory from failing ci:
55+
continue-on-error: ${{ matrix.checks == 'advisories' }}
56+
steps:
57+
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
58+
with:
59+
submodules: recursive
60+
- uses: EmbarkStudios/cargo-deny-action@a50c7d5f86370e02fae8472c398f15a36e517bb8 # v1.5.4
61+
with:
62+
command: check ${{ matrix.checks }}
63+
64+
run_rustfmt:
65+
name: Run Rustfmt
66+
runs-on: ubuntu-latest
67+
steps:
68+
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
69+
with:
70+
submodules: recursive
71+
- uses: dtolnay/rust-toolchain@0e66bd3e6b38ec0ad5312288c83e47c143e6b09e # v1
72+
with:
73+
toolchain: ${{ env.RUST_VERSION }}
74+
components: rustfmt
75+
- run: cargo fmt --all -- --check
76+
77+
run_clippy:
78+
name: Run Clippy
79+
runs-on: ubuntu-latest
80+
steps:
81+
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
82+
with:
83+
submodules: recursive
84+
85+
- uses: dtolnay/rust-toolchain@0e66bd3e6b38ec0ad5312288c83e47c143e6b09e # v1
86+
with:
87+
toolchain: ${{ env.RUST_VERSION }}
88+
components: clippy
89+
90+
- uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0
91+
with:
92+
key: clippy
93+
94+
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
95+
with:
96+
node-version: 18
97+
cache: yarn
98+
99+
- run: yarn install --frozen-lockfile
100+
- name: Run clippy action to produce annotations
101+
env:
102+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103+
uses: giraffate/clippy-action@871cc4173f2594435c7ea6b0bce499cf6c2164a1
104+
if: env.GITHUB_TOKEN != null
105+
with:
106+
clippy_flags: --all-targets -- -D warnings
107+
github_token: ${{ secrets.GITHUB_TOKEN }}
108+
reporter: "github-pr-check"
109+
110+
- name: Run clippy manually without annotations
111+
env:
112+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113+
if: env.GITHUB_TOKEN == null
114+
run: cargo clippy --all-targets -- -D warnings
115+
116+
run_rustdoc:
117+
name: Run RustDoc
118+
runs-on: ubuntu-latest
119+
steps:
120+
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
121+
with:
122+
submodules: recursive
123+
124+
- uses: dtolnay/rust-toolchain@0e66bd3e6b38ec0ad5312288c83e47c143e6b09e # v1
125+
with:
126+
toolchain: ${{ env.RUST_VERSION }}
127+
components: rustfmt
128+
129+
- uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0
130+
with:
131+
key: doc
132+
133+
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
134+
with:
135+
node-version: 18
136+
cache: yarn
137+
- run: yarn install --frozen-lockfile
138+
- run: cargo doc --document-private-items
139+
140+
run_tests:
141+
name: Run Cargo Tests
142+
runs-on: ubuntu-latest
143+
steps:
144+
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
145+
with:
146+
submodules: recursive
147+
148+
- uses: dtolnay/rust-toolchain@0e66bd3e6b38ec0ad5312288c83e47c143e6b09e # v1
149+
with:
150+
toolchain: ${{ env.RUST_VERSION }}
151+
152+
- uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0
153+
with:
154+
key: test
155+
156+
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
157+
with:
158+
node-version: 18
159+
cache: yarn
160+
- run: yarn install --frozen-lockfile
161+
- run: cargo test
162+
163+
tests_passed:
164+
name: All tests passed
165+
needs:
166+
- run_udeps
167+
- run_cargodeny
168+
- run_clippy
169+
- run_rustfmt
170+
- run_rustdoc
171+
- run_tests
172+
runs-on: ubuntu-latest
173+
steps:
174+
- name: log
175+
run: echo All tests have passed!

0 commit comments

Comments
 (0)