Skip to content

ci: cancel duplicate PR runs to save runner resources#85

Open
maxholdaway wants to merge 2 commits into
mainfrom
ci/cancel-pr-duplicate-runs
Open

ci: cancel duplicate PR runs to save runner resources#85
maxholdaway wants to merge 2 commits into
mainfrom
ci/cancel-pr-duplicate-runs

Conversation

@maxholdaway
Copy link
Copy Markdown
Contributor

Summary

Adds workflow-level concurrency: to all 12 reusable workflows so that rapid PR pushes cancel in-progress runs of the same workflow on the same PR. Pushes to main/master/release branches and tags are never cancelled (cancel-in-progress is gated on github.event_name == 'pull_request'), so tag-and-publish flows like bump-version and docker-service-publish keep their serialization guarantees.

Group key strategy:

  • ${{ github.workflow }}-${{ github.ref }} for single-call workflows (bump-version, golang-ci, golang-security)
  • Matrix-discriminating input added to the key where callers may matrix the reusable workflow:
    • inputs.imagedocker-api-service, docker-service, docker-service-build, docker-service-publish
    • inputs.dashboard-pathgrafana-dashboard-publish, grafana-dashboard-validate
    • inputs.pathsterraform-v0-ci, terraform-v1-ci
    • inputs.docker-project-namedocker-load-test

Inside a reusable workflow, github.workflow and github.ref resolve to the caller's values, so each consuming repo gets its own per-PR concurrency slot automatically — no changes needed in service repos.

Test plan

  • Open a draft PR in a consuming repo, push two commits in quick succession, confirm the first run shows cancelled and the second runs to completion.
  • Push two commits to a main branch back-to-back in a consuming repo, confirm both runs complete (second queues behind first, neither is cancelled).
  • Confirm a matrix caller that calls e.g. docker-service.yml with multiple image values runs all matrix variants in parallel (no concurrency collisions).

🤖 Generated with Claude Code

Add workflow-level concurrency to every reusable workflow. PR pushes
cancel any in-progress run for the same caller workflow + ref; pushes
to main/release branches and tags are never cancelled (cancel-in-progress
is gated on github.event_name == 'pull_request').

Group keys include a matrix-discriminating input where one exists
(inputs.image, inputs.paths, inputs.dashboard-path, inputs.docker-project-name)
so callers that matrix the same reusable workflow across multiple targets
don't serialize on a shared slot.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@maxholdaway maxholdaway requested a review from a team as a code owner May 28, 2026 12:12
@gitstream-cm
Copy link
Copy Markdown

gitstream-cm Bot commented May 28, 2026

🚨 gitStream Monthly Automation Limit Reached 🚨

Your organization has exceeded the number of pull requests allowed for automation with gitStream.
Monthly PRs automated: 250/250

To continue automating your PR workflows and unlock additional features, please contact LinearB.

Copy link
Copy Markdown
Contributor

@dtslubbersen dtslubbersen left a comment

Choose a reason for hiding this comment

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

Amazing change 🚀

A reusable workflow's github context (workflow, ref, run_id, job) is
identical for every caller-job invocation, so the only thing that
distinguishes "build" from "build-mysql8" when both call golang-ci.yml
is the inputs they pass. Without this, two such caller jobs would share
a concurrency slot and either cancel each other on PRs or serialize on
push to main.

Enumerate every input in the group key so distinct input combinations
get distinct slots, while identical-input duplicate calls correctly
share one (since they're doing the same work). Same shape as before —
just a richer key.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

5 participants