Cancel the run when Clippy fails
Browse files at this commit57527df057b34b71b847ff0713d5975f9ae5e138Parent: d8dad92- fix
- cancel the run when Clippy fails
1 changed file +26 -0
- .github/workflows/main.yml +26 -0
.github/workflows/main.ymlmodified+26 -0
| @@ -29,6 +29,14 @@ | |||
| 29 | # cancels an in-flight Deploy (two deploys racing would interleave the | 29 | # cancels an in-flight Deploy (two deploys racing would interleave the |
| 30 | # compose stack). | 30 | # compose stack). |
| 31 | # | 31 | # |
| 32 | +# Fail-fast: Clippy is ~2 minutes, Build-and-test up to 90. A red Clippy | ||
| 33 | +# still leaves the suite burning runner minutes for nothing — the deploy | ||
| 34 | +# already gates on both, so the outcome is decided. The `clippy-guard` | ||
| 35 | +# job fires the moment Clippy concludes red and cancels the whole run, | ||
| 36 | +# killing the in-flight suite. Parallelism is untouched: the guard only | ||
| 37 | +# ever runs on the failure path. (GitHub has no native "sibling job | ||
| 38 | +# failed → cancel the rest"; the run-cancel API is the door.) | ||
| 39 | +# | ||
| 32 | # The split is the recovery story, not ceremony: | 40 | # The split is the recovery story, not ceremony: |
| 33 | # * "Re-run failed jobs" on a run whose Deploy step failed re-runs ONLY the | 41 | # * "Re-run failed jobs" on a run whose Deploy step failed re-runs ONLY the |
| 34 | # ~1-minute deploy job — the built image is still in the run's artifact. | 42 | # ~1-minute deploy job — the built image is still in the run's artifact. |
| @@ -137,6 +145,24 @@ jobs: | |||
| 137 | - name: Clippy | 145 | - name: Clippy |
| 138 | run: cargo clippy --all-targets --locked -- -D warnings | 146 | run: cargo clippy --all-targets --locked -- -D warnings |
| 139 | 147 | ||
| 148 | + # Fires the moment Clippy concludes red and cancels the run, killing the | ||
| 149 | + # in-flight Build-and-test instead of letting it burn up to 90 minutes on | ||
| 150 | + # a run whose outcome is already decided. Skipped on a green Clippy and on | ||
| 151 | + # workflow_dispatch (Clippy itself is skipped there, which is not a | ||
| 152 | + # failure). Needs `actions: write` to cancel the run. | ||
| 153 | + clippy-guard: | ||
| 154 | + name: Cancel run on Clippy failure | ||
| 155 | + needs: clippy | ||
| 156 | + if: failure() | ||
| 157 | + runs-on: ubuntu-24.04 | ||
| 158 | + permissions: | ||
| 159 | + actions: write | ||
| 160 | + steps: | ||
| 161 | + - name: Cancel the run | ||
| 162 | + env: | ||
| 163 | + GH_TOKEN: ${{ github.token }} | ||
| 164 | + run: gh api -X POST "/repos/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID/cancel" | ||
| 165 | + | ||
| 140 | build: | 166 | build: |
| 141 | name: Build and test | 167 | name: Build and test |
| 142 | # Pushes always build (and, by default, test). A manual redeploy reuses | 168 | # Pushes always build (and, by default, test). A manual redeploy reuses |