Skip to content

Commit 8074e01

Browse files
andygroveclaude
andcommitted
ci: publish label-run verdicts under a name nothing requires
ci.yml also fires on `labeled`, and on that event POLICY skips the PR tier because it already ran at the same commit. The label run's aggregate says nothing about the commit's applicable suites, but GitHub keeps only the most recent check run per name per commit, so publishing it as `Required Checks` would let a `dependencies` label that lands a minute after a push mark the commit green while the real run is still going (the mechanism from #5007). Make the aggregator's `name:` an expression that routes label runs to `Required Checks (label run)`. Skipping the job on `labeled` would not help: a skipped check run still carries the name and still counts as passing. check-ci-config.py now requires that expression shape, rejects a `labeled` branch equal to the required name, and rejects an `.asf.yaml` that requires the label-run name. The commit-run name is what has to match `.asf.yaml`. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01BtAqq4YJsk8uk42c7vHk8B
1 parent e169d39 commit 8074e01

3 files changed

Lines changed: 83 additions & 14 deletions

File tree

‎.github/workflows/README.md‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ Two rules keep those runs from corrupting the PR's status:
103103
- On a `labeled` event, `POLICY` reports false for every job the new label does
104104
not gate. Without that, applying a single label re-ran the entire heavy
105105
pipeline at a commit that had already been tested.
106+
- On a `labeled` event, `required_checks` publishes its verdict as
107+
`Required Checks (label run)`, not `Required Checks`. Because the PR tier is
108+
skipped on that event, the label run's aggregate says nothing about the
109+
commit's applicable suites, and GitHub keeps only the most recent check run
110+
per name per commit. Under the real name, a `dependencies` label landing a
111+
minute after a push would mark the commit green while the commit run was
112+
still going. Skipping the job would not help either, since a skipped check
113+
run still carries the name and still counts as passing.
106114

107115
`run-spark-4.1-tests` gates nothing: `spark_4_1` already runs on every PR.
108116

@@ -258,6 +266,9 @@ that is safe to require. It is flat, so it reports on every event; it runs
258266
upstream job reports `failure` or `cancelled`.
259267

260268
`dev/ci/check-ci-config.py` enforces that every `ci.yml` job except `docs`
261-
appears in `required_checks.needs`. Once `.asf.yaml` does declare a required
262-
context for `main`, it also enforces that the job's `name:` still matches it.
263-
Both sides of that pair are silent when broken and expensive to recover from.
269+
appears in `required_checks.needs`, and that the job's `name:` is the
270+
expression that routes `labeled` runs to a separate name (see "Label events"
271+
above). Once `.asf.yaml` does declare a required context for `main`, it also
272+
enforces that the commit-run name still matches it and that the label-run name
273+
is never the one required. All of that is silent when broken and expensive to
274+
recover from.

‎.github/workflows/ci.yml‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,19 @@ jobs:
344344
#
345345
# `if: always()` is what makes this work: without it the job inherits the
346346
# default `success()` and is itself skipped the moment any dependency fails.
347+
#
348+
# The name is an expression because `ci.yml` also fires on `labeled`, and on
349+
# that event POLICY deliberately skips the PR tier (it already ran at this
350+
# commit). A label run's verdict therefore says nothing about the commit's
351+
# applicable suites, yet GitHub keeps only the most recent check run per name
352+
# per commit, so publishing it as `Required Checks` would let a `dependencies`
353+
# label turn a still-running or red commit run green (issue #5007). Label
354+
# runs publish under a name nothing requires instead. Skipping the job here
355+
# would not help: a skipped check run still carries the name and still counts
356+
# as passing. dev/ci/check-ci-config.py enforces both halves of this.
347357
# ---------------------------------------------------------------------------
348358
required_checks:
349-
name: Required Checks
359+
name: ${{ github.event.action == 'labeled' && 'Required Checks (label run)' || 'Required Checks' }}
350360
if: always()
351361
# Reads only the `needs` context, so it needs no token access at all.
352362
permissions: {}

‎dev/ci/check-ci-config.py‎

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333
# missing from its `needs:` can fail without blocking the merge, and a
3434
# rename on either side of the ci.yml/.asf.yaml pair turns the required
3535
# context into one that never reports, which blocks *every* merge to main
36-
# until INFRA removes it by hand.
36+
# until INFRA removes it by hand. The job's name must also route `labeled`
37+
# runs, which skip the PR tier by design, to a name nothing requires:
38+
# GitHub keeps the most recent check run per name per commit, so a label
39+
# run publishing the required name would overwrite the real verdict.
3740
#
3841
# 4. Artifact-name uniqueness. Artifact names are scoped to the *run*, not
3942
# to the calling workflow, and ci.yml calls the Spark SQL and Iceberg
@@ -55,6 +58,13 @@
5558
# The ci.yml job that aggregates every other job's result.
5659
AGGREGATOR_JOB = "required_checks"
5760

61+
# The aggregator's `name:` has to be this expression shape: label runs publish
62+
# the first literal, every other event the second. See the comment on the job.
63+
AGGREGATOR_NAME_EXPR = re.compile(
64+
r"^\$\{\{\s*github\.event\.action\s*==\s*'labeled'\s*&&\s*"
65+
r"'([^']+)'\s*\|\|\s*'([^']+)'\s*\}\}$"
66+
)
67+
5868
# Jobs that legitimately stay out of the aggregator's `needs:`. `docs` deploys
5969
# to asf-site on push to main; it gates nothing and is never part of a merge
6070
# decision, so folding it in would only turn a failed site deploy into a red
@@ -368,6 +378,19 @@ def asf_required_contexts():
368378
return contexts
369379

370380

381+
def aggregator_check_names(raw_name):
382+
"""Split the aggregator's `name:` into (required name, label-run name).
383+
384+
Returns (None, None) when the value is not the expected expression, which
385+
includes a plain literal: a literal name is published on `labeled` runs too,
386+
and that is the failure mode the expression exists to prevent.
387+
"""
388+
match = AGGREGATOR_NAME_EXPR.match(raw_name)
389+
if not match:
390+
return None, None
391+
return match.group(2), match.group(1)
392+
393+
371394
def check_required_checks():
372395
jobs, needs, display_name = ci_jobs_and_aggregator()
373396
failures = []
@@ -395,17 +418,42 @@ def check_required_checks():
395418
if display_name is None:
396419
failures.append(f"the `{AGGREGATOR_JOB}` job in ci.yml has no `name:`")
397420
else:
398-
# An empty list means main does not require any status check yet,
399-
# which is a valid state: there is nothing to keep in sync. Once a
400-
# context is declared, it has to be one this job actually reports.
401-
contexts = asf_required_contexts()
402-
if contexts and display_name not in contexts:
421+
required_name, label_run_name = aggregator_check_names(display_name)
422+
if required_name is None:
403423
failures.append(
404-
f"`{AGGREGATOR_JOB}` publishes the check name "
405-
f"'{display_name}', but .asf.yaml requires {contexts} "
406-
f"for main. A required context that never reports blocks every "
407-
f"merge, including the one that would fix .asf.yaml"
424+
f"`{AGGREGATOR_JOB}.name` is {display_name!r}; it must be the "
425+
f"expression `${{{{ github.event.action == 'labeled' && "
426+
f"'<label-run name>' || '<required name>' }}}}`. A label run "
427+
f"skips the PR tier by design, and GitHub keeps only the most "
428+
f"recent check run per name, so publishing the required name "
429+
f"from a label run would overwrite the commit run's verdict"
408430
)
431+
elif label_run_name == required_name:
432+
failures.append(
433+
f"`{AGGREGATOR_JOB}.name` publishes '{required_name}' on "
434+
f"label runs too; the `labeled` branch of the expression must "
435+
f"be a different name"
436+
)
437+
else:
438+
# An empty list means main does not require any status check
439+
# yet, which is a valid state: there is nothing to keep in sync.
440+
# Once a context is declared, it has to be the one this job
441+
# reports on commit runs, and never the label-run name.
442+
contexts = asf_required_contexts()
443+
if contexts and required_name not in contexts:
444+
failures.append(
445+
f"`{AGGREGATOR_JOB}` publishes the check name "
446+
f"'{required_name}', but .asf.yaml requires {contexts} "
447+
f"for main. A required context that never reports blocks every "
448+
f"merge, including the one that would fix .asf.yaml"
449+
)
450+
if label_run_name in contexts:
451+
failures.append(
452+
f".asf.yaml requires '{label_run_name}', which is the name "
453+
f"`{AGGREGATOR_JOB}` publishes only on label runs. Those runs "
454+
f"skip the PR tier, so requiring it would let a label mark an "
455+
f"untested commit green"
456+
)
409457

410458
for failure in failures:
411459
print(f"required checks: {failure}")

0 commit comments

Comments
 (0)