Parallel clippy/test runners, cancel stale CI
Browse files at this commitb3168eb3b7c2a2b0c23aacdbd696238f6f94e3cbParent: 4de958f- chore
- parallel clippy/test runners, cancel stale CI
1 changed file +52 -19
- .github/workflows/main.yml +52 -19
.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: |
| 2 | # | 2 | # |
| 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 | ||
| 4 | # build; packs the stripped binary + migrations into the | 5 | # build; packs the stripped binary + migrations into the |
| 5 | # runtime image (deploy/Containerfile.runtime) and | 6 | # runtime image (deploy/Containerfile.runtime) and |
| 6 | # uploads the image tarball + compose files as the run's | 7 | # uploads the image tarball + compose files as the run's |
| @@ -11,6 +12,11 @@ | |||
| 11 | # restart the stack, /health-gated rollback to the | 12 | # restart the stack, /health-gated rollback to the |
| 12 | # previous tag, independent after-the-fact verify. | 13 | # previous tag, independent after-the-fact verify. |
| 13 | # | 14 | # |
| 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 | +# | ||
| 14 | # The split is the recovery story, not ceremony: | 20 | # The split is the recovery story, not ceremony: |
| 15 | # * "Re-run failed jobs" on a run whose Deploy step failed re-runs ONLY the | 21 | # * "Re-run failed jobs" on a run whose Deploy step failed re-runs ONLY the |
| 16 | # ~1-minute deploy job — the built image is still in the run's artifact. | 22 | # ~1-minute deploy job — the built image is still in the run's artifact. |
| @@ -44,13 +50,10 @@ on: | |||
| 44 | # The manual redeploy door — see the header comment for how and why. | 50 | # The manual redeploy door — see the header comment for how and why. |
| 45 | workflow_dispatch: | 51 | workflow_dispatch: |
| 46 | 52 | ||
| 47 | -# One deploy at a time: the deploy reloads one compose stack; two of them | 53 | +# Deploy serialisation lives on the deploy job, not the workflow: a new |
| 48 | -# racing would interleave container recreations and could leave the served | 54 | +# push must be allowed to cancel stale Clippy/Build without touching an |
| 49 | -# image and the tag files from different builds. A dispatched redeploy | 55 | +# in-flight VPS swap. |
| 50 | -# queues behind any in-flight push deploy rather than racing it. | 56 | + |
| 51 | -concurrency: | ||
| 52 | - group: deploy | ||
| 53 | - cancel-in-progress: false | ||
| 54 | 57 | ||
| 55 | env: | 58 | env: |
| 56 | # A gnu binary links against the toolchain's glibc, so the runner is | 59 | # A gnu binary links against the toolchain's glibc, so the runner is |
| @@ -85,11 +88,39 @@ env: | |||
| 85 | SQLX_OFFLINE: "true" | 88 | SQLX_OFFLINE: "true" |
| 86 | 89 | ||
| 87 | jobs: | 90 | 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 | + | ||
| 88 | build: | 116 | build: |
| 89 | name: Build and test | 117 | name: Build and test |
| 90 | # Pushes only: a manual redeploy reuses the newest green artifact | 118 | # Pushes only: a manual redeploy reuses the newest green artifact |
| 91 | # instead of paying the suite again. | 119 | # instead of paying the suite again. |
| 92 | if: github.event_name == 'push' | 120 | if: github.event_name == 'push' |
| 121 | + concurrency: | ||
| 122 | + group: ci-${{ github.workflow }}-${{ github.ref }}-build | ||
| 123 | + cancel-in-progress: true | ||
| 93 | # Pinned, not `latest`: the gnu build links the runner's glibc and the | 124 | # Pinned, not `latest`: the gnu build links the runner's glibc and the |
| 94 | # runtime image is debian:trixie-slim — float either side carelessly | 125 | # runtime image is debian:trixie-slim — float either side carelessly |
| 95 | # and the binary stops loading. See the TARGET comment above. | 126 | # and the binary stops loading. See the TARGET comment above. |
| @@ -151,15 +182,12 @@ jobs: | |||
| 151 | with: | 182 | with: |
| 152 | tool: cargo-nextest | 183 | tool: cargo-nextest |
| 153 | 184 | ||
| 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 | - | ||
| 158 | # A broken build must never reach the server: the whole suite gates | 185 | # A broken build must never reach the server: the whole suite gates |
| 159 | # the deploy (doc_sync included, so README drift blocks it too). | 186 | # the deploy (doc_sync included, so README drift blocks it too). |
| 160 | - name: Test | 187 | - name: Test |
| 161 | run: cargo nextest run | 188 | run: cargo nextest run |
| 162 | 189 | ||
| 190 | + | ||
| 163 | - name: Build the release | 191 | - name: Build the release |
| 164 | run: | | 192 | run: | |
| 165 | set -euo pipefail | 193 | set -euo pipefail |
| @@ -211,14 +239,19 @@ jobs: | |||
| 211 | 239 | ||
| 212 | deploy: | 240 | deploy: |
| 213 | name: Deploy | 241 | name: Deploy |
| 214 | - needs: build | 242 | + needs: [clippy, build] |
| 215 | - # Push: only behind a green build — the suite gates the server. | 243 | + concurrency: |
| 216 | - # Dispatch: build is skipped on purpose (see its `if`), and `always()` | 244 | + group: deploy |
| 217 | - # is what stops that skip from cascading past this gate. | 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. | ||
| 218 | if: >- | 249 | if: >- |
| 219 | always() && | 250 | always() && |
| 220 | - (needs.build.result == 'success' || | 251 | + ((needs.clippy.result == 'success' && needs.build.result == 'success') || |
| 221 | - (github.event_name == 'workflow_dispatch' && needs.build.result == 'skipped')) | 252 | + (github.event_name == 'workflow_dispatch' && |
| 253 | + needs.clippy.result == 'skipped' && | ||
| 254 | + needs.build.result == 'skipped')) | ||
| 222 | runs-on: ubuntu-24.04 | 255 | runs-on: ubuntu-24.04 |
| 223 | steps: | 256 | steps: |
| 224 | # A push deploy takes the release this very run built and gated. | 257 | # A push deploy takes the release this very run built and gated. |