Repository navigation
ci: serialise the automation workflows on the state they write - #1310
Merged
Merged
Conversation
Four workflows open a pull request with peter-evans/create-pull-request on a branch they name themselves, and none declared a concurrency group. The action force-pushes refs/heads/<branch> with --force-with-lease and, with delete-branch: true, deletes that ref once it stops differing from the base, so two overlapping runs (a dispatch during the nightly cron, or Run workflow pressed twice) either fail the loser's push or delete the ref the other run just opened a pull request from. Add a concurrency group to each, keyed exactly as coarsely as the branch: a constant group for import-architectures, refresh-community-people and refresh-radar-reports, and a per-issue group for architecture-submission so two different submissions still proceed in parallel. All are cancel-in-progress: false, because cancelling a run that has already pushed is the failure mode rather than the cure. create-milestones and pr-queue-hygiene push no branch but mutate GitHub state non-atomically (a read-once milestone snapshot; a marker comment read then written), so they get constant, non-cancelling groups too. tests/ci-concurrency.test.mjs gains the contract so the gap cannot reopen: a workflow using the action must declare a group that varies with nothing the branch does not (racingBranchWorkflows); unexplainedConstantGroups now accepts any event-keyed group, not only per-PR ones; the five new constant groups are recorded in SERIALISED_WORKFLOWS. With the workflow half reverted the contract names all four branch-pushing files. Closes #1222 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Bob Killen <bkillen@linuxfoundation.org>
Contributor
62b8794
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Finding (#1222)
Four workflows open a pull request with
peter-evans/create-pull-requeston a branch they name themselves, and none declared aconcurrencygroup. The action force-pushesrefs/heads/<branch>with--force-with-leaseand, withdelete-branch: true, deletes that ref once it stops differing from the base. Two overlapping runs (aworkflow_dispatchduring the nightly cron, or Run workflow pressed twice) therefore either fail the loser's push on stale info or delete the ref the other run just opened a pull request from. Two further workflows mutate GitHub state non-atomically on a repeatable trigger.Half 1: the workflows
architecture-submission.ymlautomation/architecture-issue-${{ github.event.issue.number }}import-architectures.ymlautomation/import-architecturesrefresh-community-people.ymlautomation/refresh-community-peoplerefresh-radar-reports.ymlautomation/refresh-radar-reportscreate-milestones.ymlcreate-milestonespr-queue-hygiene.ymlpr-queue-hygieneAll six are
cancel-in-progress: false: cancelling a run that has already pushed a branch, posted a marker or created a milestone is the failure mode, not the cure. Each block carries a comment explaining itself.Half 2: the contract (
tests/ci-concurrency.test.mjs)racingBranchWorkflows/pullRequestBranches/expressionsIn: every workflow using the action must declare a group that varies with nothing the branch does not. A coarser group is accepted (it only queues more than it must); a finer one puts two runs that write one ref in different lanes and is reported.unexplainedConstantGroupsnow usesisPerEvent(addsgithub.event.issue.number,inputs.) so the per-issue key is recognised as event-keyed rather than repository-wide.SERIALISED_WORKFLOWSwith their reasons; the existing retire-itself test keeps them honest.Verification
node --test tests/ci-concurrency.test.mjs: 19 pass. With.github/workflows/reverted, 2 fail and the branch-race contract names exactly the four branch-pushing files.ci-supply-chain,workflow-scripts,automation-workflow-ordering: 42 pass.npm run test:unit:coverage:check: green (src 100/100, harness 100/99.57, all files 99.66/96.16).check:format,check:spelling: clean.Closes #1222