diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15b6b28d4..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 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 "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 "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 f1d0b1d29..bffe797cb 100644 --- a/src/ciRequiredChecks.repo.test.ts +++ b/src/ciRequiredChecks.repo.test.ts @@ -192,3 +192,34 @@ describe("the release step", () => { expect(releaseSteps.map((step) => step.env?.HUSKY)).toEqual(["0"]); }); }); + +describe("the workflow's network fetches", () => { + /** 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); + 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", () => { + /** 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([]); + }); +});