@zgeoff/rig 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/package.json +1 -1
- package/src/build-init-scripts.ts +8 -3
- package/src/collect-bench-files.ts +18 -10
package/README.md
CHANGED
|
@@ -41,8 +41,8 @@ so a run that outgrows its memory budget fails alone when `diet` finds a
|
|
|
41
41
|
lane the repo declares.
|
|
42
42
|
- `rig bench [name]` and `rig eval [name]` run the benchmarks and the evaluation suites, or the one
|
|
43
43
|
named `name`.
|
|
44
|
-
- `rig init`
|
|
45
|
-
has files for, and a starter config.
|
|
44
|
+
- `rig init` sets `test` to `rig unit`, adds each missing `test:related`, `test:<lane>`, `bench` and
|
|
45
|
+
`eval` script the repo has files for, keeps its other scripts, and writes a starter config.
|
|
46
46
|
|
|
47
47
|
`rig unit` and the lane commands pass every argument after the command on to `bun test`, so
|
|
48
48
|
`bun run test --seed=1` replays a run's order, and rig drops one `--` among them. The exceptions are
|
package/package.json
CHANGED
|
@@ -23,14 +23,19 @@ export function buildInitScripts(
|
|
|
23
23
|
|
|
24
24
|
const evalScripts = collectEvalFiles(trackedFiles).length > 0 ? { eval: 'rig eval' } : {};
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
...oldScripts,
|
|
28
|
-
test: 'rig unit',
|
|
26
|
+
const rigScripts: PackageScripts = {
|
|
29
27
|
'test:related': 'rig related',
|
|
30
28
|
...Object.fromEntries(laneScripts),
|
|
31
29
|
...benchScripts,
|
|
32
30
|
...evalScripts,
|
|
33
31
|
};
|
|
32
|
+
|
|
33
|
+
// Renovate reruns init on each rig bump, so a script the repo already defines stays as it is.
|
|
34
|
+
const missingScripts = Object.entries(rigScripts).filter(
|
|
35
|
+
([name]) => !Object.hasOwn(oldScripts, name),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
return { ...oldScripts, test: 'rig unit', ...Object.fromEntries(missingScripts) };
|
|
34
39
|
}
|
|
35
40
|
|
|
36
41
|
function isLaneWanted(
|
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
import { posix } from 'node:path';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// A bench file sits in the `bench/` folder of a package, or of the root of a single-package repo.
|
|
3
|
+
// A bench file sits in the `bench/` folder of a package, or beside the module it measures under the
|
|
4
|
+
// package's `src/`. The root of a single-package repo counts as a package.
|
|
6
5
|
export function collectBenchFiles(
|
|
7
6
|
trackedFiles: readonly string[],
|
|
8
7
|
isWorkspaceRepo: boolean,
|
|
9
8
|
): readonly string[] {
|
|
10
9
|
const tracked = new Set(trackedFiles);
|
|
11
10
|
|
|
12
|
-
return trackedFiles.filter(
|
|
13
|
-
|
|
11
|
+
return trackedFiles.filter(
|
|
12
|
+
(file) =>
|
|
13
|
+
file.endsWith('.bench.ts') &&
|
|
14
|
+
listPackageFolders(file).some((folder) =>
|
|
15
|
+
folder === '' ? !isWorkspaceRepo : tracked.has(posix.join(folder, 'package.json')),
|
|
16
|
+
),
|
|
17
|
+
);
|
|
18
|
+
}
|
|
14
19
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
// The folders that hold the file as a bench file if they are a package: the parent of the `bench/`
|
|
21
|
+
// folder the file sits in, and the parent of each `src/` folder above the file.
|
|
22
|
+
function listPackageFolders(file: string): readonly string[] {
|
|
23
|
+
const segments = file.split('/');
|
|
24
|
+
const parents = segments.slice(0, -1);
|
|
18
25
|
|
|
19
|
-
|
|
26
|
+
return parents.flatMap((segment, index) => {
|
|
27
|
+
const isBenchFolder = segment === 'bench' && index === parents.length - 1;
|
|
20
28
|
|
|
21
|
-
return
|
|
29
|
+
return isBenchFolder || segment === 'src' ? [parents.slice(0, index).join('/')] : [];
|
|
22
30
|
});
|
|
23
31
|
}
|