Repository navigation
ci: fold six CI jobs into four with parallel and background steps; cancel superseded and closed-PR runs #3658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0d333e3
ci: temporary fallow timing probe
thymikee 29e3c10
ci: probe statx paths
thymikee adfe685
ci: probe dirname via awk
thymikee 1d8f508
ci: probe warm fallow cache and parallel step syntax
thymikee 365a0f5
ci: cache fallow, fold compat into repo guards and lint into typechec…
thymikee c7404c5
ci: run the fallow audit in the background and drop the fallow cache
thymikee 249e6ed
ci: run numeric ranges in sequence so only the fallow audit shares th…
thymikee 27d5ca6
ci: cancel a PR's unfinished runs when it closes, and supersede runs …
thymikee a096d79
ci: cancel closed-PR runs from a pull_request trigger instead of pull…
thymikee ca79480
ci: keep test-app build-cache runs uncancelled, and fail on a refused…
thymikee 01992b3
ci: cancel only runs that belong to the closed PR
thymikee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| name: Cancel runs of closed PRs | ||
|
|
||
| # A merged or closed PR gates nothing, so its queued and running runs only hold runners. | ||
| on: | ||
| pull_request: | ||
| types: | ||
| - closed | ||
|
|
||
| permissions: | ||
| actions: write | ||
|
|
||
| jobs: | ||
| cancel: | ||
| # A fork PR's token is read-only, so it cannot cancel runs. | ||
| if: github.event.pull_request.head.repo.full_name == github.repository | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| steps: | ||
| # pr-preview-cleanup.yml runs on the same close event and must finish. | ||
| - name: Cancel the PR's unfinished runs | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| HEAD_REF: ${{ github.event.pull_request.head.ref }} | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| RUN_ID: ${{ github.run_id }} | ||
| run: | | ||
| ids=$(gh api --paginate -X GET "repos/$GITHUB_REPOSITORY/actions/runs" \ | ||
| -f branch="$HEAD_REF" -f event=pull_request -f per_page=100 \ | ||
| --jq ".workflow_runs[] | ||
| | select(.status != \"completed\") | ||
| | select(.head_repository.full_name == \"$GITHUB_REPOSITORY\") | ||
| | select(any(.pull_requests[]; .number == $PR_NUMBER)) | ||
| | select(.id != $RUN_ID) | ||
| | select(.path != \".github/workflows/pr-preview-cleanup.yml\") | ||
|
thymikee marked this conversation as resolved.
|
||
| | .id") | ||
| refused=() | ||
| for id in $ids; do | ||
| gh run cancel "$id" --repo "$GITHUB_REPOSITORY" || refused+=("$id") | ||
| done | ||
| # A run that finished after the listing refuses cancellation; any other refusal is an error. | ||
| for id in "${refused[@]}"; do | ||
| status=$(gh run view "$id" --repo "$GITHUB_REPOSITORY" --json status --jq .status) | ||
| [ "$status" = completed ] || { echo "::error::Could not cancel run $id ($status)"; exit 1; } | ||
| done | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.