Skip to content

Commit f9332bf

Browse files
committed
test(ci): reuse the runner cached path-filter action
Signed-off-by: Tom Brow <[email protected]>
1 parent 157fcc5 commit f9332bf

1 file changed

Lines changed: 23 additions & 18 deletions

File tree

‎scripts/ci-selection.test.mjs‎

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import assert from "node:assert/strict";
22
import { execFileSync, spawnSync } from "node:child_process";
33
import {
4+
existsSync,
45
mkdtempSync,
56
mkdirSync,
67
readFileSync,
@@ -52,26 +53,30 @@ const filters = workflow
5253
.split("\n")
5354
.map((line) => line.slice(12))
5455
.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) {
7277
const repo = mkdtempSync(join(scratch, "repo-"));
7378
const git = (...args) =>
74-
execFileSync("git", args, { cwd: repo, stdio: "pipe" });
79+
execFileSync("git", args, { cwd: repo, stdio: "pipe", timeout: 10000 });
7580
git("init", "-q");
7681
// Fixture repositories must not inherit developer machine hooks.
7782
mkdirSync(join(repo, "empty-hooks"));

0 commit comments

Comments
 (0)