Skip to content

Key the doc build concurrency group on the pull request number - #7174

Merged
albertvillanova merged 1 commit into
mainfrom
key-doc-build-concurrency-on-pr-number
Sep 14, 2026
Merged

albertvillanova merged 1 commit into
mainfrom
key-doc-build-concurrency-on-pr-number

Conversation

@albertvillanova

@albertvillanova albertvillanova commented Sep 10, 2026

Copy link
Copy Markdown
Member

What does this PR do?

build_pr_documentation.yml keys its concurrency group on github.head_ref, which is the head branch name without the fork owner. Two open PRs from different forks that both use a branch called patch-1 therefore land in the same group, and a push on one cancels the in-flight doc build on the other.

github.event.pull_request.number is unique per pull request. This workflow only triggers on pull_request, so the github.run_id fallback is never reached, but it is kept so the block stays identical to the one in tests.yml and tests-experimental.yml. Happy to drop it if you would rather the expression say only what this workflow needs.

Bugbot found the same pattern on #7170 (comment), where it had been copied from here. No two of the 182 currently open PRs share a head branch name, but 130 of them come from forks, so the collision is reachable.


Note

Low Risk
Single CI workflow concurrency expression change with no runtime or application impact.

Overview
Fixes cross-PR doc build cancellations when multiple forks use the same branch name (e.g. patch-1).

The Build PR Documentation workflow’s concurrency.group now uses github.event.pull_request.number instead of github.head_ref, so each PR gets its own group and pushes on one PR no longer cancel in-flight doc builds on another. The github.run_id fallback is unchanged for parity with other workflows.

Reviewed by Cursor Bugbot for commit 5adea5a. Bugbot is set up for automated code reviews on this repo. Configure here.

@bot-ci-comment

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@albertvillanova

Copy link
Copy Markdown
Member Author

build_pr_documentation.yml was itself copied from the workflow template in the doc-builder README, which still carries the head_ref form. The same one-liner is proposed there in huggingface/doc-builder#829, so new copies stop inheriting it.

@qgallouedec qgallouedec left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Indeed, I learned something here.

On the fallback, tests.yml and tests-experimental.yml use || github.ref rather than || github.run_id, so it isn't quite identical either way. They also run on push where theirs is reachable, while this one is pull_request-only so yours stays dead. Keep it for symmetry if you prefer, no strong view.

Worth pushing the one-liner upstream to the doc-builder template too?, since that's where the pattern came from.

@albertvillanova

albertvillanova commented Sep 14, 2026

Copy link
Copy Markdown
Member Author

Thanks, @qgallouedec.

You are right about main as it stands: #7172 changed both test workflows to || github.ref, so the three blocks are not identical today. However, #7201 reverts that to || github.run_id in both (see explanation in #7169 (comment)), which restores the symmetry this PR was leaning on.

Your reachability point holds either way. In tests.yml the fallback is load-bearing, since it is what gives every push its own group and keeps main runs from cancelling each other. Here it is dead, because this workflow only triggers on pull_request. I would still keep it. The value is that the block can be copied between workflows without anyone having to work out which half applies, and copying it without thinking is exactly how the head_ref collision travelled from the doc-builder template into this file, and from here into tests.yml.

On the template, as I already commented in #7174 (comment), that is what I did on Friday:

The same one-liner is proposed there in huggingface/doc-builder#829, so new copies stop inheriting it.

@albertvillanova
albertvillanova merged commit 547c547 into main Sep 14, 2026
10 checks passed
@albertvillanova
albertvillanova deleted the key-doc-build-concurrency-on-pr-number branch September 14, 2026 05:22
@albertvillanova albertvillanova added the 🔧 maintenance CI, tooling, tests, or repo upkeep label Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔧 maintenance CI, tooling, tests, or repo upkeep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants