ci: key workflow concurrency groups on pull request number #7829
miri.yml triggers only on schedule and workflow_dispatch (see its on: block), and nothing calls it through workflow_call. github.event.pull_request.number is never set there, and github.head_ref was already empty, so this edit changes no group at runtime. Keeping it for consistency is fine, but the PR description and the issue should not count it as a fix.
The bug is that a concurrency group names github.head_ref. A check that scans .github/workflows/.yml for a group: line containing github.head_ref is about 15 lines and fails on exactly the three files this PR fixes. check_concurrency_groups instead adds a hand-rolled YAML block parser (concurrency_blocks, about 60 lines), simulates pull request, workflow_run, push, merge_group, schedule and workflow_dispatch contexts, and re-derives the case-only and cross-fork properties by evaluating expressions. The script already holds a concurrency: regex check in check_fork_runs (line 1767) that could host the simple rule. I would replace the new function with the short scan and drop the helpers it needs.
This block re-tests ci.yml's group against ci_label.yml runs and asserts that ci_label.yml has no concurrency. ci.yml is not touched by this PR (its group was fixed in https://github.com/apache/datafusion-comet/pull/7311), so this is new coverage for a different property and belongs in its own change if it is wanted.
workflow_triggers (generalizing ci_triggers), the _unquote_yaml_scalar change to workflow_name, and the evaluate_condition to evaluate_expression split exist only to serve the new checker. If the checker shrinks to the short scan from my other comment, these edits to shared helpers are not needed, and the PR then does what its title says with no change to existing checks.
The three workflow edits are correct. For codeql.yml's push and schedule and for pr_title_check.yml's pull_request events the fallback to github.sha behaves as before, because github.head_ref is also empty on push and schedule. The 330 line checker is far larger than the bug needs, and it carries drive-by refactors of shared helpers. A grep-level rule would guard the same regression.
thanks @adityavaish, the PR goes into right direction, please check some nits!
I appended -${{ github.event.pull_request.head.sha }} to the CodeQL group and python3 dev/ci/check-ci-config.py still passed. pr_context varies github.sha but leaves the PR head SHA unset, so the evaluator substitutes an empty string on both pushes. In Actions the suffix changes and the previous run keeps running. If we keep this simulation, can we give successive pushes distinct head SHAs and check that this mutation fails?
The new keys separate same-named branches across forks and keep successive runs on one PR together. The CI configuration checks passed locally. I found one case the new regression check misses.
_Automated review by Codex._
Thanks for catching that—per @comphead's feedback, 5c7929e3a replaced the context simulation with a direct github.head_ref concurrency-group scan, so pr_context has been removed.
<sub>Auto-replied by the GitHub Copilot app</sub>
Reverted all shared-helper edits in 5c7929e3a (ci_triggers, workflow_name, and evaluate_condition are now unchanged from main).
<sub>Auto-replied by the GitHub Copilot app</sub>
Good catch—kept the miri.yml change for consistency and updated the PR description to note that miri.yml only triggers on schedule/workflow_dispatch and is a consistency edit rather than a runtime fix.
<sub>Auto-replied by the GitHub Copilot app</sub>
Removed in 5c7929e3a so this PR stays focused strictly on preventing github.head_ref in concurrency groups.
<sub>Auto-replied by the GitHub Copilot app</sub>
Simplified in 5c7929e3a—replaced the parser and context simulation with a concise check_concurrency_groups() scan (~35 lines) that flags any workflow- or job-level concurrency: block referencing github.head_ref (handling inline scalar/flow and multiline group: values while ignoring comments). Confirmed it catches the three pre-fix files and passes on the updated workflows.
<sub>Auto-replied by the GitHub Copilot app</sub>
Thanks @comphead and @sunchao for the review! Addressed all comments in 5c7929e3a (simplified \check_concurrency_groups()\ to a concise \github.head_ref\ scan, reverted unrelated helper edits, removed the \ci_label.yml\ check, and clarified \miri.yml\ in the PR description).
@comphead could you please approve the workflow runs on this updated commit (and queue for merge once CI is green)?
Approved these changes.
comphead
adityavaish
<!-- copilot-assessment:v1 -->
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
5c7929e3a447b9db68d3866bf96c4e89cf32a94c| Dimension | Assessment | Rationale |
|---|---|---|
| Change confidence | 9.5/10 | ↑ Updates
codeql.yml,pr_title_check.yml, and (for consistency)miri.yml, simplifiescheck_concurrency_groups()to a focusedgithub.head_refscan with zero edits to shared helpers, and passes all 19check-ci-config.pychecks,test-docs-permissions.py, andactionlint --shellcheck=off.<br>↓ Live GitHub Actions runs on Linux andcheck_local_ci_config()under native Linux bash are pending CI approval. || Diagnosis confidence | 9.5/10 | ↑ Workflow inspection confirmed
codeql.ymlandpr_title_check.ymlstill keyed PRconcurrency.groupongithub.head_ref(andmiri.ymlcarried the same template on non-PR triggers), whileci.ymlwas already updated in #7311. || Evidence fit | 9.5/10 | ↑ Directly resolves the remaining PR workflows in #7315 and guards against reintroducing
github.head_refindev/ci/check-ci-config.py. |<!-- /copilot-assessment -->
Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example
Closes #123indicates that this PR will close issue #123.-->
Closes #7315.
Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
codeql.ymlandpr_title_check.ymlstill keyedconcurrency.groupongithub.head_ref || github.sha. Becausegithub.head_refis only the branch name without the fork repository or PR number, two open pull requests from different forks sharing a branch name (such asmainorpatch-1) collide in the same concurrency group and cancel each other's runs. (ci.ymlwas already switched togithub.event.pull_request.numberin #7311;miri.ymlonly triggers onschedule/workflow_dispatchso its matching edit is for consistency rather than a runtime fix.)What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
concurrency.groupin.github/workflows/codeql.ymland.github/workflows/pr_title_check.ymlfromgithub.head_ref || github.shatogithub.event.pull_request.number || github.sha(and updated.github/workflows/miri.ymlto match for consistency).check_concurrency_groups()scan indev/ci/check-ci-config.pythat checks.github/workflows/.ymland fails if any workflow- or job-levelconcurrency:block referencesgithub.head_ref.How are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
check_concurrency_groups()fails on the pre-fixcodeql.yml,miri.yml, andpr_title_check.ymlfrommain(3 failures) and passes on the updated files.check_concurrency_groups()(inline scalar/flowconcurrency:, multilinegroup: >-, job-levelconcurrency:, ignoring comments andrun:blocks).dev/ci/check-ci-config.pypass (bash -n dev/local-ci.shpassed separately;check_local_ci_config()has a pre-existing Windows backslash quirk).python dev/ci/test-docs-permissions.py— passed.actionlint --shellcheck=off(v1.7.12) across all workflows — passed (exit code 0).