Skip to content

Conversation

mbg
Copy link
Member

@mbg mbg commented Sep 20, 2025

This PR updates sync.py to add concurrency settings to all PR checks so that:

  • There is one concurrency group per workflow per ref.
  • For pull_request events, in-progress workflows in the same concurrency group are cancelled if a new workflow is starting.
  • For other events, new workflows will wait until previous ones in the same concurrency group have finished.

This should reduce the number of concurrent workflows that we have running for the repo.

Risk assessment

For internal use only. Please select the risk level of this change:

  • Low risk: Changes are fully under feature flags, or have been fully tested and validated in pre-production environments and are highly observable, or are documentation or test only.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Consider adding a changelog entry for this change.
  • Confirm the readme and docs have been updated if necessary.

@mbg mbg requested a review from a team as a code owner September 20, 2025 13:21
@Copilot Copilot AI review requested due to automatic review settings September 20, 2025 13:21
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a concurrency configuration to generated PR check workflows to limit simultaneous runs per workflow/ref, cancelling superseded pull_request runs while serializing other event types. Key goal is to reduce parallel workflow executions and associated API load.

  • Adds concurrency block (group = workflow + ref) into workflow generation template (sync.py).
  • Regenerates all auto-generated workflow YAML files to include the concurrency settings.
  • Improves operational efficiency by cancelling obsolete PR runs and queueing non-PR runs.

Reviewed Changes

Copilot reviewed 56 out of 56 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pr-checks/sync.py Adds concurrency configuration template used to regenerate workflows.
.github/workflows/__with-checkout-path.yml Generated: adds concurrency block.
.github/workflows/__upload-ref-sha-input.yml Generated: adds concurrency block.
.github/workflows/__upload-quality-sarif.yml Generated: adds concurrency block.
.github/workflows/__unset-environment.yml Generated: adds concurrency block.
.github/workflows/__test-proxy.yml Generated: adds concurrency block.
.github/workflows/__test-local-codeql.yml Generated: adds concurrency block.
.github/workflows/__test-autobuild-working-dir.yml Generated: adds concurrency block.
.github/workflows/__swift-custom-build.yml Generated: adds concurrency block.
.github/workflows/__swift-autobuild.yml Generated: adds concurrency block.
.github/workflows/__submit-sarif-failure.yml Generated: adds concurrency block.
.github/workflows/__start-proxy.yml Generated: adds concurrency block.
.github/workflows/__split-workflow.yml Generated: adds concurrency block.
.github/workflows/__rust.yml Generated: adds concurrency block.
.github/workflows/__ruby.yml Generated: adds concurrency block.
.github/workflows/__rubocop-multi-language.yml Generated: adds concurrency block.
.github/workflows/__resolve-environment-action.yml Generated: adds concurrency block.
.github/workflows/__remote-config.yml Generated: adds concurrency block.
.github/workflows/__quality-queries.yml Generated: adds concurrency block.
.github/workflows/__packaging-inputs-js.yml Generated: adds concurrency block.
.github/workflows/__packaging-config-js.yml Generated: adds concurrency block.
.github/workflows/__packaging-config-inputs-js.yml Generated: adds concurrency block.
.github/workflows/__packaging-codescanning-config-inputs-js.yml Generated: adds concurrency block.
.github/workflows/__overlay-init-fallback.yml Generated: adds concurrency block.
.github/workflows/__multi-language-autodetect.yml Generated: adds concurrency block.
.github/workflows/__language-aliases.yml Generated: adds concurrency block.
.github/workflows/__job-run-uuid-sarif.yml Generated: adds concurrency block.
.github/workflows/__javascript-source-root.yml Generated: adds concurrency block.
.github/workflows/__init-with-registries.yml Generated: adds concurrency block.
.github/workflows/__go-tracing-legacy-workflow.yml Generated: adds concurrency block.
.github/workflows/__go-tracing-custom-build-steps.yml Generated: adds concurrency block.
.github/workflows/__go-tracing-autobuilder.yml Generated: adds concurrency block.
.github/workflows/__go-indirect-tracing-workaround.yml Generated: adds concurrency block.
.github/workflows/__go-indirect-tracing-workaround-no-file-program.yml Generated: adds concurrency block.
.github/workflows/__go-indirect-tracing-workaround-diagnostic.yml Generated: adds concurrency block.
.github/workflows/__go-custom-queries.yml Generated: adds concurrency block.
.github/workflows/__extractor-ram-threads.yml Generated: adds concurrency block.
.github/workflows/__export-file-baseline-information.yml Generated: adds concurrency block.
.github/workflows/__diagnostics-export.yml Generated: adds concurrency block.
.github/workflows/__cpp-deptrace-enabled.yml Generated: adds concurrency block.
.github/workflows/__cpp-deptrace-enabled-on-macos.yml Generated: adds concurrency block.
.github/workflows/__cpp-deptrace-disabled.yml Generated: adds concurrency block.
.github/workflows/__config-input.yml Generated: adds concurrency block.
.github/workflows/__config-export.yml Generated: adds concurrency block.
.github/workflows/__cleanup-db-cluster-dir.yml Generated: adds concurrency block.
.github/workflows/__bundle-zstd.yml Generated: adds concurrency block.
.github/workflows/__bundle-toolcache.yml Generated: adds concurrency block.
.github/workflows/__build-mode-rollback.yml Generated: adds concurrency block.
.github/workflows/__build-mode-none.yml Generated: adds concurrency block.
.github/workflows/__build-mode-manual.yml Generated: adds concurrency block.
.github/workflows/__build-mode-autobuild.yml Generated: adds concurrency block.
.github/workflows/__autobuild-direct-tracing.yml Generated: adds concurrency block.
.github/workflows/__autobuild-direct-tracing-with-working-dir.yml Generated: adds concurrency block.
.github/workflows/__autobuild-action.yml Generated: adds concurrency block.
.github/workflows/__analyze-ref-input.yml Generated: adds concurrency block.
.github/workflows/__all-platform-bundle.yml Generated: adds concurrency block.

# consequently the number of concurrent API requests.
'cancel-in-progress': "${{ github.event_name == 'pull_request' }}",
# The group is determined by the workflow name + the ref
'group': "${{ github.workflow }}-${{ github.ref }}"
Copy link
Contributor

Choose a reason for hiding this comment

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

My understanding is this prevents duplicate checks on the same ref due to marking ready for review, for instance. However couldn't we go further and base the concurrency group on the PR number, so that new pushes cancel runs for previous pushes?

Copy link
Member Author

Choose a reason for hiding this comment

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

According to the docs:

For workflows triggered by pull_request, this is the pull request merge branch. For workflows triggered by release, this is the release tag created. For other triggers, this is the branch or tag ref that triggered the workflow run. This is only set if a branch or tag is available for the event type. The ref given is fully-formed, meaning that for branches the format is refs/heads/<branch_name>. For pull requests events except pull_request_target, it is refs/pull/<pr_number>/merge. pull_request_target events have the ref from the base branch. For tags it is refs/tags/<tag_name>. For example, refs/heads/feature-branch-1.

So for pull_request events, we should get the fully-formed branch name (not the commit ref). You can see this in action on this PR: a bunch of in-progress workflows for 6fcf631 got cancelled because I pushed 2d8d639.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the clarification!

@mbg mbg merged commit 0c4919d into main Sep 22, 2025
299 checks passed
@mbg mbg deleted the mbg/ci/concurrency branch September 22, 2025 10:45
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