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
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)" </dev/null
curl -fsSL --retry 6 --retry-delay 5 --retry-all-errors -o "$RUNNER_TEMP/homebrew-install.sh" https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
/bin/bash "$RUNNER_TEMP/homebrew-install.sh" </dev/null
fi
echo "/home/linuxbrew/.linuxbrew/bin" >> "$GITHUB_PATH"
- uses: actions/checkout@v7
Expand Down Expand Up @@ -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: |
Expand Down Expand Up @@ -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: |
Expand Down
31 changes: 31 additions & 0 deletions src/ciRequiredChecks.repo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`(?<![\w.-])(?:ba|z|da)?sh(?![\w.-])`;
/** What may stand between a pipe and the shell it feeds: a wrapper command with its options, or a path. */
const wrapper = String.raw`(?:(?:sudo|env|exec|command|nice|time)\s+(?:-\S+\s+)*)*`;
const fedToShell = new RegExp(String.raw`<\(\s*curl\b|${shell}[^\n]*\$\(\s*curl\b|curl\b[^\n]*\|\s*${wrapper}(?:\S*/)?${shell}`);
expect(commands.filter(({ text }) => fedToShell.test(text)).map(({ line }) => line)).toEqual([]);
});
});
Loading