|
| 1 | +name: CodeQL #1537 revisit watch |
| 2 | + |
| 3 | +# Upstream-dependency watcher (#5780). The GitHub merge queue was reverted |
| 4 | +# because CodeQL does not report a status context on `merge_group` |
| 5 | +# (github/codeql-action#1537, open since 2023). A merge queue and a blocking |
| 6 | +# required `CodeQL` check are therefore mutually exclusive on GitHub. If/when |
| 7 | +# #1537 is resolved upstream, the queue becomes re-adoptable — this workflow is |
| 8 | +# the reminder so that window is not missed. |
| 9 | +# |
| 10 | +# Behaviour: monthly, check the upstream issue state. While #1537 is OPEN, this |
| 11 | +# is a silent green no-op (no comments, no churn — the failure mode of the |
| 12 | +# follow-through sweeper for a maybe-years wait). When #1537 CLOSES, post ONE |
| 13 | +# idempotent comment on the standing tracking issue (label `merge-queue-revisit`) |
| 14 | +# and flag it `needs-attention`, so the operator revisits per the ADR-032 |
| 15 | +# re-adoption recipe. A `not_planned` close is surfaced too but flagged as |
| 16 | +# "verify this is a real fix, not a wontfix". |
| 17 | +# |
| 18 | +# WHY GH-Actions cron (ADR-033 repo-scoped): default GITHUB_TOKEN + `gh api`/ |
| 19 | +# `gh issue` ONLY — no app context, no Doppler/app secrets, no token mint. The |
| 20 | +# upstream issue state is public read; our tracking issue is same-repo write. |
| 21 | +# Mirrors the (now-removed) merge-queue-stall-check.yml scope determination. |
| 22 | +# |
| 23 | +# To test manually: gh workflow run codeql-1537-revisit-watch.yml |
| 24 | + |
| 25 | +on: |
| 26 | + schedule: |
| 27 | + - cron: '0 12 1 * *' # 12:00 UTC on the 1st of each month |
| 28 | + workflow_dispatch: {} |
| 29 | + |
| 30 | +permissions: |
| 31 | + contents: read |
| 32 | + issues: write |
| 33 | + |
| 34 | +concurrency: |
| 35 | + group: codeql-1537-revisit-watch |
| 36 | + cancel-in-progress: false |
| 37 | + |
| 38 | +jobs: |
| 39 | + revisit-watch: |
| 40 | + runs-on: ubuntu-latest |
| 41 | + timeout-minutes: 10 |
| 42 | + env: |
| 43 | + GH_TOKEN: ${{ github.token }} |
| 44 | + GH_REPO: ${{ github.repository }} |
| 45 | + UPSTREAM: github/codeql-action |
| 46 | + UPSTREAM_ISSUE: '1537' |
| 47 | + TRACK_LABEL: merge-queue-revisit |
| 48 | + # Sentinel that marks "we already pinged for this closure" — keeps the |
| 49 | + # comment idempotent across monthly runs after #1537 closes. |
| 50 | + SENTINEL: '<!-- codeql-1537-closed-ping -->' |
| 51 | + steps: |
| 52 | + - name: Ping tracking issue if upstream #1537 has closed |
| 53 | + run: | |
| 54 | + set -euo pipefail |
| 55 | +
|
| 56 | + # Public read of the upstream issue state. A transient API failure must |
| 57 | + # NOT false-fire; treat any non-clean read as "unknown → no-op". |
| 58 | + state="$(gh api "repos/${UPSTREAM}/issues/${UPSTREAM_ISSUE}" \ |
| 59 | + --jq '.state' 2>/dev/null || true)" |
| 60 | + reason="$(gh api "repos/${UPSTREAM}/issues/${UPSTREAM_ISSUE}" \ |
| 61 | + --jq '.state_reason // "unspecified"' 2>/dev/null || true)" |
| 62 | +
|
| 63 | + if [[ -z "$state" ]]; then |
| 64 | + echo "::warning::Could not read ${UPSTREAM}#${UPSTREAM_ISSUE} state (transient?) — no-op this run." |
| 65 | + exit 0 |
| 66 | + fi |
| 67 | + if [[ "$state" != "closed" ]]; then |
| 68 | + echo "${UPSTREAM}#${UPSTREAM_ISSUE} is still ${state} — merge queue remains blocked; no action. Silent green no-op." |
| 69 | + exit 0 |
| 70 | + fi |
| 71 | +
|
| 72 | + echo "::notice::${UPSTREAM}#${UPSTREAM_ISSUE} is CLOSED (reason=${reason}). Checking tracking issue." |
| 73 | +
|
| 74 | + # Locate the standing tracking issue by label (number is not hardcoded |
| 75 | + # so this survives issue re-creation). |
| 76 | + track_num="$(gh issue list --repo "$GH_REPO" --state open --limit 20 \ |
| 77 | + --label "$TRACK_LABEL" --json number --jq '.[0].number // empty')" |
| 78 | + if [[ -z "$track_num" ]]; then |
| 79 | + echo "::warning::No open issue labelled '${TRACK_LABEL}' found — cannot ping. Create the tracking issue (see ADR-032 re-adoption recipe)." |
| 80 | + exit 0 |
| 81 | + fi |
| 82 | +
|
| 83 | + # Idempotency: only comment once per closure. |
| 84 | + if gh issue view "$track_num" --repo "$GH_REPO" --json comments \ |
| 85 | + --jq '.comments[].body' 2>/dev/null | grep -qF "$SENTINEL"; then |
| 86 | + echo "Tracking issue #${track_num} already pinged for this closure; nothing to do." |
| 87 | + exit 0 |
| 88 | + fi |
| 89 | +
|
| 90 | + reason_note="" |
| 91 | + if [[ "$reason" == "not_planned" ]]; then |
| 92 | + reason_note=" **Note: closed as \`not_planned\` — this may be a wontfix/supersede, NOT a fix. Verify a \`CodeQL\` status actually posts on a \`merge_group\` ref before re-adopting.**" |
| 93 | + fi |
| 94 | +
|
| 95 | + # shellcheck disable=SC2016 # single-quoted printf FORMAT: backticks are literal markdown, %s are positional args — no shell expansion intended |
| 96 | + body="$(printf '%s\n%s upstream issue %s has CLOSED (reason: `%s`).%s\n\nThe GitHub merge queue was reverted (#5780) solely because CodeQL did not report a status on `merge_group` (that issue). If it is genuinely fixed, the queue is now re-adoptable.\n\n**Verify + re-adopt per the ADR-032 recipe** (`knowledge-base/engineering/architecture/decisions/ADR-032-github-branch-protection-as-iac.md`, 2026-07-01 amendment):\n1. Confirm a `CodeQL` status context now posts on a real `merge_group` ref (open a canary PR through a temporarily-enabled queue, or check GitHub docs/changelog).\n2. Only then re-add the `merge_queue` rule to `infra/github/ruleset-ci-required.tf` and flip the `T-mq-1` guard back to a param-parity test.\n\nUpstream: https://github.com/%s/issues/%s\n\n_Filed automatically by .github/workflows/codeql-1537-revisit-watch.yml._' \ |
| 97 | + "$SENTINEL" "$UPSTREAM" "$UPSTREAM_ISSUE" "$reason" "$reason_note" "$UPSTREAM" "$UPSTREAM_ISSUE")" |
| 98 | +
|
| 99 | + gh label create needs-attention --repo "$GH_REPO" \ |
| 100 | + --color D93F0B --description "Requires operator action" 2>/dev/null || true |
| 101 | + gh issue edit "$track_num" --repo "$GH_REPO" --add-label needs-attention 2>/dev/null || true |
| 102 | + printf '%s' "$body" | gh issue comment "$track_num" --repo "$GH_REPO" --body-file - |
| 103 | + echo "Pinged tracking issue #${track_num} — ${UPSTREAM}#${UPSTREAM_ISSUE} closed." |
0 commit comments