Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix: make self-hosted checks resilient

Steven Enamakel8d945ebdc8dd
diff --git a/.github/workflows/ci-lanes.yml b/.github/workflows/ci-lanes.yml
index 1b9bcae79d..0708b38282 100644
--- a/.github/workflows/ci-lanes.yml
+++ b/.github/workflows/ci-lanes.yml
@@ -81,10 +81,17 @@ jobs:
- name: Install jq for release-script tests
if: steps.filter.outputs.scripts == 'true'
run: |
- if command -v jq >/dev/null && python3 -c 'import tomli' 2>/dev/null; then
+ if command -v jq >/dev/null && python3 -c 'import tomllib' 2>/dev/null; then
+ exit 0
+ fi
+ if [ "$(id -u)" -eq 0 ]; then
+ SUDO=""
+ elif command -v sudo >/dev/null 2>&1; then
+ SUDO=sudo
+ else
+ echo "::warning::jq/tomli are unavailable and this runner cannot install packages; continuing with the Node-only script tests."
exit 0
fi
- SUDO=$([ "$(id -u)" -eq 0 ] || echo sudo)
$SUDO apt-get update
$SUDO apt-get install -y --no-install-recommends jq python3-tomli
diff --git a/scripts/__tests__/retry-markdown-links.test.mjs b/scripts/__tests__/retry-markdown-links.test.mjs
index 304e8eef71..4135b362d6 100644
--- a/scripts/__tests__/retry-markdown-links.test.mjs
+++ b/scripts/__tests__/retry-markdown-links.test.mjs
@@ -7,6 +7,8 @@ import {
const unavailable =
"* [503] <https://example.test/docs#anchor> | Service Unavailable\n";
+const internalError =
+ "* [500] <https://example.test/docs#anchor> | Internal Server Error\n";
const missing = "* [404] <https://example.test/missing> | Not Found\n";
function checker(results) {
@@ -47,6 +49,25 @@ test("transient 503 recovers after more than one retry and preserves fragments",
assert.ok(logs.some((line) => /reason=recovered/.test(line)));
});
+test("transient GitHub 500 responses are retried too", async () => {
+ const { calls, check } = checker([
+ { status: 2, report: internalError },
+ { status: 0, report: "" },
+ ]);
+ assert.equal(
+ await retryServiceUnavailable({
+ initialReport: internalError,
+ check,
+ wait: async () => {},
+ }),
+ 0,
+ );
+ assert.deepEqual(calls, [
+ ["https://example.test/docs#anchor"],
+ ["https://example.test/docs#anchor"],
+ ]);
+});
+
test("persistent 503 remains a failure after bounded retries", async () => {
const { calls, check } = checker(
Array.from({ length: 3 }, () => ({ status: 2, report: unavailable })),
diff --git a/scripts/__tests__/self-hosted-lanes.test.mjs b/scripts/__tests__/self-hosted-lanes.test.mjs
index 50a49427bc..976a6f1ed9 100644
--- a/scripts/__tests__/self-hosted-lanes.test.mjs
+++ b/scripts/__tests__/self-hosted-lanes.test.mjs
@@ -49,6 +49,11 @@ test("EX63 installs script dependencies only after changed areas are detected",
const detect = ciLanes.indexOf("- name: Detect changed areas");
const install = ciLanes.indexOf("- name: Install jq for release-script tests");
assert.ok(detect >= 0 && install > detect, "filter outputs must exist before they gate jq installation");
+ const nextStep = ciLanes.indexOf("\n - name:", install + 1);
+ const installBlock = ciLanes.slice(install, nextStep < 0 ? undefined : nextStep);
+ assert.match(installBlock, /import tomllib/, "Python 3.11+ already provides TOML parsing");
+ assert.match(installBlock, /command -v sudo/, "non-root runners may not have sudo");
+ assert.match(installBlock, /cannot install packages/, "the EX63 image may not grant package installation");
});
const plans = () => [
diff --git a/scripts/ci/retry-markdown-links.mjs b/scripts/ci/retry-markdown-links.mjs
index 8251c6c7a7..a40e6c3c5f 100644
--- a/scripts/ci/retry-markdown-links.mjs
+++ b/scripts/ci/retry-markdown-links.mjs
@@ -4,10 +4,15 @@ import { spawnSync } from "node:child_process";
import { setTimeout as delay } from "node:timers/promises";
import { fileURLToPath } from "node:url";
-/** Extract URLs only when every reported link failure is an HTTP 503. */
+const TRANSIENT_HTTP_STATUSES = new Set(["500", "502", "503", "504"]);
+
+/** Extract URLs only when every reported link failure is a transient HTTP 5xx. */
export function serviceUnavailableUrls(report) {
const failures = [...report.matchAll(/^\*\s+\[([^\]]+)\]\s+<([^>]+)>/gm)];
- if (!failures.length || failures.some(([, status]) => status !== "503"))
+ if (
+ !failures.length ||
+ failures.some(([, status]) => !TRANSIENT_HTTP_STATUSES.has(status))
+ )
return null;
return [...new Set(failures.map(([, , url]) => url))];
}