From 276ea88d5b86eabf6296c17c4e06bcb33df96181 Mon Sep 17 00:00:00 2001 From: Nick Vigilante Date: Fri, 4 Dec 2026 17:22:32 +0000 Subject: [PATCH 1/2] fix(ci): create workflow labels idempotently instead of searching first The reconciler's validation step looked a label up with `gh label list --search` and created it when the search found nothing. GitHub's label search is not always consistent, so on 2026-12-04 it missed an existing label, `gh label create` failed with "already exists", and the whole scheduled run failed before it compared anything. Create each label with `--force`, which creates or updates it, in the reconciler's two label helpers and the weekly header check, and pin that with a test over every workflow. Assisted-by: AI --- .github/workflows/reconcile-versions.yml | 8 ++---- .github/workflows/security.yml | 4 +-- apps/docs/scripts/workflow-labels.test.mjs | 32 ++++++++++++++++++++++ 3 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 apps/docs/scripts/workflow-labels.test.mjs diff --git a/.github/workflows/reconcile-versions.yml b/.github/workflows/reconcile-versions.yml index c2cf696f..e7cccf00 100644 --- a/.github/workflows/reconcile-versions.yml +++ b/.github/workflows/reconcile-versions.yml @@ -121,9 +121,7 @@ jobs: # label that does not exist, so make sure it does before any step # that files or annotates the issue can need it. ensure_label() { - if ! gh label list -R "$GITHUB_REPOSITORY" --search "$1" --json name --jq '.[].name' | grep -qx "$1"; then - gh label create "$1" -R "$GITHUB_REPOSITORY" --color "$2" --description "$3" - fi + gh label create "$1" -R "$GITHUB_REPOSITORY" --color "$2" --description "$3" --force } ensure_label docs-archive-drift D93F0B "Docs archive drift tracked by the daily reconciler" ensure_label code-server-pin-behind FBCA04 "The code-server docs pin is behind code-server's main" @@ -405,9 +403,7 @@ jobs: note_on() { # The validation step creates the label, but this step also runs # when that step itself is what failed, so do not rely on it here. - if ! gh label list -R "$GITHUB_REPOSITORY" --search "$1" --json name --jq '.[].name' | grep -qx "$1"; then - gh label create "$1" -R "$GITHUB_REPOSITORY" --color "$3" --description "$4" - fi + gh label create "$1" -R "$GITHUB_REPOSITORY" --color "$3" --description "$4" --force local existing note existing=$(gh issue list -R "$GITHUB_REPOSITORY" --label "$1" --state open --json number --limit 1 --jq '.[0].number // empty') note="reconciler failed at $(date -u +%Y-%m-%dT%H:%M:%SZ) in step \"$5\"; see run $RUN_URL" diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index bbd38b7c..db28aba7 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -233,9 +233,7 @@ jobs: run: | set -euo pipefail label="security-header-drift" - if ! gh label list -R "$GITHUB_REPOSITORY" --search "$label" --json name --jq '.[].name' | grep -qx "$label"; then - gh label create "$label" -R "$GITHUB_REPOSITORY" --color B60205 --description "The public docs site no longer serves the router's security headers" - fi + gh label create "$label" -R "$GITHUB_REPOSITORY" --color B60205 --description "The public docs site no longer serves the router's security headers" --force if [[ "$CHECK" == "failure" ]]; then note="The weekly check found $DOCS_SITE_URL serving headers that differ from the router's; the diff is in the job log and summary of $RUN_URL. coder.com's header rules for $DOCS_BASE_PATH replace the router's (see ARCHITECTURE.md, \"Content Security Policy for the public docs host\"), so the fix is usually in coder.com's next.config.js." else diff --git a/apps/docs/scripts/workflow-labels.test.mjs b/apps/docs/scripts/workflow-labels.test.mjs new file mode 100644 index 00000000..97bcd2b8 --- /dev/null +++ b/apps/docs/scripts/workflow-labels.test.mjs @@ -0,0 +1,32 @@ +import assert from "node:assert/strict"; +import { readFileSync, readdirSync } from "node:fs"; +import path from "node:path"; +import test from "node:test"; +import { fileURLToPath } from "node:url"; + +const workflowsDir = path.resolve( + path.dirname(fileURLToPath(import.meta.url)), + "../../../.github/workflows", +); + +const workflowLines = readdirSync(workflowsDir) + .filter((file) => file.endsWith(".yml") || file.endsWith(".yaml")) + .flatMap((file) => + readFileSync(path.join(workflowsDir, file), "utf8") + .split("\n") + .map((line, index) => ({ at: `${file}:${index + 1}`, line })), + ); + +test("every workflow that creates a label creates it with --force", () => { + const without = workflowLines + .filter(({ line }) => line.includes("gh label create") && !line.includes("--force")) + .map(({ at }) => at); + assert.deepEqual(without, []); +}); + +test("no workflow checks for a label with a search before creating it", () => { + const searching = workflowLines + .filter(({ line }) => line.includes("gh label list") && line.includes("--search")) + .map(({ at }) => at); + assert.deepEqual(searching, []); +}); From 30524776713735002874d2119723f558d91283b1 Mon Sep 17 00:00:00 2001 From: Nick Vigilante Date: Fri, 4 Dec 2026 17:32:16 +0000 Subject: [PATCH 2/2] docs(ci): say that the reconciler owns its labels and runs twice a day Update the reconcile workflow's header comment for labels that are created or reset on every run, note beside `ensure_label` that `--force` resets a label edited by hand, and call the reconciler "twice-daily" in the label description to match its 06:17 and 12:17 UTC schedule. Assisted-by: AI --- .github/workflows/reconcile-versions.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/reconcile-versions.yml b/.github/workflows/reconcile-versions.yml index e7cccf00..ee70ad70 100644 --- a/.github/workflows/reconcile-versions.yml +++ b/.github/workflows/reconcile-versions.yml @@ -32,8 +32,9 @@ # died inside an inline JSON.parse of the CLI's empty output, with the failure # note then failing too because the `docs-archive-drift` label did not exist. # A missing credential now fails the run at its first step with the name of -# what is missing and where the runbook documents it, and the label is created -# when it is absent (`gh issue create --label` does not create one). +# what is missing and where the runbook documents it, and the label is created, +# or its colour and description reset, on every run (`gh issue create --label` +# does not create one). # # Runner choice: this job only compares manifest state, no compiling and no # memory need, so `ubuntu-latest` is all it takes. @@ -119,11 +120,12 @@ jobs: [[ "$missing" == 0 ]] || exit 1 # The tracking issue's label. `gh issue create --label` fails on a # label that does not exist, so make sure it does before any step - # that files or annotates the issue can need it. + # that files or annotates the issue can need it. --force resets a label + # edited by hand, because this workflow owns its colour and description. ensure_label() { gh label create "$1" -R "$GITHUB_REPOSITORY" --color "$2" --description "$3" --force } - ensure_label docs-archive-drift D93F0B "Docs archive drift tracked by the daily reconciler" + ensure_label docs-archive-drift D93F0B "Docs archive drift tracked by the twice-daily reconciler" ensure_label code-server-pin-behind FBCA04 "The code-server docs pin is behind code-server's main" - uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4 - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 @@ -430,5 +432,5 @@ jobs: note_on code-server-pin-behind "code-server docs pin is behind" FBCA04 "The code-server docs pin is behind code-server's main" "$code_server_step" fi if [[ -n "$drift_step" || -z "$code_server_step" ]]; then - note_on docs-archive-drift "Docs archive drift" D93F0B "Docs archive drift tracked by the daily reconciler" "${drift_step:-unknown}" + note_on docs-archive-drift "Docs archive drift" D93F0B "Docs archive drift tracked by the twice-daily reconciler" "${drift_step:-unknown}" fi