ci: limit push trigger to master to avoid duplicate runs on PRs#200
Conversation
Several workflows listen to both push and pull_request with overlapping
paths. When a PR head branch is pushed, GitHub fires both events, and
the existing concurrency keys cannot deduplicate them:
- build-check / build-envd-base-image group by github.ref, which
differs between push (refs/heads/<branch>) and pull_request
(refs/pull/N/merge);
- build-builder-image declares no concurrency block at all;
- hypervisor-integration explicitly includes ${{ github.event_name }}
in the concurrency key, which makes both runs coexist by design.
As a result, every check (Build CubeAPI, Build CubeMaster, ...) shows
up twice in the PR checks list, doubling CI cost for no benefit.
PR TencentCloud#195 and TencentCloud#196 are recent examples that triggered the duplicate
runs on Build Check.
Restrict the push trigger of the four affected workflows to the master
branch. PR validation now runs only via the pull_request event; direct
pushes to master remain covered.
Signed-off-by: staryxchen <staryxchen@tencent.com>
|
Claude finished @staryxchen's task in 2m 57s —— View job PR Review: ci: limit push trigger to master to avoid duplicate runs on PRs
DCO CheckThe single commit Overall AssessmentThis is a clean, well-motivated, and minimal fix. The root cause analysis in the PR description is thorough and correct — each of the four workflows has a different reason why its concurrency block fails to deduplicate push/pull_request runs:
Adding Specific Observations
VerdictNo issues found. The change is correct, minimal, and well-documented. The fix directly addresses the root cause and the PR description includes clear verification steps. |
Summary
Stops every CI check on PRs from being executed twice. After this fix, each affected workflow runs exactly once per PR (via
pull_request), instead of once viapushand once viapull_request.Why
Four workflows listen to both
pushandpull_requestwith the samepaths. When a PR head branch is pushed (typical for Dependabot or any branch update), both events fire and produce two independent workflow runs. None of the existingconcurrencyblocks deduplicate them:build-check.ymlgroup: build-check-${{ github.ref }}pushref isrefs/heads/<branch>;pull_requestref isrefs/pull/N/merge— different groupsbuild-builder-image.ymlbuild-envd-base-image.ymlgroup: ...${{ github.ref }}...build-checkhypervisor-integration.yaml${{ github.event_name }}Real-world examples on the Build Check workflow:
Build *check appears twice — runs25711649092(event=push) and25711650627(event=pull_request).25711913134(push) and25711914512(pull_request).The bug has existed since
build-check.ymlwas first introduced in PR #61 (commit85ab046, 2026-04-23); it just became visible recently as Dependabot PRs piled up.What changed
For each of the four workflows, restrict
pushto themasterbranch only:PR validation continues to run on
pull_request. Direct pushes tomaster(post-merge) keep triggering builds as before.Affected files (4 lines added in total):
.github/workflows/build-check.yml.github/workflows/build-builder-image.yml.github/workflows/build-envd-base-image.yml.github/workflows/hypervisor-integration.yamlHow to verify
This PR itself is the test case — it modifies all four workflow files, which are inside their own
pathslists, so all four workflows will be triggered.Note GitHub uses the base branch version of workflow files for
pull_requestevents and the head branch version forpushevents. On this PR:pull_requestruns use master's old config → still fire once (this is the run we want to keep).pushevent would use this branch's new config → skipped because the head branch is notmaster.Net result: each workflow appears once in the PR checks list.
Test plan
build-checkonce (event: push, conclusion: success)