|
| 1 | +name: P-022 merge gate |
| 2 | + |
| 3 | +# The merge order for the #263 preregistration, as a check rather than an |
| 4 | +# agreement. `mergegate.py` is run against the commit a merge would PRODUCE — |
| 5 | +# for a pull_request event that is `github.sha`, the merge ref, not the branch |
| 6 | +# head — because a PR number proves someone pressed a button and says nothing |
| 7 | +# about what the merged tree contains. |
| 8 | +# |
| 9 | +# Two jobs, and the gate needs the controls: a gate whose own controls are |
| 10 | +# failing must not be the thing that says a merge is safe. A failed controls job |
| 11 | +# leaves the gate job unreported, which a required check reads as unsatisfied. |
| 12 | +# |
| 13 | +# This workflow is one half of the wiring. The other half is a ruleset requiring |
| 14 | +# these two checks; without it the job reports and nothing is prevented. The |
| 15 | +# names below are the contexts that ruleset must name: |
| 16 | +# |
| 17 | +# P-022 merge gate controls |
| 18 | +# P-022 merge gate |
| 19 | +# |
| 20 | +# Least privilege as elsewhere in this repository: read-only, and every |
| 21 | +# third-party `uses:` pinned to a commit SHA with its version in a comment. |
| 22 | + |
| 23 | +permissions: |
| 24 | + contents: read |
| 25 | + |
| 26 | +on: |
| 27 | + pull_request: |
| 28 | + workflow_dispatch: |
| 29 | + |
| 30 | +jobs: |
| 31 | + controls: |
| 32 | + name: P-022 merge gate controls |
| 33 | + runs-on: ubuntu-latest |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 |
| 36 | + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 |
| 37 | + with: |
| 38 | + python-version: "3.11" |
| 39 | + - name: the gate's own controls (fixtures ship the real tools and mutate them) |
| 40 | + run: python tests/test_step7_mergegate.py |
| 41 | + - name: the wiring's controls (applicability and co-change) |
| 42 | + run: python tests/test_step7_mergegate_ci.py |
| 43 | + |
| 44 | + gate: |
| 45 | + name: P-022 merge gate |
| 46 | + needs: controls |
| 47 | + runs-on: ubuntu-latest |
| 48 | + steps: |
| 49 | + # Full history: the co-change rule compares the gate's own files against |
| 50 | + # the base commit, which a shallow clone would not carry. |
| 51 | + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 |
| 52 | + with: |
| 53 | + fetch-depth: 0 |
| 54 | + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 |
| 55 | + with: |
| 56 | + python-version: "3.11" |
| 57 | + - name: the gate, against the commit this merge would produce |
| 58 | + env: |
| 59 | + # Read through the environment rather than interpolated into the |
| 60 | + # script body, so nothing from the event can be read as shell. |
| 61 | + MERGE_COMMIT: ${{ github.sha }} |
| 62 | + BASE_COMMIT: ${{ github.event.pull_request.base.sha }} |
| 63 | + run: | |
| 64 | + set -euo pipefail |
| 65 | + if [ -n "${BASE_COMMIT}" ]; then |
| 66 | + python scripts/step7/mergegate_ci.py --repo . \ |
| 67 | + --commit "${MERGE_COMMIT}" --base "${BASE_COMMIT}" |
| 68 | + else |
| 69 | + python scripts/step7/mergegate_ci.py --repo . --commit "${MERGE_COMMIT}" |
| 70 | + fi |
0 commit comments