From 16bc55a6cc07292ef00028513d38765b75bac4d3 Mon Sep 17 00:00:00 2001 From: Joseph Mearman Date: Thu, 26 Nov 2026 18:05:59 +0000 Subject: [PATCH 1/4] ci: retry every network fetch in the workflow The install.sh verify jobs and the Homebrew bootstrap fetched with a plain curl, so one dropped stream failed the job and turned main red. A test over the workflow now fails when a curl step lacks --retry. Fixes #920 --- .github/workflows/ci.yml | 6 +++--- src/ciRequiredChecks.repo.test.ts | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15b6b28d4..ca68d1b6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1045,7 +1045,7 @@ jobs: - name: Install Homebrew on Linux run: | if ! command -v brew >/dev/null 2>&1 && ! [ -x /home/linuxbrew/.linuxbrew/bin/brew ]; then - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" > "$GITHUB_PATH" - uses: actions/checkout@v7 @@ -1254,7 +1254,7 @@ jobs: run: | scratch_dir="$RUNNER_TEMP/agent-shim-install-test" mkdir -p "$scratch_dir" - AGENT_SHIM_INSTALL_DIR="$scratch_dir" sh -c "$(curl -fsSL "https://github.com/ExaDev/agent-shim/releases/download/${RELEASE_TAG}/install.sh")" + AGENT_SHIM_INSTALL_DIR="$scratch_dir" sh -c "$(curl -fsSL --retry 6 --retry-delay 5 --retry-all-errors "https://github.com/ExaDev/agent-shim/releases/download/${RELEASE_TAG}/install.sh")" echo "$scratch_dir" >> "$GITHUB_PATH" - name: Check installed version matches the tag, and that claude is not installed by default run: | @@ -1303,7 +1303,7 @@ jobs: run: | scratch_dir="$RUNNER_TEMP/agent-shim-install-test" mkdir -p "$scratch_dir" - AGENT_SHIM_INSTALL_DIR="$scratch_dir" sh -c "$(curl -fsSL "https://github.com/ExaDev/agent-shim/releases/download/${RELEASE_TAG}/install.sh")" + AGENT_SHIM_INSTALL_DIR="$scratch_dir" sh -c "$(curl -fsSL --retry 6 --retry-delay 5 --retry-all-errors "https://github.com/ExaDev/agent-shim/releases/download/${RELEASE_TAG}/install.sh")" echo "$scratch_dir" >> "$GITHUB_PATH" - name: Check installed version matches the tag, and that claude is not installed by default run: | diff --git a/src/ciRequiredChecks.repo.test.ts b/src/ciRequiredChecks.repo.test.ts index f1d0b1d29..5b8e03f43 100644 --- a/src/ciRequiredChecks.repo.test.ts +++ b/src/ciRequiredChecks.repo.test.ts @@ -192,3 +192,17 @@ describe("the release step", () => { expect(releaseSteps.map((step) => step.env?.HUSKY)).toEqual(["0"]); }); }); + +describe("the workflow's network fetches", () => { + /** Every `curl` a step runs, comments left out: a fetch that does not retry fails the job on one dropped stream, which turns main red for a failure that says nothing about the code. */ + const fetches = fs + .readFileSync(path.join(__dirname, "..", ".github", "workflows", "ci.yml"), "utf8") + .split("\n") + .map((text, index) => ({ line: index + 1, text })) + .filter(({ text }) => /\bcurl\b/.test(text) && !text.trim().startsWith("#")); + + it("retry transient errors", () => { + expect(fetches.length).toBeGreaterThan(0); + expect(fetches.filter(({ text }) => !text.includes("--retry")).map(({ line }) => line)).toEqual([]); + }); +}); From 176f12f7e75a1710ed2a5e027fb0ee0e5f580e4e Mon Sep 17 00:00:00 2001 From: Joseph Mearman Date: Thu, 26 Nov 2026 18:09:16 +0000 Subject: [PATCH 2/4] ci: download install scripts to a file before running them A retry after a dropped stream appends the whole body to the part already received when curl writes into a command substitution, so the retried script would run garbled. Each script is written to a file, which a retry truncates, and run from there. The workflow test now requires --retry as its own flag and refuses a retried download fed straight into a shell. Refs #920 --- .github/workflows/ci.yml | 9 ++++++--- src/ciRequiredChecks.repo.test.ts | 17 +++++++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca68d1b6f..788a7a686 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1045,7 +1045,8 @@ jobs: - name: Install Homebrew on Linux run: | if ! command -v brew >/dev/null 2>&1 && ! [ -x /home/linuxbrew/.linuxbrew/bin/brew ]; then - /bin/bash -c "$(curl -fsSL --retry 6 --retry-delay 5 --retry-all-errors https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" > "$GITHUB_PATH" - uses: actions/checkout@v7 @@ -1254,7 +1255,8 @@ jobs: run: | scratch_dir="$RUNNER_TEMP/agent-shim-install-test" mkdir -p "$scratch_dir" - AGENT_SHIM_INSTALL_DIR="$scratch_dir" sh -c "$(curl -fsSL --retry 6 --retry-delay 5 --retry-all-errors "https://github.com/ExaDev/agent-shim/releases/download/${RELEASE_TAG}/install.sh")" + curl -fsSL --retry 6 --retry-delay 5 --retry-all-errors -o "$scratch_dir/install.sh" "https://github.com/ExaDev/agent-shim/releases/download/${RELEASE_TAG}/install.sh" + AGENT_SHIM_INSTALL_DIR="$scratch_dir" sh "$scratch_dir/install.sh" echo "$scratch_dir" >> "$GITHUB_PATH" - name: Check installed version matches the tag, and that claude is not installed by default run: | @@ -1303,7 +1305,8 @@ jobs: run: | scratch_dir="$RUNNER_TEMP/agent-shim-install-test" mkdir -p "$scratch_dir" - AGENT_SHIM_INSTALL_DIR="$scratch_dir" sh -c "$(curl -fsSL --retry 6 --retry-delay 5 --retry-all-errors "https://github.com/ExaDev/agent-shim/releases/download/${RELEASE_TAG}/install.sh")" + curl -fsSL --retry 6 --retry-delay 5 --retry-all-errors -o "$scratch_dir/install.sh" "https://github.com/ExaDev/agent-shim/releases/download/${RELEASE_TAG}/install.sh" + AGENT_SHIM_INSTALL_DIR="$scratch_dir" sh "$scratch_dir/install.sh" echo "$scratch_dir" >> "$GITHUB_PATH" - name: Check installed version matches the tag, and that claude is not installed by default run: | diff --git a/src/ciRequiredChecks.repo.test.ts b/src/ciRequiredChecks.repo.test.ts index 5b8e03f43..7acdb7158 100644 --- a/src/ciRequiredChecks.repo.test.ts +++ b/src/ciRequiredChecks.repo.test.ts @@ -194,15 +194,20 @@ describe("the release step", () => { }); describe("the workflow's network fetches", () => { - /** Every `curl` a step runs, comments left out: a fetch that does not retry fails the job on one dropped stream, which turns main red for a failure that says nothing about the code. */ - const fetches = fs + /** Every command of a step's script that runs `curl`, with its continuation lines joined and comments left out: a fetch that does not retry fails the job on one dropped stream, which turns main red for a failure that says nothing about the code. */ + const commands = fs .readFileSync(path.join(__dirname, "..", ".github", "workflows", "ci.yml"), "utf8") + .replace(/\\\n\s*/g, " ") .split("\n") - .map((text, index) => ({ line: index + 1, text })) - .filter(({ text }) => /\bcurl\b/.test(text) && !text.trim().startsWith("#")); + .map((text, index) => ({ line: index + 1, text: text.trim() })) + .filter(({ text }) => /\bcurl\b/.test(text) && !text.startsWith("#")); it("retry transient errors", () => { - expect(fetches.length).toBeGreaterThan(0); - expect(fetches.filter(({ text }) => !text.includes("--retry")).map(({ line }) => line)).toEqual([]); + expect(commands.length).toBeGreaterThan(0); + expect(commands.filter(({ text }) => !/\s--retry(\s|$)/.test(text)).map(({ line }) => line)).toEqual([]); + }); + + it("never feed a retried download straight into a shell, since a retry after a dropped stream appends the whole body to the part already received", () => { + expect(commands.filter(({ text }) => /\$\(\s*curl\b/.test(text) && /\b(?:ba|z)?sh\b/.test(text)).map(({ line }) => line)).toEqual([]); }); }); From ef5fd31fc21c2883e50794f3ac7e9e1d87cb331f Mon Sep 17 00:00:00 2001 From: Joseph Mearman Date: Thu, 26 Nov 2026 18:12:19 +0000 Subject: [PATCH 3/4] test: catch a download piped or substituted into any shell form, and not a file name ending in .sh The workflow guard now sees curl output fed to a shell through a command substitution, a pipe or a process substitution, with or without a path before the shell, and no longer mistakes install.sh in a URL for one. Refs #920 --- src/ciRequiredChecks.repo.test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ciRequiredChecks.repo.test.ts b/src/ciRequiredChecks.repo.test.ts index 7acdb7158..4ae1b8c20 100644 --- a/src/ciRequiredChecks.repo.test.ts +++ b/src/ciRequiredChecks.repo.test.ts @@ -208,6 +208,9 @@ describe("the workflow's network fetches", () => { }); it("never feed a retried download straight into a shell, since a retry after a dropped stream appends the whole body to the part already received", () => { - expect(commands.filter(({ text }) => /\$\(\s*curl\b/.test(text) && /\b(?:ba|z)?sh\b/.test(text)).map(({ line }) => line)).toEqual([]); + /** A shell named as a command word: not part of a file name such as install.sh. */ + const shell = String.raw`(? fedToShell.test(text)).map(({ line }) => line)).toEqual([]); }); }); From 53dcd157151b1d7a57f8b15789329a05c04c38e6 Mon Sep 17 00:00:00 2001 From: Joseph Mearman Date: Thu, 26 Nov 2026 18:16:58 +0000 Subject: [PATCH 4/4] test: catch a download piped into a wrapped or pathed shell and report real line numbers The pipe form now sees curl piped into sudo bash, env sh or /bin/bash, and a failing workflow test names the physical line a command starts on, not an index into the joined text. Refs #920 --- src/ciRequiredChecks.repo.test.ts | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/ciRequiredChecks.repo.test.ts b/src/ciRequiredChecks.repo.test.ts index 4ae1b8c20..bffe797cb 100644 --- a/src/ciRequiredChecks.repo.test.ts +++ b/src/ciRequiredChecks.repo.test.ts @@ -194,13 +194,20 @@ describe("the release step", () => { }); describe("the workflow's network fetches", () => { - /** Every command of a step's script that runs `curl`, with its continuation lines joined and comments left out: a fetch that does not retry fails the job on one dropped stream, which turns main red for a failure that says nothing about the code. */ - const commands = fs - .readFileSync(path.join(__dirname, "..", ".github", "workflows", "ci.yml"), "utf8") - .replace(/\\\n\s*/g, " ") - .split("\n") - .map((text, index) => ({ line: index + 1, text: text.trim() })) - .filter(({ text }) => /\bcurl\b/.test(text) && !text.startsWith("#")); + /** Every command of a step's script that runs `curl`, comments left out, with its continuation lines joined and the number of the physical line it starts on: a fetch that does not retry fails the job on one dropped stream, which turns main red for a failure that says nothing about the code. */ + const commands: { readonly line: number; readonly text: string }[] = []; + let pending: { readonly line: number; text: string } | undefined; + for (const [index, physical] of fs.readFileSync(path.join(__dirname, "..", ".github", "workflows", "ci.yml"), "utf8").split("\n").entries()) { + const joined = pending === undefined ? { line: index + 1, text: physical.trim() } : { line: pending.line, text: `${pending.text} ${physical.trim()}` }; + if (joined.text.endsWith("\\")) { + pending = { line: joined.line, text: joined.text.slice(0, -1).trimEnd() }; + continue; + } + pending = undefined; + if (/\bcurl\b/.test(joined.text) && !joined.text.startsWith("#")) { + commands.push(joined); + } + } it("retry transient errors", () => { expect(commands.length).toBeGreaterThan(0); @@ -209,8 +216,10 @@ describe("the workflow's network fetches", () => { it("never feed a retried download straight into a shell, since a retry after a dropped stream appends the whole body to the part already received", () => { /** A shell named as a command word: not part of a file name such as install.sh. */ - const shell = String.raw`(? fedToShell.test(text)).map(({ line }) => line)).toEqual([]); }); });