From 796ef0ce3bf36236ce84659f7338ae49a8eefcc0 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Wed, 11 Nov 2026 04:49:35 -0500 Subject: [PATCH 1/2] fix: probe every availability URL before failing the job Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- .github/workflows/links.yml | 12 +++++++++++- runbooks/availability-failure.md | 6 ++++-- scripts/availability-probes.test.mjs | 24 ++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/.github/workflows/links.yml b/.github/workflows/links.yml index a440b78..3caee5c 100644 --- a/.github/workflows/links.yml +++ b/.github/workflows/links.yml @@ -25,6 +25,10 @@ jobs: - name: Check live Pages availability shell: bash run: | + # Probe every URL before failing so the log shows how many pages broke + # (one path vs every path); runbooks/availability-failure.md relies on it. + probed=0 + failed=0 for url in https://hivecommons.dev/ https://hivecommons.dev/stories/ \ https://hivecommons.dev/docs/ https://hivecommons.dev/code/ \ https://hivecommons.dev/discord/ https://hivecommons.dev/join/ \ @@ -38,12 +42,18 @@ jobs: status=$(curl --silent --show-error --output /dev/null \ --write-out '%{http_code}' --connect-timeout 10 --max-time 30 \ --retry 2 --retry-delay 5 "$url" || true) + probed=$((probed + 1)) if [[ "$status" != 200 ]]; then echo "::error::Live page $url returned HTTP $status (expected 200)" - exit 1 + failed=$((failed + 1)) + continue fi echo "$url returned HTTP $status" done + if (( failed > 0 )); then + echo "::error::$failed of $probed probed pages did not return HTTP 200" + exit 1 + fi links: if: github.event_name != 'schedule' || github.event.schedule == '17 9 * * 1' diff --git a/runbooks/availability-failure.md b/runbooks/availability-failure.md index 41bd3f8..19b0ecb 100644 --- a/runbooks/availability-failure.md +++ b/runbooks/availability-failure.md @@ -15,8 +15,10 @@ probe runs (about 12 hours) should be treated as an outage, not a blip. ## Triage -1. Read the failing step's log: the `::error::` line names the URL and the HTTP status. - A connection or TLS error (no status) points at DNS, certificate or network; a +1. Read the failing step's log: each `::error::` line names a URL and its HTTP status, + and the final `N of M probed pages did not return HTTP 200` line tells one path from + every path directly. + A connection or TLS error (`HTTP 000`) points at DNS, certificate or network; a `404` on one path points at content; a `404` or other error on every path points at Pages or the custom domain. 2. Re-run the probe to rule out a transient fault: diff --git a/scripts/availability-probes.test.mjs b/scripts/availability-probes.test.mjs index d495a55..7dd7a9c 100644 --- a/scripts/availability-probes.test.mjs +++ b/scripts/availability-probes.test.mjs @@ -68,6 +68,15 @@ export function runbookProbedPaths(markdown) { return paths; } +// Text of the availability loop from `do` to its closing `done`, and what +// follows it. Returns null when the job or the loop is absent. +export function probeLoopParts(yaml) { + const job = /^\s{2}availability:\s*$([\s\S]*?)(?=^\s{2}\S|(?![\s\S]))/m.exec(yaml); + if (!job) return null; + const loop = /for\s+url\s+in\s+[\s\S]*?;\s*do\b([\s\S]*?)^\s*done\b([\s\S]*)$/m.exec(job[1]); + return loop ? { body: loop[1], after: loop[2] } : null; +} + export function sitemapLocs(xml) { return [...xml.matchAll(/\s*([^<\s]+)\s*<\/loc>/g)].map((m) => m[1]); } @@ -369,3 +378,18 @@ test("runbooks/availability-failure.md names exactly the paths the links.yml ava "the availability runbook's probe list drifted from .github/workflows/links.yml; update the runbook intro (or, if a probe was dropped, the workflow)", ); }); + +test("fixture: probeLoopParts separates the loop body from the code after done", () => { + const yaml = "jobs:\n availability:\n steps:\n - run: |\n for url in a b; do\n exit 1\n done\n exit 2\n"; + const parts = probeLoopParts(yaml); + assert.match(parts.body, /exit 1/); + assert.match(parts.after, /exit 2/); + assert.equal(probeLoopParts("jobs:\n other:\n"), null); +}); + +test("links.yml availability loop probes every URL: `exit` only after `done`, never inside the loop", () => { + const parts = probeLoopParts(readFileSync(WORKFLOW, "utf8")); + assert.ok(parts, "availability job has no `for url in ...; do ... done` loop"); + assert.doesNotMatch(parts.body, /^[^#\n]*\bexit\b/m, "exit inside the loop stops at the first failing URL; count failures and exit after done"); + assert.match(parts.after, /\bexit\s+1\b/, "the job must still fail after done when any probe failed"); +}); From 868c2e7d87e8cd5208e667fbed48e1f8dd8ae421 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Wed, 11 Nov 2026 04:51:55 -0500 Subject: [PATCH 2/2] test(availability-probes): cover the no-loop branch of probeLoopParts coverage-floor flagged line 77's `: null` as never executed. Assert that an availability job without a `for url in ...; do` loop returns null. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- scripts/availability-probes.test.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/availability-probes.test.mjs b/scripts/availability-probes.test.mjs index 7dd7a9c..c7ed0e9 100644 --- a/scripts/availability-probes.test.mjs +++ b/scripts/availability-probes.test.mjs @@ -385,6 +385,7 @@ test("fixture: probeLoopParts separates the loop body from the code after done", assert.match(parts.body, /exit 1/); assert.match(parts.after, /exit 2/); assert.equal(probeLoopParts("jobs:\n other:\n"), null); + assert.equal(probeLoopParts("jobs:\n availability:\n steps:\n - run: curl -fsS a\n"), null, "job without a for-loop"); }); test("links.yml availability loop probes every URL: `exit` only after `done`, never inside the loop", () => {