Skip to content

ci: cancel superseded PR runs of Lean Action CI - #908

Open
jessealama wants to merge 2 commits into
leanprover:mainfrom
jessealama:ci/lean-action-concurrency
Open

jessealama wants to merge 2 commits into
leanprover:mainfrom
jessealama:ci/lean-action-concurrency

Conversation

@jessealama

@jessealama jessealama commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Adds a concurrency group to lean_action_ci.yml so that new pushes to a PR cancel running steps instead of doing a redundant full build behind it. This saves resources (almost certainly wasted compute and network traffic). It could even reduce the bill the leanprover GitHub org pays for compute. Canceling a redundant run also better reflects development reality: a canceled run shows the branch is busy.

(Mathlib does the same thing. GitHub-native concurrency, replacing a third-party approach, was introduced in this PR.)

Runs on main and nightly-testing are never canceled. report_failures_nightly-testing.yml consumes completed runs via workflow_run, so canceling one there would swallow a status report. This also works with the merge queue.

docs.yml is left alone since it only runs on pushes to main.

Add a concurrency group keyed on workflow and ref. On PR refs a new push
cancels the in-flight run. On main and nightly-testing runs queue instead,
since report_failures_nightly-testing.yml consumes every completed run.
@jessealama
jessealama force-pushed the ci/lean-action-concurrency branch from c852a2c to 0b107a5 Compare September 15, 2026 17:52
Comment thread .github/workflows/lean_action_ci.yml Outdated
Comment on lines +14 to +15
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/nightly-testing' }}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this may not behave as expected because of the concurrency queue, which by default allows only one job at a time. There is a setting to expand this, but the docs indicate

Note that queue: max cannot be combined with cancel-in-progress: true, because the two options describe conflicting behaviors for handling in-progress runs.

I'm not 100% sure if that also applies to conditional cancel-in-progress, but it seems simplest to follow what Mathlib does: when these conditions apply the id is included in the group name, making them unique.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, good point. I thought that what I had should be safe (and maybe it is), but doing what Mathlib does is just fine.

@jessealama
jessealama force-pushed the ci/lean-action-concurrency branch from 1622106 to 29b08cf Compare September 16, 2026 15:57
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.

2 participants