|
1 | 1 | import assert from "node:assert/strict"; |
2 | 2 | import { execFileSync, spawnSync } from "node:child_process"; |
3 | 3 | import { |
| 4 | + existsSync, |
4 | 5 | mkdtempSync, |
5 | 6 | mkdirSync, |
6 | 7 | readFileSync, |
@@ -52,26 +53,30 @@ const filters = workflow |
52 | 53 | .split("\n") |
53 | 54 | .map((line) => line.slice(12)) |
54 | 55 | .join("\n"); |
55 | | -let actionPath; |
56 | | -async function select(paths) { |
57 | | - if (!actionPath) { |
58 | | - // Exercise the exact bundled matcher CI executes, including negation and |
59 | | - // dotfile semantics, instead of maintaining an approximation of picomatch. |
60 | | - actionPath = join(scratch, "paths-filter.cjs"); |
61 | | - execFileSync("curl", [ |
62 | | - "--fail", |
63 | | - "--silent", |
64 | | - "--show-error", |
65 | | - "--max-time", |
66 | | - "30", |
67 | | - "-o", |
68 | | - actionPath, |
69 | | - `https://raw.githubusercontent.com/dorny/paths-filter/${actionSha}/dist/index.js`, |
70 | | - ]); |
71 | | - } |
| 56 | +// GitHub-hosted runners prepare pinned actions beside RUNNER_TEMP before any |
| 57 | +// steps run. Reuse that bundle, without another download in the selection gate. |
| 58 | +// Locally, point PATHS_FILTER_ACTION at dist/index.js from the pinned action. |
| 59 | +const actionPath = |
| 60 | + process.env.PATHS_FILTER_ACTION || |
| 61 | + (process.env.RUNNER_TEMP && |
| 62 | + join( |
| 63 | + process.env.RUNNER_TEMP, |
| 64 | + "..", |
| 65 | + "_actions", |
| 66 | + "dorny", |
| 67 | + "paths-filter", |
| 68 | + actionSha, |
| 69 | + "dist", |
| 70 | + "index.js", |
| 71 | + )); |
| 72 | +assert.ok( |
| 73 | + actionPath && existsSync(actionPath), |
| 74 | + `Set PATHS_FILTER_ACTION to the local dist/index.js from dorny/paths-filter@${actionSha}`, |
| 75 | +); |
| 76 | +function select(paths) { |
72 | 77 | const repo = mkdtempSync(join(scratch, "repo-")); |
73 | 78 | const git = (...args) => |
74 | | - execFileSync("git", args, { cwd: repo, stdio: "pipe" }); |
| 79 | + execFileSync("git", args, { cwd: repo, stdio: "pipe", timeout: 10000 }); |
75 | 80 | git("init", "-q"); |
76 | 81 | // Fixture repositories must not inherit developer machine hooks. |
77 | 82 | mkdirSync(join(repo, "empty-hooks")); |
|
0 commit comments