Skip to content

Commit 271466a

Browse files
committed
ci: Improvements
* Prevent notification on cancelled workflows * Update failure condition to check job results * Add missing job dependencies to notify job * Validate required jobs in finished job * Fix detect-changes globs to cover subdirectory Rust sources * Match dependency versions across templates * Guard publish/provenance jobs with stackabletech owner check * Fix daily security workflow
1 parent a7dbb73 commit 271466a

5 files changed

Lines changed: 54 additions & 35 deletions

File tree

.github/workflows/generate_prs.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
5454
with:
5555
persist-credentials: false
56-
- uses: cachix/install-nix-action@fd24c48048070c1be9acd18c9d369a83f0fe94d7 # v31.8.1
56+
- uses: cachix/install-nix-action@630ae543ea3a38a9a4166f03376c02c50f408342 # v31.11.0
5757
- name: Install Ansible
5858
env:
5959
DEBIAN_FRONTEND: noninteractive
@@ -78,15 +78,14 @@ jobs:
7878
- name: Install jinja2
7979
run: pip install -r requirements.txt
8080

81-
# Create commit message and run the playbook
81+
# Create commit message depending on whether this is run manually or due to a scheduled run
8282
- name: Run playbook
8383
env:
8484
CUSTOM_PR_TITLE: ${{ inputs.custom-pr-title }}
8585
GH_ACCESS_TOKEN: ${{ secrets.gh_access_token }}
8686
REPOSITORY: ${{ matrix.repository }}
87-
DRY_RUN_FLAGS: ${{ (github.event_name != 'schedule' && inputs.dry-run != false) && '--tags=local' || '' }}
88-
# Safely pass inputs/context via environment variables to prevent injection
89-
INPUT_MESSAGE: ${{ github.event.inputs.message }}
87+
DRY_RUN_FLAGS: ${{ inputs.dry-run && '--tags=local' || '' }}
88+
INPUT_MESSAGE: ${{ inputs.message }}
9089
SENDER_LOGIN: ${{ github.event.sender.login }}
9190
EVENT_NAME: ${{ github.event_name }}
9291
run: |
@@ -98,7 +97,7 @@ jobs:
9897
REASON="$INPUT_MESSAGE"
9998
fi
10099
101-
# Encode parameters safely using jq, without serializing the GH_ACCESS_TOKEN
100+
# Encode parameters using jq, without serializing the GH_ACCESS_TOKEN
102101
jq -n \
103102
--arg commit_hash "$GITHUB_SHA" \
104103
--arg author "$AUTHOR" \
@@ -109,4 +108,6 @@ jobs:
109108
'{commit_hash: $commit_hash, author: $author, reason: $reason, custom_pr_title: $custom_pr_title, base_dir: $base_dir, shard_repositories: [$repository]} | with_entries(select(.value != null and .value != ""))' > vars.json
110109
111110
# Run the Ansible playbook. The token is read directly from the GH_ACCESS_TOKEN environment variable.
111+
# $DRY_RUN_FLAGS is intentionally unquoted (empty or one fixed flag)
112+
# shellcheck disable=SC2086
112113
ansible-playbook playbook/playbook.yaml --extra-vars "@vars.json" $DRY_RUN_FLAGS

template/.github/workflows/build.yaml.j2

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ jobs:
5959
- 'deploy/**'
6060
- '.cargo/**'
6161
- 'docker/**'
62-
- 'Cargo.*'
63-
- '*.rs'
62+
- '**/Cargo.toml'
63+
- 'Cargo.lock'
64+
- '**/*.rs'
6465
outputs:
6566
detected: ${{ steps.check.outputs.detected }}
6667

@@ -75,7 +76,7 @@ jobs:
7576
RUSTC_BOOTSTRAP: 1
7677
steps:
7778
- name: Install host dependencies
78-
uses: awalsh128/cache-apt-pkgs-action@2c09a5e66da6c8016428a2172bd76e5e4f14bb17 # v1.5.3
79+
uses: awalsh128/cache-apt-pkgs-action@553a35bb8ebd9fcabcb1c9451aa4c98e1b4ca8a9 # v1.6.3
7980
with:
8081
packages: protobuf-compiler krb5-user libkrb5-dev libclang-dev liblzma-dev libssl-dev pkg-config apt-transport-https
8182
version: ubuntu-latest
@@ -95,17 +96,19 @@ jobs:
9596
with:
9697
cache-all-crates: "true"
9798
key: udeps
98-
lookup-only: ${{ github.event_name == 'pull_request' }}
9999

