|
| 1 | +# SPDX-License-Identifier: MPL-2.0 |
| 2 | +# CI gate — thin caller of the estate's interim gate, which lives in |
| 3 | +# hyperpolymath/proven-cicd-and-workflows as a reusable workflow. Do not copy |
| 4 | +# its jobs in here: a copy freezes at one cicd-suite commit and never receives |
| 5 | +# a fix. |
| 6 | +# |
| 7 | +# It emits the commit status `CI/gate`, which the Branch-Floor ruleset |
| 8 | +# requires. It is a COMMIT STATUS, not a check run, because a job inside a |
| 9 | +# reusable workflow gets the check-run name `<caller job> / <called job>` |
| 10 | +# (see rust-ci-caller.yml: `rust-ci / Cargo test`), which always contains |
| 11 | +# " / " and can never equal `CI/gate`. |
| 12 | +# |
| 13 | +# It triggers on workflow_run, schedule and workflow_dispatch, all of which GitHub runs from the |
| 14 | +# DEFAULT branch: a pull request cannot alter this file, its pin or its list. The consequence: |
| 15 | +# the pull request that adds this caller can never receive `CI/gate` itself, and |
| 16 | +# would be merged past the gate once (owner action) without the gate-pr job at the end. There is no |
| 17 | +# pull_request start here except the gate-pr job at the end (docs/CI-GATE.adoc, "The pull_request start"), |
| 18 | +# whose shape tests/ci-gate.sh asserts. |
| 19 | +# |
| 20 | +# `schedule` and `workflow_dispatch` run a SWEEP: the reusable lists the open pull requests and the |
| 21 | +# default branch head and re-evaluates each distinct head SHA with the same guarded publisher. A stale state |
| 22 | +# then normally lasts until the next sweep. It is still last-writer-wins, a sweep is itself an evaluator, |
| 23 | +# and GitHub may delay or skip scheduled runs (docs/CI-GATE.adoc, "Residual limit"). The cron below runs at minutes |
| 24 | +# 7, 22, 37 and 52 of every hour; keep the minutes off :00 and :30, where scheduled load is highest. |
| 25 | +# The sweep reads open pull requests, so the caller must grant `pull-requests: read`. |
| 26 | +# |
| 27 | +# It also fires when a workflow run STARTS (`in_progress`, which GitHub also sends for a rerun): |
| 28 | +# any active run makes the verdict pending, so a rerun replaces a stale success with pending, |
| 29 | +# approximating a native required check. `completed` then re-evaluates it (last-writer-wins; see docs/CI-GATE.adoc, "Residual limit"). |
| 30 | +# |
| 31 | +# The required-check list is NOT in this repository: it lives in |
| 32 | +# proven-cicd-and-workflows/profiles/ci-gate/<owner>/<repo>.json at the pinned |
| 33 | +# SHA below, selected by github.repository. A repository with no profile there |
| 34 | +# fails the gate closed until one is added to the suite. |
| 35 | +# |
| 36 | +# The job id MUST stay `gate`. The pin is a full SHA, never `@main` or a tag: |
| 37 | +# the account enforces sha_pinning_required. An A3 `estate-gate` replaces this |
| 38 | +# interim gate by changing ONE pin and ONE context (`with: context`) here. |
| 39 | +# |
| 40 | +# ⚠ DE-ONBOARDED from actions.lock, deliberately, like the estate-audit and |
| 41 | +# Rust CI callers: an onboarded cross-repo reusable startup-fails with zero |
| 42 | +# jobs under sha_pinning_required. cicd-suite/scripts/deonboard-workflow.sh |
| 43 | +# reverses a re-onboarding. |
| 44 | +# |
| 45 | +# There is deliberately NO `concurrency:` block here: serialising per SHA would delay the |
| 46 | +# in_progress caller behind a running evaluation that then writes a stale success. The reusable's |
| 47 | +# own job cancels a running evaluation of the same SHA instead, and re-reads the runs just before it |
| 48 | +# writes (scripts/ci-gate-publish.sh; tests/ci-gate.sh asserts the template has no concurrency). |
| 49 | +# |
| 50 | +# API budget: "**" starts the gate for every workflow. If the profile's required checks come from a |
| 51 | +# few workflows, naming them (workflows: ["CI", "Lint"]) cuts the events; keep that list in step with |
| 52 | +# the profile (docs/CI-GATE.adoc, "API budget"). |
| 53 | +# |
| 54 | +# No `secrets:` line: the reusable consumes none. |
| 55 | +name: CI gate |
| 56 | + |
| 57 | +on: |
| 58 | + pull_request: |
| 59 | + workflow_run: |
| 60 | + workflows: ["**", "!CI gate"] |
| 61 | + types: [completed, in_progress] |
| 62 | + schedule: |
| 63 | + - cron: "7,22,37,52 * * * *" |
| 64 | + workflow_dispatch: {} |
| 65 | + |
| 66 | +permissions: |
| 67 | + statuses: write |
| 68 | + actions: read |
| 69 | + contents: read |
| 70 | + pull-requests: read |
| 71 | + |
| 72 | +jobs: |
| 73 | + gate: |
| 74 | + if: github.event_name != 'pull_request' && (github.event_name != 'workflow_run' || github.event.workflow_run.name != 'CI gate') |
| 75 | + uses: hyperpolymath/proven-cicd-and-workflows/.github/workflows/ci-gate.yml@a0760cea695a815a96b3944f3d03ee015da856d0 # cicd-suite ci-gate |
| 76 | + with: |
| 77 | + context: "CI/gate" |
| 78 | + # timeout_minutes: 180 # how long a missing check keeps the gate pending |
| 79 | + |
| 80 | + # The pull_request start. workflow_run, schedule and workflow_dispatch run only from the default |
| 81 | + # branch, so without this job the pull request that adds or changes the gate never gets the status |
| 82 | + # and a ruleset requiring it blocks that very pull request. This job runs from the pull request's own |
| 83 | + # branch and posts the same verdict, waiting (bounded) for the checks named in the profile to report. |
| 84 | + # Same-repository branches only: a fork's or Dependabot's pull_request token cannot write statuses, |
| 85 | + # and those are covered by the workflow_run job. No trust decision uses github.actor. |
| 86 | + # Because a pull request can edit this file, the Gate tamper guard (ci-gate-tamper-guard.yml, run from |
| 87 | + # the default branch) fails a pull request that touches gate files unless the owner has approved it. |
| 88 | + gate-pr: |
| 89 | + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository |
| 90 | + uses: hyperpolymath/proven-cicd-and-workflows/.github/workflows/ci-gate.yml@a0760cea695a815a96b3944f3d03ee015da856d0 # cicd-suite ci-gate |
| 91 | + with: |
| 92 | + context: "CI/gate" |
0 commit comments