Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions .github/workflows/reconcile-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -119,13 +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() {
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 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
Expand Down Expand Up @@ -405,9 +405,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"
Expand All @@ -434,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
4 changes: 1 addition & 3 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions apps/docs/scripts/workflow-labels.test.mjs
Original file line number Diff line number Diff line change
@@ -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, []);
});
Loading