Skip to content

lint(#10944): ratchet bare process-global statics that tests assert on, and convert the first three #15161

lint(#10944): ratchet bare process-global statics that tests assert on, and convert the first three

lint(#10944): ratchet bare process-global statics that tests assert on, and convert the first three #15161

name: Scheduled Gate Failure Watch
# A completed red gate on main is not an alert by itself: #9830 measured one
# correctly failing scheduled workflow that stayed red for nineteen days. This
# observer turns that result into one durable issue per workflow. Repeated reds
# update the same issue with the current rows and their delta; the next green
# closes it.
# zizmor flags `workflow_run` categorically -- "almost always used
# insecurely", at Medium audit confidence. The two ways it IS used insecurely
# are both closed here, in code, and each is checkable in one line:
#
# 1. It never runs for untrusted input. The `observe` job's `if:` admits only
# `schedule`, or `workflow_dispatch`/`repository_dispatch`/`push` whose
# head_branch is `main` or a `v*` tag. A fork PR's run satisfies none of
# those, so the write-capable token is never reachable from a
# contributor-controlled trigger.
# 2. It never executes the triggering run's code. The checkout pins
# `ref: main` with `persist-credentials: false`, and the only thing run is
# `scripts/gate_failure_watch.py` out of that trusted default-branch
# checkout. Nothing is taken from the triggering run -- no artifact
# download, no `head_sha` checkout.
#
# Permissions are `actions: read`, `contents: read`, `issues: write`: enough to
# read a run's conclusion and file one issue, nothing more.
#
# Dropping the trigger is not an alternative -- observing another workflow's
# completion IS the feature (#9830 measured a correctly-failing scheduled
# workflow staying red for nineteen days with nobody noticing).
#
# Ratchet: if this workflow ever gains an artifact download, a `head_sha`
# checkout, or a looser `if:`, delete the marker and let the gate fail.
on: # zizmor: ignore[dangerous-triggers]
workflow_run:
workflows:
- Auto-Optimize App Patterns
- CI
- Gate Freshness
- GC Moving Witnesses
- gc-native-roots
- GC Parse-Churn Layout Gate
- GC Ptr<Shape> OFF-arm witness
- GC Ratchet
- GC Root Dominance
- TLS Budget
- eh-transport
- llvm-inprocess
types: [completed]
pull_request:
paths:
- .github/workflows/*.yml
- scripts/gate_failure_watch.json
- scripts/gate_failure_watch.py
- scripts/gate_freshness.json
permissions:
contents: read
concurrency:
group: scheduled-gate-failure-watch-${{ github.event_name == 'workflow_run' && github.event.workflow_run.id || github.run_id }}
cancel-in-progress: false
jobs:
validate:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: Self-test the failure observer
run: python3 scripts/gate_failure_watch.py --self-test
- name: Check watched-workflow configuration
run: python3 scripts/gate_failure_watch.py --check-config
observe:
if: >-
github.event_name == 'workflow_run' &&
(
github.event.workflow_run.event == 'schedule' ||
(
(github.event.workflow_run.event == 'workflow_dispatch' ||
github.event.workflow_run.event == 'repository_dispatch') &&
github.event.workflow_run.head_branch == 'main'
) ||
(
github.event.workflow_run.event == 'push' &&
(github.event.workflow_run.head_branch == 'main' ||
startsWith(github.event.workflow_run.head_branch, 'v'))
)
)
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
actions: read
contents: read
issues: write
steps:
# workflow_run carries a write-capable token. Execute only the trusted
# default-branch script, never the triggering workflow's checkout.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: main
persist-credentials: false
- name: Open, update, or close the workflow's failure issue
env:
GH_TOKEN: ${{ github.token }}
GITHUB_REPOSITORY: ${{ github.repository }}
run: python3 scripts/gate_failure_watch.py