
























@@ -0,0 +1,62 @@
1+import { spawnSync } from "node:child_process";
2+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
3+import os from "node:os";
4+import path from "node:path";
5+import { describe, expect, it } from "vitest";
6+7+const scriptPath = path.resolve("scripts/check-workflows.mjs");
8+9+describe("check-workflows", () => {
10+it("prints an actionable diagnostic when actionlint and go are unavailable", () => {
11+const result = spawnSync(process.execPath, [scriptPath], {
12+encoding: "utf8",
13+env: {
14+ ...process.env,
15+PATH: "",
16+},
17+});
18+19+expect(result.status).toBe(1);
20+expect(result.stderr).toContain("missing workflow linter");
21+expect(result.stderr).toContain("install actionlint or Go");
22+});
23+24+it("uses the pinned go fallback when actionlint is unavailable", () => {
25+const tempDir = mkdtempSync(path.join(os.tmpdir(), "check-workflows-"));
26+try {
27+const binDir = path.join(tempDir, "bin");
28+const markerPath = path.join(tempDir, "go-run.txt");
29+mkdirSync(binDir);
30+writeFileSync(
31+path.join(binDir, "go"),
32+[
33+"#!/bin/sh",
34+'if [ "$1" = "version" ]; then exit 0; fi',
35+'if [ "$1" = "run" ]; then printf "%s\\n" "$*" > "$GO_FALLBACK_MARKER"; exit 0; fi',
36+"exit 1",
37+"",
38+].join("\n"),
39+{ mode: 0o755 },
40+);
41+for (const command of ["python3", "node"]) {
42+writeFileSync(path.join(binDir, command), "#!/bin/sh\nexit 0\n", { mode: 0o755 });
43+}
44+45+const result = spawnSync(process.execPath, [scriptPath], {
46+encoding: "utf8",
47+env: {
48+ ...process.env,
49+GO_FALLBACK_MARKER: markerPath,
50+PATH: binDir,
51+},
52+});
53+54+expect(result.status).toBe(0);
55+expect(readFileSync(markerPath, "utf8")).toContain(
56+"github.com/rhysd/actionlint/cmd/actionlint@v1.7.11",
57+);
58+} finally {
59+rmSync(tempDir, { force: true, recursive: true });
60+}
61+});
62+});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。