100100
- name: Install cargo-udeps
101-
uses: stackabletech/cargo-install-action@8f7dbbcd2ebe22717efc132d0dd61e80841994b9 # cargo-udeps
101+
uses: stackabletech/cargo-install-action@e3e2dcf8d0f0e5bdbc619bf6ee7560dd68152d3c # cargo-udeps
102102

103103
- name: Run cargo-udeps
104104
run: cargo udeps --workspace --all-targets
105105

106106
build-container-image:
107107
name: Build/Publish ${{ matrix.runner.arch }} Image
108-
if: (github.event_name != 'merge_group') && needs.detect-changes.outputs.detected == 'true'
108+
if: |
109+
github.repository_owner == 'stackabletech'
110+
&& (github.event_name != 'merge_group')
111+
&& needs.detect-changes.outputs.detected == 'true'
109112
needs: [detect-changes]
110113
permissions:
111114
contents: read
@@ -120,23 +123,12 @@ jobs:
120123
outputs:
121124
operator-version: ${{ steps.version.outputs.OPERATOR_VERSION }}
122125
steps:
123-
# Use cached apt packages on PRs.
124-
# For merges to main and releases, bypass the cache and install fresh package to ensure we have the absolute latest versions.
125126
- name: Install host dependencies
126-
if: github.event_name == 'pull_request'
127-
uses: awalsh128/cache-apt-pkgs-action@2c09a5e66da6c8016428a2172bd76e5e4f14bb17 # v1.5.3
127+
uses: awalsh128/cache-apt-pkgs-action@553a35bb8ebd9fcabcb1c9451aa4c98e1b4ca8a9 # v1.6.3
128128
with:
129129
packages: protobuf-compiler krb5-user libkrb5-dev libclang-dev liblzma-dev libssl-dev pkg-config apt-transport-https
130130
version: ${{ matrix.runner.name }}
131131

132-
- name: Install host dependencies (no cache)
133-
if: github.event_name != 'pull_request'
134-
run: |
135-
sudo apt-get update
136-
sudo apt-get install -y protobuf-compiler krb5-user libkrb5-dev \
137-
libclang-dev liblzma-dev libssl-dev pkg-config apt-transport-https
138-
139-
140132
- name: Checkout Repository
141133
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
142134
with:
@@ -173,7 +165,7 @@ jobs:
173165
echo "OPERATOR_VERSION=$NEW_VERSION" | tee -a "$GITHUB_OUTPUT"
174166

175167
- name: Install Nix
176-
uses: cachix/install-nix-action@fc6e360bedc9ee72d75e701397f0bb30dce77568 # v31.5.2
168+
uses: cachix/install-nix-action@630ae543ea3a38a9a4166f03376c02c50f408342 # v31.11.0
177169

