Skip to content

Commit 72ff36e

Browse files
authored
fix(ci): prevent workflow lint stdin deadlock (#131982)
1 parent 8206e75 commit 72ff36e

6 files changed

Lines changed: 52 additions & 40 deletions

File tree

‎.github/workflows/workflow-sanity.yml‎

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -152,29 +152,25 @@ jobs:
152152
tar -xJf "${archive}" "shellcheck-v${SHELLCHECK_VERSION}/shellcheck"
153153
sudo install -m 0755 "shellcheck-v${SHELLCHECK_VERSION}/shellcheck" /usr/local/bin/shellcheck
154154
155+
- name: Setup Go
156+
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
157+
with:
158+
go-version: "1.25.0"
159+
cache: false
160+
155161
- name: Install actionlint
156162
shell: bash
157163
run: |
158164
set -euo pipefail
159-
ACTIONLINT_VERSION="1.7.12"
160-
archive="actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz"
161-
base_url="https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}"
162-
# GitHub release downloads occasionally return transient 5xx responses.
163-
# Retry all curl errors here so workflow-sanity does not fail closed on
164-
# a one-off release edge outage.
165-
curl_args=(
166-
--connect-timeout 10
167-
--max-time 120
168-
--retry 5
169-
--retry-delay 2
170-
--retry-all-errors
171-
-sSfL
172-
)
173-
curl "${curl_args[@]}" -o "${archive}" "${base_url}/${archive}"
174-
curl "${curl_args[@]}" -o checksums.txt "${base_url}/actionlint_${ACTIONLINT_VERSION}_checksums.txt"
175-
grep " ${archive}\$" checksums.txt | sha256sum -c -
176-
tar -xzf "${archive}" actionlint
177-
sudo install -m 0755 actionlint /usr/local/bin/actionlint
165+
# v1.7.12 writes ShellCheck stdin before starting it and deadlocks on large run blocks.
166+
# Pin the upstream fix until a release includes rhysd/actionlint#651.
167+
ACTIONLINT_REVISION="011a6d15e749bb3f2d771eed9c7aa0e7e3e10ee7"
168+
export GOBIN="$RUNNER_TEMP/actionlint-bin"
169+
go install "github.com/rhysd/actionlint/cmd/actionlint@${ACTIONLINT_REVISION}"
170+
version="$("$GOBIN/actionlint" -version)"
171+
printf '%s\n' "$version"
172+
grep -Fxq "v1.7.13-0.20260419144658-${ACTIONLINT_REVISION:0:12}" <<< "$version"
173+
echo "$GOBIN" >> "$GITHUB_PATH"
178174
179175
- name: Lint workflows
180176
run: actionlint

‎.pre-commit-config.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ repos:
3131

3232
# GitHub Actions linting
3333
- repo: https://github.com/rhysd/actionlint
34-
rev: v1.7.12
34+
rev: 011a6d15e749bb3f2d771eed9c7aa0e7e3e10ee7 # ShellCheck stdin deadlock fix (#651)
3535
hooks:
3636
- id: actionlint
3737

‎scripts/check-workflows.mts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { mkdtempSync, readdirSync, rmSync } from "node:fs";
77
import { tmpdir } from "node:os";
88
import { join } from "node:path";
99

10-
const ACTIONLINT_VERSION = "1.7.12";
10+
const ACTIONLINT_REVISION = "011a6d15e749bb3f2d771eed9c7aa0e7e3e10ee7";
1111
const PRE_COMMIT_VERSION = "4.6.2";
1212
const WORKFLOW_DIR = ".github/workflows";
1313

@@ -118,7 +118,7 @@ const workflows = workflowFiles();
118118
if (commandExists("actionlint")) {
119119
run("actionlint", workflows);
120120
} else if (commandExists("go", ["version"])) {
121-
run("go", ["run", `github.com/rhysd/actionlint/cmd/actionlint@v${ACTIONLINT_VERSION}`]);
121+
run("go", ["run", `github.com/rhysd/actionlint/cmd/actionlint@${ACTIONLINT_REVISION}`]);
122122
} else if (
123123
commandExists("pre-commit") ||
124124
commandExists("python3", ["-m", "pre_commit", "--version"]) ||
@@ -127,7 +127,7 @@ if (commandExists("actionlint")) {
127127
runPreCommitHook("actionlint", workflows);
128128
} else {
129129
console.error(
130-
`[check-workflows] missing workflow linter: install actionlint, Go ${ACTIONLINT_VERSION} fallback support, or pre-commit.`,
130+
`[check-workflows] missing workflow linter: install actionlint, Go for actionlint@${ACTIONLINT_REVISION}, or pre-commit.`,
131131
);
132132
process.exit(1);
133133
}

‎test/scripts/check-workflows.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ describe("check-workflows", () => {
2525
expect(result.status).toBe(1);
2626
expect(result.stderr).toContain("missing workflow linter");
2727
expect(result.stderr).toContain("install actionlint, Go");
28+
expect(result.stderr).toContain("011a6d15e749bb3f2d771eed9c7aa0e7e3e10ee7");
2829
});
2930

3031
it("uses the pinned go fallback and audits all workflows with zizmor", () => {
@@ -71,7 +72,7 @@ describe("check-workflows", () => {
7172

7273
expect(result.status).toBe(0);
7374
expect(readFileSync(markerPath, "utf8")).toContain(
74-
"github.com/rhysd/actionlint/cmd/actionlint@v1.7.12",
75+
"github.com/rhysd/actionlint/cmd/actionlint@011a6d15e749bb3f2d771eed9c7aa0e7e3e10ee7",
7576
);
7677
const preCommitArgs = readFileSync(preCommitMarkerPath, "utf8");
7778
expect(preCommitArgs).toContain("run --config .pre-commit-config.yaml zizmor --files");

‎test/scripts/ci-workflow-guards.test.ts‎

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6316,29 +6316,46 @@ server.listen(0, "127.0.0.1", () => {
63166316
expect(run).not.toContain("git fetch");
63176317
});
63186318

6319-
it("bounds the workflow sanity tool downloads", () => {
6319+
it("bounds the workflow sanity ShellCheck download", () => {
63206320
const workflow = readWorkflowSanityWorkflow();
63216321
const shellcheckStep = expectDefined(
63226322
workflow.jobs.actionlint.steps.find(
63236323
(step: WorkflowStep) => step.name === "Install ShellCheck",
63246324
),
63256325
"ShellCheck install step",
63266326
);
6327-
const actionlintStep = expectDefined(
6328-
workflow.jobs.actionlint.steps.find(
6329-
(step: WorkflowStep) => step.name === "Install actionlint",
6330-
),
6331-
"actionlint install step",
6332-
);
6333-
63346327
expect(shellcheckStep.run).toContain("curl --connect-timeout 10 --max-time 120");
63356328
expect(shellcheckStep.run).toContain("--retry 5 --retry-delay 2 --retry-all-errors");
6336-
expect(actionlintStep.run).toContain("--connect-timeout 10");
6337-
expect(actionlintStep.run).toContain("--max-time 120");
6338-
expect(actionlintStep.run).toContain("--retry 5");
6339-
expect(actionlintStep.run).toContain("--retry-delay 2");
6340-
expect(actionlintStep.run).toContain("--retry-all-errors");
6341-
expect(actionlintStep.run.match(/curl "\$\{curl_args\[@\]\}"/gu)).toHaveLength(2);
6329+
});
6330+
6331+
it("pins workflow and pre-commit actionlint to the large-stdin deadlock fix", () => {
6332+
const revision = "011a6d15e749bb3f2d771eed9c7aa0e7e3e10ee7";
6333+
const steps: WorkflowStep[] = readWorkflowSanityWorkflow().jobs.actionlint.steps;
6334+
const setupGo = expectDefined(
6335+
steps.find((step) => step.uses === SETUP_GO_V6),
6336+
"Go setup",
6337+
);
6338+
const install = expectDefined(
6339+
steps.find((step) => step.name === "Install actionlint"),
6340+
"actionlint install",
6341+
);
6342+
6343+
expect(setupGo.with).toEqual({ "go-version": "1.25.0", cache: false });
6344+
expect(steps.indexOf(setupGo)).toBeLessThan(steps.indexOf(install));
6345+
expect(install.run).toContain(`ACTIONLINT_REVISION="${revision}"`);
6346+
expect(install.run).toContain('export GOBIN="$RUNNER_TEMP/actionlint-bin"');
6347+
expect(install.run).toContain(
6348+
'go install "github.com/rhysd/actionlint/cmd/actionlint@${ACTIONLINT_REVISION}"',
6349+
);
6350+
expect(install.run).toContain('"$GOBIN/actionlint" -version');
6351+
expect(install.run).toContain("v1.7.13-0.20260419144658-${ACTIONLINT_REVISION:0:12}");
6352+
expect(install.run).toContain('echo "$GOBIN" >> "$GITHUB_PATH"');
6353+
const preCommit = parse(readFileSync(".pre-commit-config.yaml", "utf8"));
6354+
expect(
6355+
preCommit.repos.find(
6356+
(repo: { repo: string }) => repo.repo === "https://github.com/rhysd/actionlint",
6357+
).rev,
6358+
).toBe(revision);
63426359
});
63436360

63446361
it("runs committed generated baseline drift checks in workflow sanity", () => {

‎test/scripts/package-acceptance-workflow.test.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7325,8 +7325,6 @@ printf '%s\\n' "$DEEPSEEK_API_KEY" "$DEEPINFRA_API_KEY"`,
73257325
expect(publishOrchestration.env?.FULL_RELEASE_VALIDATION_RUN_ATTEMPT).toBe(
73267326
"${{ needs.resolve_release_target.outputs.full_release_validation_run_attempt }}",
73277327
);
7328-
// actionlint passes embedded scripts to ShellCheck through a 64 KiB pipe.
7329-
expect(Buffer.byteLength(publishOrchestration.run ?? "", "utf8")).toBeLessThan(64 * 1024);
73307328
expect(publishOrchestration.run).toContain('"${target_sha}" != "${TARGET_SHA}"');
73317329
expect(npmFullRun.env?.FULL_RELEASE_VALIDATION_RUN_ATTEMPT).toBe(
73327330
"${{ inputs.full_release_validation_run_attempt }}",

0 commit comments

Comments
 (0)