forge
Explore
Log in

Don't you dare go Hollow

Parallel clippy/test runners, cancel stale CI

Browse files at this commit

b3168eb3b7c2a2b0c23aacdbd696238f6f94e3cbAhmet Kaan GümüşParent: 4de958f
  • chore
    • parallel clippy/test runners, cancel stale CI
Show full message
⚡ chore: parallel clippy/test runners, cancel stale CI

Clippy and Build and test on separate runners. A new push cancels
in-flight CI on the same ref. Deploy stays serial.
.github/workflows/main.ymlmodified+52 -19
@@ -1,6 +1,7 @@
1-# VPS deploy, compose-style, split into two jobs so failure recovery is cheap:
1+# VPS deploy, compose-style, split so failure recovery is cheap:
22 #
3-# Build and test — Postgres sidecar, clippy, the whole suite, the release
3+# Clippy — -D warnings on --all-targets, own runner. No Postgres.
4+# Build and test — Postgres sidecar, the whole suite, the release
45 # build; packs the stripped binary + migrations into the
56 # runtime image (deploy/Containerfile.runtime) and
67 # uploads the image tarball + compose files as the run's
@@ -11,6 +12,11 @@
1112 # restart the stack, /health-gated rollback to the
1213 # previous tag, independent after-the-fact verify.
1314 #
15+# Clippy and Build and test run in parallel. Deploy needs both green.
16+# A new push cancels in-flight Clippy/Build on the same ref; it never
17+# cancels an in-flight Deploy (two deploys racing would interleave the
18+# compose stack).
19+#
1420 # The split is the recovery story, not ceremony:
1521 # * "Re-run failed jobs" on a run whose Deploy step failed re-runs ONLY the
1622 # ~1-minute deploy job — the built image is still in the run's artifact.
@@ -44,13 +50,10 @@ on:
4450 # The manual redeploy door — see the header comment for how and why.
4551 workflow_dispatch:
4652
47-# One deploy at a time: the deploy reloads one compose stack; two of them
48-# racing would interleave container recreations and could leave the served
49-# image and the tag files from different builds. A dispatched redeploy
50-# queues behind any in-flight push deploy rather than racing it.
51-concurrency:
52- group: deploy
53- cancel-in-progress: false
53+# Deploy serialisation lives on the deploy job, not the workflow: a new
54+# push must be allowed to cancel stale Clippy/Build without touching an
55+# in-flight VPS swap.
56+
5457
5558 env:
5659 # A gnu binary links against the toolchain's glibc, so the runner is
@@ -85,11 +88,39 @@ env:
8588 SQLX_OFFLINE: "true"
8689
8790 jobs:
91+ clippy:
92+ name: Clippy
93+ if: github.event_name == 'push'
94+ runs-on: ubuntu-24.04
95+ concurrency:
96+ group: ci-${{ github.workflow }}-${{ github.ref }}-clippy
97+ cancel-in-progress: true
98+ env:
99+ CARGO_INCREMENTAL: "0"
100+ steps:
101+ - name: Checkout
102+ uses: actions/checkout@v4
103+ - name: Set up Rust
104+ run: rustup toolchain install stable --profile minimal
105+ - name: Cache cargo
106+ uses: Swatinem/rust-cache@v2
107+ with:
108+ cache-all-crates: true
109+ prefix-key: v1-rust-gnu
110+ # Restore the build job's cache; never save over it. Two jobs
111+ # writing the same key race, and clippy is check-mode rmeta.
112+ save-if: false
113+ - name: Clippy
114+ run: cargo clippy --all-targets --locked -- -D warnings
115+
88116 build:
89117 name: Build and test
90118 # Pushes only: a manual redeploy reuses the newest green artifact
91119 # instead of paying the suite again.
92120 if: github.event_name == 'push'
121+ concurrency:
122+ group: ci-${{ github.workflow }}-${{ github.ref }}-build
123+ cancel-in-progress: true
93124 # Pinned, not `latest`: the gnu build links the runner's glibc and the
94125 # runtime image is debian:trixie-slim — float either side carelessly
95126 # and the binary stops loading. See the TARGET comment above.
@@ -151,15 +182,12 @@ jobs:
151182 with:
152183 tool: cargo-nextest
153184
154- # Zero clippy warnings is a standing project rule; CI is what keeps it.
155- - name: Clippy
156- run: cargo clippy --all-targets --locked -- -D warnings
157-
158185 # A broken build must never reach the server: the whole suite gates
159186 # the deploy (doc_sync included, so README drift blocks it too).
160187 - name: Test
161188 run: cargo nextest run
162189
190+
163191 - name: Build the release
164192 run: |
165193 set -euo pipefail
@@ -211,14 +239,19 @@ jobs:
211239
212240 deploy:
213241 name: Deploy
214- needs: build
215- # Push: only behind a green build — the suite gates the server.
216- # Dispatch: build is skipped on purpose (see its `if`), and `always()`
217- # is what stops that skip from cascading past this gate.
242+ needs: [clippy, build]
243+ concurrency:
244+ group: deploy
245+ cancel-in-progress: false
246+ # Push: only behind green clippy AND a green build — both gate the server.
247+ # Dispatch: both CI jobs are skipped on purpose (see their `if`), and
248+ # `always()` is what stops that skip from cascading past this gate.
218249 if: >-
219250 always() &&
220- (needs.build.result == 'success' ||
221- (github.event_name == 'workflow_dispatch' && needs.build.result == 'skipped'))
251+ ((needs.clippy.result == 'success' && needs.build.result == 'success') ||
252+ (github.event_name == 'workflow_dispatch' &&
253+ needs.clippy.result == 'skipped' &&
254+ needs.build.result == 'skipped'))
222255 runs-on: ubuntu-24.04
223256 steps:
224257 # A push deploy takes the release this very run built and gated.