178170
- name: Install Rust ${{ env.RUST_TOOLCHAIN_VERSION }} Toolchain
179171
shell: bash
@@ -213,7 +205,8 @@ jobs:
213205
publish-index-manifest:
214206
name: Publish/Sign ${{ needs.build-container-image.outputs.operator-version }} Index
215207
if: |
216-
(github.event_name != 'merge_group')
208+
github.repository_owner == 'stackabletech'
209+
&& (github.event_name != 'merge_group')
217210
&& needs.detect-changes.outputs.detected == 'true'
218211
&& !github.event.pull_request.head.repo.fork
219212
needs:
@@ -259,7 +252,8 @@ jobs:
259252
provenance-oci:
260253
name: Generate Provenance for ${{ needs.build-container-image.outputs.operator-version }} (oci.stackable.tech)
261254
if: |
262-
(github.event_name != 'merge_group')
255+
github.repository_owner == 'stackabletech'
256+
&& (github.event_name != 'merge_group')
263257
&& needs.detect-changes.outputs.detected == 'true'
264258
&& !github.event.pull_request.head.repo.fork
265259
needs:
@@ -286,7 +280,8 @@ jobs:
286280
provenance-quay:
287281
name: Generate Provenance for ${{ needs.build-container-image.outputs.operator-version }} (quay.io)
288282
if: |
289-
(github.event_name != 'merge_group')
283+
github.repository_owner == 'stackabletech'
284+
&& (github.event_name != 'merge_group')
290285
&& needs.detect-changes.outputs.detected == 'true'
291286
&& !github.event.pull_request.head.repo.fork
292287
needs:
@@ -313,7 +308,8 @@ jobs:
313308
publish-helm-chart:
314309
name: Package/Publish ${{ needs.build-container-image.outputs.operator-version }} Helm Chart
315310
if: |
316-
(github.event_name != 'merge_group')
311+
github.repository_owner == 'stackabletech'
312+
&& (github.event_name != 'merge_group')
317313
&& needs.detect-changes.outputs.detected == 'true'
318314
&& !github.event.pull_request.head.repo.fork
319315
needs:
@@ -358,7 +354,8 @@ jobs:
358354
openshift-preflight-check:
359355
name: Run OpenShift Preflight Check for ${{ needs.build-container-image.outputs.operator-version }}-${{ matrix.arch }}
360356
if: |
361-
(github.event_name != 'merge_group')
357+
github.repository_owner == 'stackabletech'
358+
&& (github.event_name != 'merge_group')
362359
&& needs.detect-changes.outputs.detected == 'true'
363360
&& !github.event.pull_request.head.repo.fork
364361
needs:
@@ -392,28 +389,45 @@ jobs:
392389
# WARNING: Do not change the name unless you will also be changing the
393390
# Required Checks (in branch protections) in GitHub settings.
394391
name: Finished Build and Publish
392+
if: always()
395393
needs:
394+
- detect-changes
396395
- cargo-udeps
396+
- build-container-image
397+
- publish-index-manifest
397398
- openshift-preflight-check
398399
- publish-helm-chart
400+
- provenance-oci
401+
- provenance-quay
399402
runs-on: ubuntu-latest
400403
steps:
401-
- run: echo "We are done here"
404+
- name: Fail if a required job failed or was cancelled
405+
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
406+
run: |
407+
echo "One or more required jobs failed or were cancelled."
408+
exit 1
409+
410+
- name: Finished
411+
run: echo "All required jobs succeeded or were intentionally skipped."
402412

403413
notify:
404414
name: Failure Notification
405415
if: |
406-
(failure() || github.run_attempt > 1)
416+
!cancelled()
417+
&& github.repository_owner == 'stackabletech'
418+
&& (contains(needs.*.result, 'failure') || github.run_attempt > 1)
407419
&& github.event_name != 'merge_group'
408420
&& needs.detect-changes.outputs.detected == 'true'
409421
&& !github.event.pull_request.head.repo.fork
410422
needs:
411423
- detect-changes
424+
- cargo-udeps
412425
- build-container-image
413426
- publish-index-manifest
414427
- provenance-oci
415428
- provenance-quay
416429
- publish-helm-chart
430+
- openshift-preflight-check
417431
- finished
418432
runs-on: ubuntu-latest
419433
steps:

template/.github/workflows/general_daily_security.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ jobs:
1818
permissions:
1919
contents: read
2020
checks: write
21-
issues: write
2221
steps:
2322
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
2423
with:
2524
persist-credentials: false
2625
- uses: rustsec/audit-check@69366f33c96575abad1ee0dba8212993eecbe998 # v2.0.0
26+
# Build against stable because cargo-audit sometimes depends on things
27+
# that require a newer Rust version than our pinned toolchain. This does
28+
# not influence the result, so it should be safe.
29+
env:
30+
RUSTUP_TOOLCHAIN: stable
2731
with:
2832
token: ${{ secrets.GITHUB_TOKEN }}

template/.github/workflows/integration-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ on:
1616
- custom
1717
test-mode-input:
1818
description: |
19-
The profile or the runner used. Eg: `smoke-latest` or `amd64` (see test/interu.yaml)
19+
The profile or the runner used. Eg: `smoke-latest` or `amd64` (see tests/interu.yaml)
2020
required: true
2121
test-suite:
2222
description: Name of the test-suite. Only used if test-mode is `custom`

template/.github/workflows/pr_prek.yaml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
contents: read
2222
steps:
2323
- name: Install host dependencies
24-
uses: awalsh128/cache-apt-pkgs-action@acb598e5ddbc6f68a970c5da0688d2f3a9f04d05 # v1.6.0
24+
uses: awalsh128/cache-apt-pkgs-action@553a35bb8ebd9fcabcb1c9451aa4c98e1b4ca8a9 # v1.6.3
2525
with:
2626
packages: protobuf-compiler krb5-user libkrb5-dev libclang-dev liblzma-dev libssl-dev pkg-config apt-transport-https
2727
version: ubuntu-latest

0 commit comments

Comments
 (0)