From 41f333187a4923de12bfee5778ff870e1d860563 Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Thu, 19 Nov 2026 06:04:50 -0500 Subject: [PATCH] ci: move ci-status onto the report-ci-status composite The ci-status job's check-contract and aggregate-results steps become one report-ci-status step (still named "Aggregate lane results", id report) pinned at ci-workflows v0.76.3, plus a step that fails the job when the contract or draft output is anything but success. Kept: draft allow (the job had no "Refuse a draft" step), exempt-authors, treat-skipped-as pass, rerun-contract-only-siblings true, step-name, and the job's if, needs, permissions, runner and timeout. The pin inventory test now names report-ci-status in place of the two replaced composites, skips full-line YAML comments that link a ci-workflows file, and asserts the fail-closed step. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Vcupoo79EqmECYFZ4MTv6C --- .../scripts/workflow-pin-metadata.test.cjs | 23 +++++- .github/workflows/pr-require-checks.yml | 76 +++++++++++-------- 2 files changed, 63 insertions(+), 36 deletions(-) diff --git a/.github/scripts/workflow-pin-metadata.test.cjs b/.github/scripts/workflow-pin-metadata.test.cjs index 1cd0075..7f634da 100644 --- a/.github/scripts/workflow-pin-metadata.test.cjs +++ b/.github/scripts/workflow-pin-metadata.test.cjs @@ -32,8 +32,7 @@ const expectedCiWorkflowsCallers = [ ["pr-require-checks.yml", ".github/actions/gitleaks"], ["pr-require-checks.yml", ".github/actions/lychee-offline"], ["pr-require-checks.yml", ".github/actions/markdownlint"], - ["pr-require-checks.yml", ".github/actions/pr-require-checks/aggregate-results"], - ["pr-require-checks.yml", ".github/actions/pr-require-checks/check-contract"], + ["pr-require-checks.yml", ".github/actions/pr-require-checks/report-ci-status"], ["pr-require-checks.yml", ".github/actions/shellcheck"], ["pr-require-checks.yml", ".github/actions/shfmt"], ["pr-require-checks.yml", ".github/actions/typos"], @@ -121,7 +120,8 @@ function ciWorkflowsPin() { const advisory = syncManagedMarker.test(source); const lines = source.split(/\r?\n/u); for (const [index, line] of lines.entries()) { - if (!line.includes(ciWorkflowsReference)) { + // A full-line YAML comment can link a ci-workflows file; it calls nothing. + if (!line.includes(ciWorkflowsReference) || /^\s*#/u.test(line)) { continue; } @@ -271,3 +271,20 @@ test("ci-status is the stable gateway for every Go lane", () => { assert.ok(block.includes(" name: CI Status")); assert.ok(block.includes(" if: always()")); }); + +// report-ci-status never fails on the contract or the draft policy; it reports +// them as outputs. Without this step a failed contract leaves CI Status green. +test("ci-status fails closed on the report-ci-status contract and draft outputs", () => { + const block = jobBlock(workflowSource("pr-require-checks.yml"), "ci-status"); + const report = block.findIndex((line) => line === " id: report"); + assert.notEqual(report, -1, "the report-ci-status step must carry id: report"); + assert.equal(block[report - 1], " - name: Aggregate lane results", "the writer step keeps its name"); + + const gate = block.findIndex( + (line) => + line === + " if: ${{ !cancelled() && (steps.report.outputs.contract != 'success' || steps.report.outputs.draft != 'success') }}", + ); + assert.ok(gate > report, "a later step must fail the job on any contract or draft outcome but success"); + assert.ok(block.slice(gate).some((line) => line.trim() === "exit 1"), "the gate step must exit 1"); +}); diff --git a/.github/workflows/pr-require-checks.yml b/.github/workflows/pr-require-checks.yml index eb09730..86509c4 100644 --- a/.github/workflows/pr-require-checks.yml +++ b/.github/workflows/pr-require-checks.yml @@ -57,9 +57,9 @@ permissions: # # The cost of the branch: a contract-only run no longer queues behind the full # run whose `ci-lanes` status it carries forward, so the two race. -# `yield-to-full-run` on the job below fails it at once while a full run is in -# flight, whose newer ci-status then decides the gate, instead of it queuing or -# waiting. +# The ci-status composite's fixed `yield-to-full-run` fails it at once while a +# full run is in flight, whose newer ci-status then decides the gate, instead +# of it queuing or waiting. # # One hazard the branch does not remove, because no concurrency setting both # removes it and keeps supersession: the full branch is keyed on the pull @@ -484,17 +484,19 @@ jobs: - build-worker-image - review-dependencies runs-on: ubuntu-24.04 - # With `yield-to-full-run` a contract-only run lists in-flight runs once and - # reads the status once, so it finishes in seconds. A full run's ci-status - # runs after its lanes and waits at most `rerun-wait-seconds` (default 90) - # for in-flight contract-only siblings before re-running them. + # With the composite's fixed `yield-to-full-run` a contract-only run lists + # in-flight runs once and reads the status once, so it finishes in + # seconds. A full run's ci-status runs after its lanes and waits at most + # `rerun-wait-seconds` (default 90) for in-flight contract-only siblings + # before re-running them. timeout-minutes: 3 permissions: - contents: read # No checkout here; the composites read the pull request through the API. - # `yield-to-full-run` lists this workflow's runs on the head SHA, and - # `rerun-contract-only-siblings` re-runs the red contract-only ones once - # the full run records `success`. Under an explicit permissions block every - # unlisted scope defaults to none; write covers the read. + contents: read # No checkout here; the composite reads the pull request through the API. + # The composite lists this workflow's runs on the head SHA (its fixed + # `yield-to-full-run`) and re-runs the red contract-only ones once the + # full run records `success` (`rerun-contract-only-siblings`). Under an + # explicit permissions block every unlisted scope defaults to none; write + # covers the read. actions: write # Lists this workflow's runs and re-runs contract-only siblings. # check-contract upserts the advisory linkage comment and moves the linkage # label; ci-status records the `ci-lanes` commit status the carry-forward @@ -502,10 +504,25 @@ jobs: pull-requests: write # Advisory linkage comment and label writes. statuses: write # Records and reads back the `ci-lanes` commit status. steps: - - name: Check the pull-request contract - uses: melodic-software/ci-workflows/.github/actions/pr-require-checks/check-contract@9c5bedfbfdbdfe733b9ce4cd7ca80c1574bd4cb8 # v0.76.3 + # The contract, the draft policy and the aggregation in one step. The + # step keeps the aggregation step's old name: a contract-only run finds + # the writer step of the full run it carries forward by this name, and + # the jobs API, which can list a running job's steps as [] for minutes, + # is matched on `step-name`. The composite fixes + # `yield-to-full-run: 'true'` and `carry-forward-wait-seconds: '0'` + # (https://github.com/melodic-software/ci-workflows/blob/9c5bedfbfdbdfe733b9ce4cd7ca80c1574bd4cb8/.github/actions/pr-require-checks/report-ci-status/action.yml#L128-L129): + # a contract-only run never waits; while a full run on the SHA is in + # flight it fails with "superseded by full run ", and that run's + # newer ci-status decides the gate. Once the full run records `success` + # it re-runs those red contract-only runs, which then read the `success` + # and replace their red check runs. + - name: Aggregate lane results + id: report + uses: melodic-software/ci-workflows/.github/actions/pr-require-checks/report-ci-status@9c5bedfbfdbdfe733b9ce4cd7ca80c1574bd4cb8 # v0.76.3 with: - token: ${{ github.token }} + step-name: Aggregate lane results + # This workflow is not draft-gated (no `ready_for_review` trigger), so a draft passes. + draft: allow # Dependabot and the standards sync open pull requests that close no # issue, so without this they collect the advisory linkage comment # and the `needs-issue-linkage` label on every run. Exempts the @@ -514,13 +531,6 @@ jobs: # equality, never a `*[bot]` pattern, so a new bot is not silently # skipped. exempt-authors: 'dependabot[bot],melodic-standards-sync[bot]' - - name: Aggregate lane results - # `!cancelled()` so a failing check-contract step does not skip the - # aggregation: the job still fails on the contract step's exit code, and - # the `ci-lanes` status is on the SHA for the next contract-only run. - if: ${{ !cancelled() }} - uses: melodic-software/ci-workflows/.github/actions/pr-require-checks/aggregate-results@9c5bedfbfdbdfe733b9ce4cd7ca80c1574bd4cb8 # v0.76.3 - with: results: >- ${{ needs.markdownlint.result }} ${{ needs.shellcheck.result }} @@ -542,16 +552,16 @@ jobs: ${{ needs.fuzz-go.result }} ${{ needs.build-worker-image.result }} ${{ needs.review-dependencies.result }} + # Lanes such as fuzz-go and review-dependencies skip by event, not + # only on a contract-only event, so a skip passes (the composite + # defaults to `fail`). treat-skipped-as: pass - # A contract-only run never waits: while a full run on the SHA is in - # flight it fails with "superseded by full run ", and that run's - # newer ci-status decides the gate. Once the full run records - # `success` it re-runs those red contract-only runs, which then read - # the `success` and replace their red check runs. - yield-to-full-run: 'true' rerun-contract-only-siblings: 'true' - carry-forward-wait-seconds: '0' - # The jobs API can list a running job's steps as [] for minutes; the - # step's own name lets the carry-forward and yield lookups find it. - step-name: Aggregate lane results - token: ${{ github.token }} + # The composite's step concludes on the lanes alone; the contract and + # draft results fail the job here. Anything but `success` fails, so an + # empty or renamed output fails closed. + - name: Fail on the contract or draft policy + if: ${{ !cancelled() && (steps.report.outputs.contract != 'success' || steps.report.outputs.draft != 'success') }} + run: | + echo "::error::ci-status: the pull-request contract or the draft policy failed; see the step above." + exit 1