Skip to content

Propose cancelling the runs of merged pull requests - #323

Open
potiuk wants to merge 4 commits into
apache:masterfrom
potiuk:cancel-merged-pr-runs
Open

potiuk wants to merge 4 commits into
apache:masterfrom
potiuk:cancel-merged-pr-runs

Conversation

@potiuk

@potiuk potiuk commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Adds a proposed technique to the GitHub Actions optimization page: cancelling the pull_request runs that keep going after their pull request has merged.

Maintainers often merge as soon as the checks they need are green, while slower jobs of the same run are still queued or running. Those jobs keep holding shared runners for a result nobody reads, and a concurrency group does not catch them, because the merge does not start a new run in the pull request's group. On 2026-10-25 Apache Airflow had four such runs going at once, and two of them stopped only with force-cancel.

The new section explains how a workflow triggered by push can cancel them: it looks up the pull request of the pushed commit and cancels that pull request's unfinished pull_request runs. It also lists what such a workflow has to get right (matching fork pull requests by head commit and repository, not cancelling workflows triggered by the merge itself, skipping heads that an open pull request still uses, force-cancelling what does not stop) and gives a minimal workflow. Running on push instead of a schedule was suggested in review by @slawekjaranowski. The section is marked Proposed in the summary table until it has been used in production for a while.

The recipe was run read-only against recent merges in apache/airflow (with gh run cancel replaced by echo): it matched the runs of each merged pull request, including those from forks, and left out the workflows triggered by the merge.


Drafted-by: Claude Code (Opus 5); reviewed by @potiuk before posting

@potiuk

potiuk commented Oct 25, 2026

Copy link
Copy Markdown
Member Author

cc: @cottage14

61049f4 left the section headings of app-upgrade-policy.md without the
blank line after them that MD022 requires, so the prek check fails for
every pull request.

Generated-by: Claude Opus 5

@cottage14 cottage14 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 204: change 'for a run that is still running some time after a normal cancel' to 'to end a run that continues after a normal cancel.' (to avoid 'run' and 'running' in the same sentence

Also, I don't think we need the Airflow citations on the Infra site,

@potiuk

potiuk commented Oct 25, 2026

Copy link
Copy Markdown
Member Author

@cottage14 Thanks for the review. I reworded the force-cancel tip as you suggested and removed the Airflow citations from this section. Could you take another look?

There is also a separate commit that adds the blank lines after the headings in app-upgrade-policy.md. Since 61049f4 they failed markdownlint, which made the prek check fail for every pull request.


Drafted-by: Claude Code (Opus 5); reviewed by @potiuk before posting

Running on push handles only the pull request that was just merged,
right after the merge, instead of scanning every unfinished run on a
schedule. Suggested in review.

Generated-by: Claude Opus 5
@potiuk

potiuk commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

@cottage14 Since your review, the section changed in one more way: following @slawekjaranowski's suggestion, the workflow now runs on push and cancels only the runs of the pull request that was just merged, instead of scanning all runs on a schedule (1adbf43). Your two earlier points are in 830e649. Could you take another look?


Drafted-by: Claude Code (Opus 5); reviewed by @potiuk before posting

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants