@smoothbricks/nx-plugin 0.4.26 → 0.4.27
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 +994 -117
- package/dist/bin/smoo-nx-bound-failures.d.ts +3 -0
- package/dist/bin/smoo-nx-bound-failures.d.ts.map +1 -0
- package/dist/bin/smoo-nx-bound-failures.js +31 -0
- package/dist/bin/smoo-nx-cargo-hash.js +28 -3
- package/dist/bin/smoo-nx-exec.js +15 -73
- package/dist/bin/smoo-nx-failures.d.ts +3 -0
- package/dist/bin/smoo-nx-failures.d.ts.map +1 -0
- package/dist/bin/smoo-nx-failures.js +3 -0
- package/dist/bin/smoo-nx-nextest-extract.js +3 -2
- package/dist/bin/smoo-nx-test-walks.d.ts +3 -0
- package/dist/bin/smoo-nx-test-walks.d.ts.map +1 -0
- package/dist/bin/smoo-nx-test-walks.js +34 -0
- package/dist/bounded-test-policy.d.ts +7 -1
- package/dist/bounded-test-policy.d.ts.map +1 -1
- package/dist/bounded-test-policy.js +101 -40
- package/dist/build-state-output-policy.d.ts +25 -0
- package/dist/build-state-output-policy.d.ts.map +1 -0
- package/dist/build-state-output-policy.js +64 -0
- package/dist/cargo-closure-input.d.ts +3 -2
- package/dist/cargo-closure-input.d.ts.map +1 -1
- package/dist/cargo-closure-input.js +16 -15
- package/dist/cargo-dev-profile.d.ts +37 -0
- package/dist/cargo-dev-profile.d.ts.map +1 -0
- package/dist/cargo-dev-profile.js +108 -0
- package/dist/cargo-source-hash.d.ts +43 -6
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +309 -73
- package/dist/cargo-toolchain-policy.d.ts +4 -0
- package/dist/cargo-toolchain-policy.d.ts.map +1 -1
- package/dist/cargo-toolchain-policy.js +5 -0
- package/dist/cargo-workspace.d.ts +101 -5
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +291 -10
- package/dist/cross-check-policy.d.ts +21 -3
- package/dist/cross-check-policy.d.ts.map +1 -1
- package/dist/cross-check-policy.js +24 -6
- package/dist/disk-command-policy.d.ts +7 -0
- package/dist/disk-command-policy.d.ts.map +1 -0
- package/dist/disk-command-policy.js +98 -0
- package/dist/ensure-built-receipt.d.ts +25 -0
- package/dist/ensure-built-receipt.d.ts.map +1 -0
- package/dist/ensure-built-receipt.js +261 -0
- package/dist/ensure-built-witness.d.ts +57 -0
- package/dist/ensure-built-witness.d.ts.map +1 -0
- package/dist/ensure-built-witness.js +412 -0
- package/dist/ensure-built.d.ts +207 -12
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +576 -202
- package/dist/eslint-file-set.d.ts +7 -0
- package/dist/eslint-file-set.d.ts.map +1 -0
- package/dist/eslint-file-set.js +12 -0
- package/dist/executors/bounded-exec/cpu-pool.d.ts +63 -0
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -0
- package/dist/executors/bounded-exec/cpu-pool.js +379 -0
- package/dist/executors/bounded-exec/cpu-tokens.d.ts +82 -0
- package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +1 -0
- package/dist/executors/bounded-exec/cpu-tokens.js +114 -0
- package/dist/executors/bounded-exec/disk-lease.d.ts +61 -0
- package/dist/executors/bounded-exec/disk-lease.d.ts.map +1 -0
- package/dist/executors/bounded-exec/disk-lease.js +91 -0
- package/dist/executors/bounded-exec/executor.d.ts +45 -2
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +447 -52
- package/dist/executors/bounded-exec/gateway-lease.d.ts +52 -0
- package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -0
- package/dist/executors/bounded-exec/gateway-lease.js +143 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts +35 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -0
- package/dist/executors/bounded-exec/hang-diagnostics.js +231 -0
- package/dist/executors/bounded-exec/progress.d.ts +35 -0
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -0
- package/dist/executors/bounded-exec/progress.js +79 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +3 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.js +12 -0
- package/dist/executors/bounded-exec/ram-temp-held.d.ts +91 -0
- package/dist/executors/bounded-exec/ram-temp-held.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-temp-held.js +152 -0
- package/dist/executors/bounded-exec/ram-temp.d.ts +223 -0
- package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-temp.js +1528 -0
- package/dist/executors/bounded-exec/schema.d.ts +29 -11
- package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.d.ts +162 -0
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -0
- package/dist/executors/bounded-exec/verdict.js +318 -0
- package/dist/executors/shard-timings/executor.d.ts +14 -0
- package/dist/executors/shard-timings/executor.d.ts.map +1 -0
- package/dist/executors/shard-timings/executor.js +25 -0
- package/dist/executors/shard-timings/schema.d.ts +4 -0
- package/dist/executors/shard-timings/schema.d.ts.map +1 -0
- package/dist/executors/shard-timings/schema.js +1 -0
- package/dist/failure-summary.d.ts +5 -0
- package/dist/failure-summary.d.ts.map +1 -0
- package/dist/failure-summary.js +118 -0
- package/dist/generators/create-package/generator.d.ts.map +1 -1
- package/dist/generators/create-package/generator.js +6 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +370 -138
- package/dist/managed-files/ci-workflow.d.ts +13 -0
- package/dist/managed-files/ci-workflow.d.ts.map +1 -1
- package/dist/managed-files/ci-workflow.js +44 -13
- package/dist/managed-files/files.d.ts +7 -1
- package/dist/managed-files/files.d.ts.map +1 -1
- package/dist/managed-files/files.js +62 -8
- package/dist/managed-files/json-edit.d.ts +21 -0
- package/dist/managed-files/json-edit.d.ts.map +1 -0
- package/dist/managed-files/json-edit.js +295 -0
- package/dist/managed-files/managed-format.d.ts +33 -1
- package/dist/managed-files/managed-format.d.ts.map +1 -1
- package/dist/managed-files/managed-format.js +82 -2
- package/dist/managed-files/pr-preview-cleanup-workflow.d.ts +7 -0
- package/dist/managed-files/pr-preview-cleanup-workflow.d.ts.map +1 -1
- package/dist/managed-files/pr-preview-cleanup-workflow.js +68 -4
- package/dist/managed-files/publish-workflow.d.ts.map +1 -1
- package/dist/managed-files/publish-workflow.js +231 -48
- package/dist/managed-files/tree.d.ts +5 -0
- package/dist/managed-files/tree.d.ts.map +1 -1
- package/dist/managed-files/tree.js +5 -3
- package/dist/manifest-hash.d.ts.map +1 -1
- package/dist/manifest-hash.js +2 -5
- package/dist/nextest-code-bound.d.ts +62 -0
- package/dist/nextest-code-bound.d.ts.map +1 -0
- package/dist/nextest-code-bound.js +154 -0
- package/dist/nextest-extraction.d.ts +24 -8
- package/dist/nextest-extraction.d.ts.map +1 -1
- package/dist/nextest-extraction.js +42 -7
- package/dist/package-target-policy.d.ts.map +1 -1
- package/dist/package-target-policy.js +3 -5
- package/dist/release-config-policy.d.ts.map +1 -1
- package/dist/release-config-policy.js +3 -5
- package/dist/runtime-input.d.ts +14 -0
- package/dist/runtime-input.d.ts.map +1 -0
- package/dist/runtime-input.js +15 -0
- package/dist/rust-tokens.d.ts +11 -0
- package/dist/rust-tokens.d.ts.map +1 -0
- package/dist/rust-tokens.js +81 -0
- package/dist/task-results.d.ts +6 -0
- package/dist/task-results.d.ts.map +1 -0
- package/dist/task-results.js +61 -0
- package/dist/test-program.d.ts +54 -0
- package/dist/test-program.d.ts.map +1 -0
- package/dist/test-program.js +292 -0
- package/dist/test-timings.d.ts +71 -0
- package/dist/test-timings.d.ts.map +1 -0
- package/dist/test-timings.js +393 -0
- package/dist/test-walk-policy.d.ts +103 -0
- package/dist/test-walk-policy.d.ts.map +1 -0
- package/dist/test-walk-policy.js +657 -0
- package/dist/testing.d.ts +177 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +824 -0
- package/dist/type-guards.d.ts +3 -0
- package/dist/type-guards.d.ts.map +1 -0
- package/dist/type-guards.js +4 -0
- package/dist/typecheck-test-policy.d.ts +8 -5
- package/dist/typecheck-test-policy.d.ts.map +1 -1
- package/dist/typecheck-test-policy.js +113 -100
- package/dist/workspace-config-policy.d.ts +8 -0
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +175 -63
- package/dist/workspace-index.d.ts +12 -0
- package/dist/workspace-index.d.ts.map +1 -0
- package/dist/workspace-index.js +17 -0
- package/dist/workspace-manifest.d.ts +37 -0
- package/dist/workspace-manifest.d.ts.map +1 -1
- package/executors.json +5 -0
- package/loader.js +13 -11
- package/managed/raw/envrc +33 -67
- package/managed/raw/git-format-staged.yml +30 -35
- package/managed/raw/patches/nx@23.2.1.patch +3484 -0
- package/managed/raw/tooling/direnv/apple-developer.sh +83 -0
- package/managed/raw/tooling/direnv/developer-links.ts +569 -11
- package/managed/raw/tooling/direnv/devenv.smoo.nix +314 -93
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -11
- package/managed/raw/tooling/direnv/linked-snapshots.ts +845 -0
- package/managed/raw/tooling/direnv/nx-socket-dir.sh +82 -0
- package/managed/raw/tooling/direnv/repo-path +14 -2
- package/managed/raw/tooling/direnv/setup-environment.ts +962 -148
- package/managed/raw/tooling/direnv/toolchain-stamp.ts +45 -3
- package/managed/raw/tooling/direnv/ttsc-env.sh +39 -0
- package/managed/raw/tooling/git-hooks/commit-msg.sh +5 -6
- package/managed/raw/tooling/git-hooks/pre-commit.sh +7 -6
- package/managed/raw/tooling/git-hooks/pre-push.sh +20 -15
- package/managed/templates/github/actions/cache-nix-devenv/action.yml +6 -6
- package/managed/templates/github/actions/cache-node-modules/action.yml +6 -4
- package/managed/templates/github/actions/cache-nx/action.yml +1 -1
- package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +1 -1
- package/managed/templates/github/actions/forgejo-artifact.cjs +99 -0
- package/managed/templates/github/actions/forgejo-download-artifact/action.yml +49 -0
- package/managed/templates/github/actions/forgejo-download-artifact/index.cjs +7 -0
- package/managed/templates/github/actions/forgejo-upload-artifact/action.yml +65 -0
- package/managed/templates/github/actions/forgejo-upload-artifact/index.cjs +7 -0
- package/managed/templates/github/actions/setup-devenv/action.yml +21 -3
- package/managed/templates/github/workflows/managed-files.yml +1 -2
- package/nextest.toml +8 -41
- package/package.json +74 -12
- package/runtime-input.sh +81 -0
- package/src/__tests__/counted-cargo.ts +33 -14
- package/src/__tests__/fixture-nx-env.ts +111 -46
- package/src/__tests__/progress-clock.ts +43 -0
- package/src/__tests__/runtime-input.ts +23 -0
- package/src/bin/smoo-nx-bound-failures.test.ts +127 -0
- package/src/bin/smoo-nx-bound-failures.ts +33 -0
- package/src/bin/smoo-nx-cargo-hash.ts +28 -3
- package/src/bin/smoo-nx-exec.ts +16 -74
- package/src/bin/smoo-nx-failures.ts +4 -0
- package/src/bin/smoo-nx-nextest-extract.ts +3 -2
- package/src/bin/smoo-nx-test-walks.ts +42 -0
- package/src/bounded-test-policy.test.ts +268 -21
- package/src/bounded-test-policy.ts +114 -42
- package/src/build-state-output-policy.test.ts +115 -0
- package/src/build-state-output-policy.ts +90 -0
- package/src/bun-bootstrap.test.ts +57 -3
- package/src/bun-file-packages.test.ts +47 -0
- package/src/cargo-closure-input.test.ts +138 -66
- package/src/cargo-closure-input.ts +17 -15
- package/src/cargo-dev-profile.ts +137 -0
- package/src/cargo-resolve-cache.test.ts +70 -1
- package/src/cargo-source-hash.test.ts +193 -97
- package/src/cargo-source-hash.ts +345 -68
- package/src/cargo-toolchain-policy.ts +6 -0
- package/src/cargo-workspace.test.ts +320 -0
- package/src/cargo-workspace.ts +336 -10
- package/src/cross-check-policy.test.ts +59 -1
- package/src/cross-check-policy.ts +25 -6
- package/src/disk-command-policy.test.ts +61 -0
- package/src/disk-command-policy.ts +107 -0
- package/src/ensure-built-receipt.test.ts +184 -0
- package/src/ensure-built-receipt.ts +263 -0
- package/src/ensure-built-witness.test.ts +344 -0
- package/src/ensure-built-witness.ts +252 -0
- package/src/ensure-built.test.ts +1036 -578
- package/src/ensure-built.ts +820 -224
- package/src/eslint-file-set.ts +9 -0
- package/src/executors/bounded-exec/cpu-pool.test.ts +454 -0
- package/src/executors/bounded-exec/cpu-pool.ts +417 -0
- package/src/executors/bounded-exec/cpu-tokens.test.ts +269 -0
- package/src/executors/bounded-exec/cpu-tokens.ts +177 -0
- package/src/executors/bounded-exec/disk-lease.test.ts +185 -0
- package/src/executors/bounded-exec/disk-lease.ts +139 -0
- package/src/executors/bounded-exec/executor-host.test.ts +778 -0
- package/src/executors/bounded-exec/executor.test.ts +1116 -63
- package/src/executors/bounded-exec/executor.ts +565 -67
- package/src/executors/bounded-exec/gateway-lease.ts +176 -0
- package/src/executors/bounded-exec/hang-diagnostics.test.ts +285 -0
- package/src/executors/bounded-exec/hang-diagnostics.ts +283 -0
- package/src/executors/bounded-exec/progress.test.ts +79 -0
- package/src/executors/bounded-exec/progress.ts +118 -0
- package/src/executors/bounded-exec/ram-temp-fixtures.ts +12 -0
- package/src/executors/bounded-exec/ram-temp-held.test.ts +264 -0
- package/src/executors/bounded-exec/ram-temp-held.ts +242 -0
- package/src/executors/bounded-exec/ram-temp-host.test.ts +605 -0
- package/src/executors/bounded-exec/ram-temp.test.ts +674 -0
- package/src/executors/bounded-exec/ram-temp.ts +1918 -0
- package/src/executors/bounded-exec/schema.json +11 -5
- package/src/executors/bounded-exec/schema.ts +27 -11
- package/src/executors/bounded-exec/verdict.test.ts +440 -0
- package/src/executors/bounded-exec/verdict.ts +433 -0
- package/src/executors/shard-timings/executor.ts +36 -0
- package/src/executors/shard-timings/schema.json +21 -0
- package/src/executors/shard-timings/schema.ts +4 -0
- package/src/failure-summary.ts +119 -0
- package/src/generators/bounded-test-targets/generator.test.ts +4 -4
- package/src/generators/bun-test-tracing/generator.test.ts +2 -2
- package/src/generators/create-package/generator.test.ts +6 -0
- package/src/generators/create-package/generator.ts +6 -2
- package/src/host-controller-wiring.test.ts +31 -0
- package/src/index.test.ts +909 -295
- package/src/index.ts +441 -143
- package/src/linked-snapshots.nx.test.ts +172 -0
- package/src/managed-files/ci-workflow.ts +54 -13
- package/src/managed-files/files.ts +65 -9
- package/src/managed-files/forgejo-artifact.test.ts +395 -0
- package/src/managed-files/generator.test.ts +60 -1
- package/src/managed-files/json-edit.test.ts +216 -0
- package/src/managed-files/json-edit.ts +290 -0
- package/src/managed-files/managed-format-json.test.ts +308 -0
- package/src/managed-files/managed-format.ts +90 -2
- package/src/managed-files/pr-preview-cleanup-workflow.ts +69 -3
- package/src/managed-files/publish-workflow.ts +285 -67
- package/src/managed-files/repo-path.test.ts +129 -0
- package/src/managed-files/trace-db-artifact.test.ts +7 -0
- package/src/managed-files/tree.ts +11 -3
- package/src/manifest-hash.ts +2 -6
- package/src/nextest-code-bound.test.ts +155 -0
- package/src/nextest-code-bound.ts +195 -0
- package/src/nextest-extraction.test.ts +37 -5
- package/src/nextest-extraction.ts +51 -9
- package/src/nextest-partitions.test.ts +427 -82
- package/src/nx-cache-bound.test.ts +5 -10
- package/src/nx-cache-restore-mtime.test.ts +170 -0
- package/src/nx-daemon-claim.test.ts +277 -0
- package/src/nx-daemon-idle-cpu.test.ts +81 -0
- package/src/nx-daemon-idle-policy.test.ts +51 -0
- package/src/nx-daemon-ignore-files.test.ts +210 -0
- package/src/nx-daemon-root-normalization.test.ts +105 -0
- package/src/nx-daemon-validity.test.ts +925 -0
- package/src/nx-dot-input-policy.test.ts +353 -0
- package/src/nx-failure-life-cycles.test.ts +207 -0
- package/src/nx-files-archive-racy.test.ts +97 -0
- package/src/nx-foreign-workspace-env.test.ts +329 -0
- package/src/nx-incomplete-run-summary.test.ts +70 -0
- package/src/nx-plugin-load-errors.test.ts +120 -0
- package/src/nx-project-resolution-cache.test.ts +176 -0
- package/src/nx-raw-inputs.test.ts +166 -0
- package/src/nx-resident-graph-workers.test.ts +7 -16
- package/src/nx-run-information.test.ts +118 -0
- package/src/nx-skipped-task-exit.test.ts +180 -0
- package/src/nx-state-location.test.ts +63 -0
- package/src/nx-store-resolution.test.ts +26 -25
- package/src/nx-task-graph-cycles.test.ts +148 -0
- package/src/nx-task-output-lease.test.ts +414 -0
- package/src/nx-use-local.test.ts +103 -0
- package/src/package-target-policy.ts +3 -6
- package/src/release-config-policy.ts +3 -6
- package/src/runtime-input.test.ts +215 -0
- package/src/runtime-input.ts +17 -0
- package/src/rust-tokens.ts +78 -0
- package/src/serial-group-wiring.test.ts +326 -0
- package/src/task-history-namespace.test.ts +87 -89
- package/src/task-results.test.ts +226 -0
- package/src/task-results.ts +75 -0
- package/src/test-program.test.ts +303 -0
- package/src/test-program.ts +341 -0
- package/src/test-timings.test.ts +240 -0
- package/src/test-timings.ts +311 -0
- package/src/test-walk-policy.test.ts +585 -0
- package/src/test-walk-policy.ts +731 -0
- package/src/testing.test.ts +509 -0
- package/src/testing.ts +922 -0
- package/src/type-guards.ts +4 -0
- package/src/typecheck-test-policy.test.ts +496 -11
- package/src/typecheck-test-policy.ts +137 -103
- package/src/workspace-config-policy.test.ts +212 -13
- package/src/workspace-config-policy.ts +101 -73
- package/src/workspace-index.ts +18 -0
- package/src/workspace-manifest.ts +41 -0
- package/test-timings.json +85 -30
- package/managed/raw/tooling/direnv/inherited-devenv.ts +0 -665
- package/managed/raw/tooling/direnv/shared-caches.sh +0 -53
|
@@ -1,22 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* A command and the bounds that end it. At least one bound is required: a run with neither would block Nx forever.
|
|
3
|
+
* A test target names only `idleTimeoutMs` (`bounded-test-policy.ts`); `timeoutMs` is for commands that report no
|
|
4
|
+
* tests, whose only progress is exiting.
|
|
5
|
+
*/
|
|
6
|
+
export type BoundedExecOptions = BoundedExecCommand & BoundedExecBounds;
|
|
7
|
+
export type BoundedExecBounds = {
|
|
8
|
+
timeoutMs: number;
|
|
9
|
+
idleTimeoutMs?: number;
|
|
10
|
+
} | {
|
|
11
|
+
timeoutMs?: undefined;
|
|
12
|
+
idleTimeoutMs: number;
|
|
13
|
+
};
|
|
14
|
+
export interface BoundedExecCommand {
|
|
2
15
|
command: string;
|
|
3
16
|
cwd?: string;
|
|
4
17
|
env?: Record<string, string>;
|
|
5
|
-
|
|
18
|
+
/** Absolute wall-clock ceiling: a backstop against an unbounded run, not a performance budget. */
|
|
19
|
+
timeoutMs?: number;
|
|
6
20
|
/**
|
|
7
|
-
* Kill the process tree when
|
|
8
|
-
* long. Absent means no progress bound.
|
|
21
|
+
* Kill the process tree when no test has finished for this long (`progress.ts`). Absent means no progress bound.
|
|
9
22
|
*
|
|
10
|
-
* This is the bound that catches a hang. A
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* just further apart, and each gap is bounded by the slowest single unit of
|
|
16
|
-
* work rather than by the total.
|
|
23
|
+
* This is the bound that catches a hang. A hung test never finishes, whatever its runner keeps printing about it,
|
|
24
|
+
* and the tests still running when it fires are named in the verdict. Unlike `timeoutMs` it does not scale with
|
|
25
|
+
* the size of the suite or the load on the machine: a machine ten times slower still finishes tests, just further
|
|
26
|
+
* apart, and each gap is bounded by the slowest single test rather than by the total. A command that reports no
|
|
27
|
+
* tests makes progress only by exiting.
|
|
17
28
|
*/
|
|
18
29
|
idleTimeoutMs?: number;
|
|
19
30
|
killAfterMs?: number;
|
|
31
|
+
/**
|
|
32
|
+
* The most threads or processes the command runs at once, which is how many CPU tokens it asks
|
|
33
|
+
* its live parent pool or the cowshed host budget for. Absent, the runner in the command decides:
|
|
34
|
+
* nextest and cargo one per core, `bun test --parallel=N` N, anything else one. The actual grant
|
|
35
|
+
* reaches the command as `BOUNDED_EXEC_CPU_TOKENS`, with its sub-pool in `BOUNDED_EXEC_CPU_POOL`.
|
|
36
|
+
*/
|
|
37
|
+
parallelism?: number;
|
|
20
38
|
forwardAllArgs?: boolean;
|
|
21
39
|
args?: string | string[];
|
|
22
40
|
__unparsed__?: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/schema.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,GAAG,iBAAiB,CAAC;AAExE,MAAM,MAAM,iBAAiB,GACzB;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7C;IAAE,SAAS,CAAC,EAAE,SAAS,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC;AAErD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,kGAAkG;IAClG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why one bounded run ended, recorded per Nx task so a caller can tell a load-sensitive bound
|
|
3
|
+
* from a real failure without reading the run's output.
|
|
4
|
+
*
|
|
5
|
+
* - `bound`: the run hit a wall-clock bound and nothing else failed. Either the command
|
|
6
|
+
* outlived `timeoutMs` (`total`), or every failing test in the runner's report failed on
|
|
7
|
+
* its runner's per-test timeout (`test`). A loaded host produces exactly these.
|
|
8
|
+
* - `wedged`: `idleTimeoutMs` fired: no test finished for that long. A machine that is only slow still finishes
|
|
9
|
+
* tests, so this is a hang, not a slow host, and the fix is the opposite one, so it is never a `bound`. It names
|
|
10
|
+
* the tests still running: those the runner said were running and never said finished, and those its report says
|
|
11
|
+
* it aborted when the bound stopped it.
|
|
12
|
+
* - `failed`: anything else that did not pass. That includes an assertion named in the report,
|
|
13
|
+
* or a non-zero exit with no report to say why.
|
|
14
|
+
*/
|
|
15
|
+
export type BoundedExecVerdict = {
|
|
16
|
+
readonly outcome: 'passed';
|
|
17
|
+
} | {
|
|
18
|
+
readonly outcome: 'bound';
|
|
19
|
+
readonly bound: 'total';
|
|
20
|
+
readonly limitMs: number;
|
|
21
|
+
readonly elapsedMs: number;
|
|
22
|
+
} | {
|
|
23
|
+
readonly outcome: 'bound';
|
|
24
|
+
readonly bound: 'test';
|
|
25
|
+
readonly tests: readonly string[];
|
|
26
|
+
} | {
|
|
27
|
+
readonly outcome: 'wedged';
|
|
28
|
+
readonly idleMs: number;
|
|
29
|
+
readonly elapsedMs: number;
|
|
30
|
+
readonly tests: readonly string[];
|
|
31
|
+
} | {
|
|
32
|
+
readonly outcome: 'failed';
|
|
33
|
+
readonly exitCode: number;
|
|
34
|
+
readonly tests: readonly string[];
|
|
35
|
+
};
|
|
36
|
+
/** One task's verdict, keyed by the Nx task and the hash it ran at. */
|
|
37
|
+
export interface BoundedExecRecord {
|
|
38
|
+
readonly task: string;
|
|
39
|
+
readonly hash: string | null;
|
|
40
|
+
readonly verdict: BoundedExecVerdict;
|
|
41
|
+
/**
|
|
42
|
+
* The host CPU budget's grant the run started under: tokens granted of those asked for, and
|
|
43
|
+
* how long it waited. Absent when it ran unbudgeted; written for the reader of a slow run,
|
|
44
|
+
* never read back.
|
|
45
|
+
*/
|
|
46
|
+
readonly cpu?: {
|
|
47
|
+
readonly tokens: number;
|
|
48
|
+
readonly want: number;
|
|
49
|
+
readonly waitedMs: number;
|
|
50
|
+
/** Set when the tokens came from an ancestor's CPU pool, not the host budget; `waitedMs` is the wait for that pool. */
|
|
51
|
+
readonly inherited?: true;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** The Nx task a run executes as. Nx gives an executor no task id, only its parts. */
|
|
55
|
+
export interface BoundedExecTask {
|
|
56
|
+
readonly id: string;
|
|
57
|
+
readonly hash: string | null;
|
|
58
|
+
}
|
|
59
|
+
/** The environment variable naming the absolute path a command writes its JUnit report to. */
|
|
60
|
+
export declare const JUNIT_REPORT_ENV = "BOUNDED_EXEC_JUNIT";
|
|
61
|
+
/** The failing tests of one JUnit report, split by what failed them. */
|
|
62
|
+
export interface JunitFailures {
|
|
63
|
+
/** Failed only on the runner's per-test timeout. */
|
|
64
|
+
readonly timedOut: readonly string[];
|
|
65
|
+
/** Aborted by the runner because its command was told to stop, not failed by anything they did. */
|
|
66
|
+
readonly cancelled: readonly string[];
|
|
67
|
+
readonly failed: readonly string[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Read the failing test cases out of a JUnit document. A case fails when it holds a `failure`
|
|
71
|
+
* or `error` element; it counts as timed out only when every such element is a timeout.
|
|
72
|
+
* Retry elements (`flakyFailure`, `rerunFailure`, ...) describe attempts, not the verdict.
|
|
73
|
+
*/
|
|
74
|
+
export declare function junitFailures(xml: string): JunitFailures;
|
|
75
|
+
/**
|
|
76
|
+
* The bound that ended a run. `total` is a wall-clock ceiling: it answers "is this run unbounded?". `idle` is the
|
|
77
|
+
* no-progress bound: it answers "is this run hung?", and carries the tests the runner reported still running.
|
|
78
|
+
*
|
|
79
|
+
* These are different questions and one number cannot answer both. A ceiling tight enough to catch a hang promptly
|
|
80
|
+
* is also tight enough to fail a correct run on a busy machine; a ceiling loose enough never to do that cannot catch
|
|
81
|
+
* a hang promptly. Keeping the two bounds separate is what makes each honest.
|
|
82
|
+
*/
|
|
83
|
+
export type ExpiredBound = {
|
|
84
|
+
readonly kind: 'total';
|
|
85
|
+
readonly limitMs: number;
|
|
86
|
+
} | {
|
|
87
|
+
readonly kind: 'idle';
|
|
88
|
+
readonly limitMs: number;
|
|
89
|
+
readonly tests: readonly string[];
|
|
90
|
+
};
|
|
91
|
+
/** How a run ended, as the executor saw it. */
|
|
92
|
+
export interface RunEnd {
|
|
93
|
+
readonly exitCode: number;
|
|
94
|
+
readonly elapsedMs: number;
|
|
95
|
+
readonly expiry: ExpiredBound | null;
|
|
96
|
+
/** The run's report, or `null` when the command was asked for none or wrote none. */
|
|
97
|
+
readonly report: JunitFailures | null;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Judge a run. A test that failed on its own is a failure even when a bound fired too, and the no-progress bound is
|
|
101
|
+
* never load: the report's assertions and the idle bound are read first. A test the runner aborted because the total
|
|
102
|
+
* bound told its command to stop is not one that failed; one it aborted at the idle bound is a test still running.
|
|
103
|
+
*/
|
|
104
|
+
export declare function judgeRun(run: RunEnd): BoundedExecVerdict;
|
|
105
|
+
/**
|
|
106
|
+
* A run that failed for a reason its command did not cause: its CPU grant was lost, or its sub-pool did not close
|
|
107
|
+
* cleanly. It is an ordinary failure whatever the command exited with and whatever bound also fired, and the tests it
|
|
108
|
+
* reports are failures, never bounds. A failed run never records exit 0.
|
|
109
|
+
*/
|
|
110
|
+
export declare function judgeOperationalFailure(exitCode: number, report: JunitFailures | null): BoundedExecVerdict;
|
|
111
|
+
/** Where `task`'s verdict and report live: this checkout's own Nx workspace-data directory. */
|
|
112
|
+
export declare function taskDirectory(workspaceData: string, taskId: string): string;
|
|
113
|
+
export declare const VERDICT_FILE = "verdict.json";
|
|
114
|
+
export declare const JUNIT_FILE = "report.xml";
|
|
115
|
+
/**
|
|
116
|
+
* `bun test`, or nextest's `nextest run` under any cargo spelling, as one shell word sequence.
|
|
117
|
+
* Global, for `match` and `replace`; `search` ignores the flag where only presence matters.
|
|
118
|
+
*
|
|
119
|
+
* `bun` is any unquoted command word whose basename is `bun`, so a runtime pinned by path
|
|
120
|
+
* (`../bun-runtime/.runtime/bun test`) is the runner too. Capture group 1 is that word, which
|
|
121
|
+
* a rewrite must keep: it is the binary the target chose. An assignment (`BUN_EXE=../x/bun test`
|
|
122
|
+
* runs the command `test`) and a longer basename (`debug-bun test`) are not it.
|
|
123
|
+
*/
|
|
124
|
+
export declare const BUN_TEST: RegExp;
|
|
125
|
+
export declare const NEXTEST_RUN: RegExp;
|
|
126
|
+
/**
|
|
127
|
+
* `command` with its test runner asked to write a JUnit report into `directory`, the report
|
|
128
|
+
* `judgeRun` reads. Both runners are recognised by their invocation, so every target that runs
|
|
129
|
+
* one gets a report without restating it: `bun test` takes the path as flags, and nextest takes
|
|
130
|
+
* it only from configuration, so it gets a one-key tool config written beside the report.
|
|
131
|
+
*
|
|
132
|
+
* A command that runs no runner, or more than one (two runs would overwrite one report), or
|
|
133
|
+
* that already chose bun's reporter, is returned unchanged and judged by its exit alone.
|
|
134
|
+
*/
|
|
135
|
+
export declare function withJunitReport(command: string, directory: string): Promise<string>;
|
|
136
|
+
/** Remove a previous run's verdict and report, so neither can be read as this run's. */
|
|
137
|
+
export declare function clearTaskDirectory(directory: string): Promise<void>;
|
|
138
|
+
export declare function writeRecord(directory: string, record: BoundedExecRecord): Promise<void>;
|
|
139
|
+
/** The record in `directory`, or `null` when there is none. A malformed record throws. */
|
|
140
|
+
export declare function readRecord(directory: string): Promise<BoundedExecRecord | null>;
|
|
141
|
+
/** The JUnit report a command wrote into `directory`, or `null` when it wrote none. */
|
|
142
|
+
export declare function readJunitReport(directory: string): Promise<JunitFailures | null>;
|
|
143
|
+
/** A failed task of an Nx run, and whether its bounded-exec record shows only a bound. */
|
|
144
|
+
export type FailedTask = {
|
|
145
|
+
readonly task: string;
|
|
146
|
+
readonly bound: true;
|
|
147
|
+
readonly verdict: Extract<BoundedExecVerdict, {
|
|
148
|
+
outcome: 'bound';
|
|
149
|
+
}>;
|
|
150
|
+
} | {
|
|
151
|
+
readonly task: string;
|
|
152
|
+
readonly bound: false;
|
|
153
|
+
readonly reason: string;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Each failed task of the run Nx summarised in `runJson` (its cache directory's `run.json`),
|
|
157
|
+
* judged by the record bounded-exec wrote for exactly that run: same task, same hash. A task
|
|
158
|
+
* with no record, or a record from another hash, is not a bound; nothing is assumed.
|
|
159
|
+
*/
|
|
160
|
+
export declare function failedTasksOfRun(runJson: unknown, workspaceData: string): Promise<FailedTask[]>;
|
|
161
|
+
export declare function describeVerdict(verdict: BoundedExecVerdict): string;
|
|
162
|
+
//# sourceMappingURL=verdict.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verdict.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/verdict.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,kBAAkB,GAC1B;IAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,GAC9B;IAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAC5G;IAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACxF;IACE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC,GACD;IAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAEjG,uEAAuE;AACvE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC;;;;OAIG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE;QACb,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,uHAAuH;QACvH,QAAQ,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC;KAC3B,CAAC;CACH;AAED,sFAAsF;AACtF,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,8FAA8F;AAC9F,eAAO,MAAM,gBAAgB,uBAAuB,CAAC;AA2BrD,wEAAwE;AACxE,MAAM,WAAW,aAAa;IAC5B,oDAAoD;IACpD,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,mGAAmG;IACnG,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAwCxD;AA+BD;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GACpB;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACpD;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAE3F,+CAA+C;AAC/C,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IACrC,qFAAqF;IACrF,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;CACvC;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAwBxD;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,GAAG,kBAAkB,CAG1G;AAED,+FAA+F;AAC/F,wBAAgB,aAAa,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAE3E;AAED,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAC3C,eAAO,MAAM,UAAU,eAAe,CAAC;AAGvC;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ,QAAoE,CAAC;AAC1F,eAAO,MAAM,WAAW,QAA4C,CAAC;AAErE;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAkBzF;AAMD,wFAAwF;AACxF,wBAAsB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMzE;AAED,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAK7F;AAED,0FAA0F;AAC1F,wBAAsB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAWrF;AAED,uFAAuF;AACvF,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAStF;AAiDD,0FAA0F;AAC1F,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,kBAAkB,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;CAAE,GACpH;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9E;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CA6BrG;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,CAmBnE"}
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
/** The environment variable naming the absolute path a command writes its JUnit report to. */
|
|
4
|
+
export const JUNIT_REPORT_ENV = 'BOUNDED_EXEC_JUNIT';
|
|
5
|
+
/**
|
|
6
|
+
* JUnit failure `type`s that mean "the runner's per-test timeout fired". `cargo-nextest` writes
|
|
7
|
+
* `test timeout` for a test it terminated at its slow-timeout; `bun test` writes `TimeoutError`
|
|
8
|
+
* for a test or hook that outlived `--timeout`. Every other type is a failure of the test itself.
|
|
9
|
+
*/
|
|
10
|
+
const TIMEOUT_FAILURE_TYPES = { 'test timeout': true, TimeoutError: true };
|
|
11
|
+
/**
|
|
12
|
+
* The JUnit failure that means "the runner stopped this test because its command was told to stop". When the
|
|
13
|
+
* SIGTERM bounded-exec sends at a bound reaches `cargo-nextest`, it ends the tests still running and reports each as
|
|
14
|
+
* a `test abort` whose message names the signal: SIGTERM, or SIGKILL once the force-kill has followed. A test that
|
|
15
|
+
* dies of any other signal (SIGSEGV, SIGABRT) is a crash of the test itself.
|
|
16
|
+
*/
|
|
17
|
+
const CANCELLED_ABORT_TYPE = 'test abort';
|
|
18
|
+
const CANCELLED_ABORT_MESSAGE = /^process aborted with signal (?:15 \(SIGTERM\)|9 \(SIGKILL\))$/;
|
|
19
|
+
function failureKind(type, message) {
|
|
20
|
+
if (Object.hasOwn(TIMEOUT_FAILURE_TYPES, type)) {
|
|
21
|
+
return 'timedOut';
|
|
22
|
+
}
|
|
23
|
+
return type === CANCELLED_ABORT_TYPE && CANCELLED_ABORT_MESSAGE.test(message) ? 'cancelled' : 'failed';
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Read the failing test cases out of a JUnit document. A case fails when it holds a `failure`
|
|
27
|
+
* or `error` element; it counts as timed out only when every such element is a timeout.
|
|
28
|
+
* Retry elements (`flakyFailure`, `rerunFailure`, ...) describe attempts, not the verdict.
|
|
29
|
+
*/
|
|
30
|
+
export function junitFailures(xml) {
|
|
31
|
+
const timedOut = [];
|
|
32
|
+
const cancelled = [];
|
|
33
|
+
const failed = [];
|
|
34
|
+
const text = xml.replace(/<!\[CDATA\[[\s\S]*?\]\]>/g, '').replace(/<!--[\s\S]*?-->/g, '');
|
|
35
|
+
const tags = /<(\/?)(testcase|failure|error)\b((?:[^>"']|"[^"]*"|'[^']*')*?)(\/?)>/g;
|
|
36
|
+
let current = null;
|
|
37
|
+
const close = () => {
|
|
38
|
+
if (current === null) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const [first] = current.kinds;
|
|
42
|
+
if (first !== undefined) {
|
|
43
|
+
const kind = current.kinds.every((one) => one === first) ? first : 'failed';
|
|
44
|
+
(kind === 'timedOut' ? timedOut : kind === 'cancelled' ? cancelled : failed).push(current.name);
|
|
45
|
+
}
|
|
46
|
+
current = null;
|
|
47
|
+
};
|
|
48
|
+
for (const [, slash, tag, attributes = '', selfClosing] of text.matchAll(tags)) {
|
|
49
|
+
if (tag === 'testcase') {
|
|
50
|
+
if (slash === '/') {
|
|
51
|
+
close();
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
close();
|
|
55
|
+
const name = attribute(attributes, 'name') ?? '';
|
|
56
|
+
const classname = attribute(attributes, 'classname');
|
|
57
|
+
current = { name: classname ? `${classname} ${name}` : name, kinds: [] };
|
|
58
|
+
if (selfClosing === '/') {
|
|
59
|
+
close();
|
|
60
|
+
}
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (slash === '/' || current === null) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
current.kinds.push(failureKind(attribute(attributes, 'type') ?? '', attribute(attributes, 'message') ?? ''));
|
|
67
|
+
}
|
|
68
|
+
close();
|
|
69
|
+
return { timedOut, cancelled, failed };
|
|
70
|
+
}
|
|
71
|
+
function attribute(attributes, name) {
|
|
72
|
+
const match = new RegExp(`(?:^|\\s)${name}\\s*=\\s*("([^"]*)"|'([^']*)')`).exec(attributes);
|
|
73
|
+
if (match === null) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
return decodeEntities(match[2] ?? match[3] ?? '');
|
|
77
|
+
}
|
|
78
|
+
function decodeEntities(value) {
|
|
79
|
+
return value.replace(/&(#x[0-9a-fA-F]+|#[0-9]+|amp|lt|gt|quot|apos);/g, (_, entity) => {
|
|
80
|
+
switch (entity) {
|
|
81
|
+
case 'amp':
|
|
82
|
+
return '&';
|
|
83
|
+
case 'lt':
|
|
84
|
+
return '<';
|
|
85
|
+
case 'gt':
|
|
86
|
+
return '>';
|
|
87
|
+
case 'quot':
|
|
88
|
+
return '"';
|
|
89
|
+
case 'apos':
|
|
90
|
+
return "'";
|
|
91
|
+
default:
|
|
92
|
+
return String.fromCodePoint(entity.startsWith('#x') ? Number.parseInt(entity.slice(2), 16) : Number.parseInt(entity.slice(1), 10));
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Judge a run. A test that failed on its own is a failure even when a bound fired too, and the no-progress bound is
|
|
98
|
+
* never load: the report's assertions and the idle bound are read first. A test the runner aborted because the total
|
|
99
|
+
* bound told its command to stop is not one that failed; one it aborted at the idle bound is a test still running.
|
|
100
|
+
*/
|
|
101
|
+
export function judgeRun(run) {
|
|
102
|
+
if (run.expiry?.kind === 'idle') {
|
|
103
|
+
const tests = [...new Set([...run.expiry.tests, ...(run.report?.cancelled ?? [])])];
|
|
104
|
+
return { outcome: 'wedged', idleMs: run.expiry.limitMs, elapsedMs: run.elapsedMs, tests };
|
|
105
|
+
}
|
|
106
|
+
if (run.report !== null && run.report.failed.length > 0) {
|
|
107
|
+
return { outcome: 'failed', exitCode: run.exitCode, tests: run.report.failed };
|
|
108
|
+
}
|
|
109
|
+
// The tests the runner aborted when the ceiling's SIGTERM reached it are the bound's casualties: they are in the
|
|
110
|
+
// report as failures, but nothing about them failed. Aborted with no total bound to explain it, they are failures,
|
|
111
|
+
// whatever else the run shows: a zero exit or a per-test timeout does not excuse a test someone else stopped.
|
|
112
|
+
if (run.expiry?.kind === 'total') {
|
|
113
|
+
return { outcome: 'bound', bound: 'total', limitMs: run.expiry.limitMs, elapsedMs: run.elapsedMs };
|
|
114
|
+
}
|
|
115
|
+
if (run.report !== null && run.report.cancelled.length > 0) {
|
|
116
|
+
return { outcome: 'failed', exitCode: run.exitCode, tests: run.report.cancelled };
|
|
117
|
+
}
|
|
118
|
+
if (run.exitCode === 0) {
|
|
119
|
+
return { outcome: 'passed' };
|
|
120
|
+
}
|
|
121
|
+
if (run.report !== null && run.report.timedOut.length > 0) {
|
|
122
|
+
return { outcome: 'bound', bound: 'test', tests: run.report.timedOut };
|
|
123
|
+
}
|
|
124
|
+
return { outcome: 'failed', exitCode: run.exitCode, tests: [] };
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* A run that failed for a reason its command did not cause: its CPU grant was lost, or its sub-pool did not close
|
|
128
|
+
* cleanly. It is an ordinary failure whatever the command exited with and whatever bound also fired, and the tests it
|
|
129
|
+
* reports are failures, never bounds. A failed run never records exit 0.
|
|
130
|
+
*/
|
|
131
|
+
export function judgeOperationalFailure(exitCode, report) {
|
|
132
|
+
const tests = report === null ? [] : [...report.failed, ...report.timedOut, ...report.cancelled];
|
|
133
|
+
return { outcome: 'failed', exitCode: exitCode === 0 ? 1 : exitCode, tests };
|
|
134
|
+
}
|
|
135
|
+
/** Where `task`'s verdict and report live: this checkout's own Nx workspace-data directory. */
|
|
136
|
+
export function taskDirectory(workspaceData, taskId) {
|
|
137
|
+
return join(workspaceData, 'bounded-exec', encodeURIComponent(taskId));
|
|
138
|
+
}
|
|
139
|
+
export const VERDICT_FILE = 'verdict.json';
|
|
140
|
+
export const JUNIT_FILE = 'report.xml';
|
|
141
|
+
const NEXTEST_REPORT_CONFIG_FILE = 'nextest-report.toml';
|
|
142
|
+
/**
|
|
143
|
+
* `bun test`, or nextest's `nextest run` under any cargo spelling, as one shell word sequence.
|
|
144
|
+
* Global, for `match` and `replace`; `search` ignores the flag where only presence matters.
|
|
145
|
+
*
|
|
146
|
+
* `bun` is any unquoted command word whose basename is `bun`, so a runtime pinned by path
|
|
147
|
+
* (`../bun-runtime/.runtime/bun test`) is the runner too. Capture group 1 is that word, which
|
|
148
|
+
* a rewrite must keep: it is the binary the target chose. An assignment (`BUN_EXE=../x/bun test`
|
|
149
|
+
* runs the command `test`) and a longer basename (`debug-bun test`) are not it.
|
|
150
|
+
*/
|
|
151
|
+
export const BUN_TEST = /(?<=^|[\s;&|()])((?:[^\s;&|()<>'"`\\=]*\/)?bun)\s+test(?=\s|$)/g;
|
|
152
|
+
export const NEXTEST_RUN = /(?<=^|[\s;&|()-])nextest\s+run(?=\s|$)/g;
|
|
153
|
+
/**
|
|
154
|
+
* `command` with its test runner asked to write a JUnit report into `directory`, the report
|
|
155
|
+
* `judgeRun` reads. Both runners are recognised by their invocation, so every target that runs
|
|
156
|
+
* one gets a report without restating it: `bun test` takes the path as flags, and nextest takes
|
|
157
|
+
* it only from configuration, so it gets a one-key tool config written beside the report.
|
|
158
|
+
*
|
|
159
|
+
* A command that runs no runner, or more than one (two runs would overwrite one report), or
|
|
160
|
+
* that already chose bun's reporter, is returned unchanged and judged by its exit alone.
|
|
161
|
+
*/
|
|
162
|
+
export async function withJunitReport(command, directory) {
|
|
163
|
+
const bun = command.match(BUN_TEST)?.length ?? 0;
|
|
164
|
+
const nextest = command.match(NEXTEST_RUN)?.length ?? 0;
|
|
165
|
+
if (bun + nextest !== 1) {
|
|
166
|
+
return command;
|
|
167
|
+
}
|
|
168
|
+
const report = join(directory, JUNIT_FILE);
|
|
169
|
+
if (bun === 1) {
|
|
170
|
+
return /(^|\s)--reporter(=|\s|$)/.test(command)
|
|
171
|
+
? command
|
|
172
|
+
: command.replace(BUN_TEST, (_match, runtime) => `${runtime} test --reporter=junit --reporter-outfile=${shellQuote(report)}`);
|
|
173
|
+
}
|
|
174
|
+
const config = join(directory, NEXTEST_REPORT_CONFIG_FILE);
|
|
175
|
+
await writeFile(config, `[profile.default.junit]\npath = ${JSON.stringify(report)}\n`);
|
|
176
|
+
return command.replace(NEXTEST_RUN, () => `nextest run --tool-config-file ${shellQuote(`smoo-report:${config}`)}`);
|
|
177
|
+
}
|
|
178
|
+
function shellQuote(value) {
|
|
179
|
+
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
180
|
+
}
|
|
181
|
+
/** Remove a previous run's verdict and report, so neither can be read as this run's. */
|
|
182
|
+
export async function clearTaskDirectory(directory) {
|
|
183
|
+
await mkdir(directory, { recursive: true });
|
|
184
|
+
await Promise.all([
|
|
185
|
+
rm(join(directory, VERDICT_FILE), { force: true }),
|
|
186
|
+
rm(join(directory, JUNIT_FILE), { force: true }),
|
|
187
|
+
]);
|
|
188
|
+
}
|
|
189
|
+
export async function writeRecord(directory, record) {
|
|
190
|
+
const target = join(directory, VERDICT_FILE);
|
|
191
|
+
const staged = `${target}.${process.pid}`;
|
|
192
|
+
await writeFile(staged, `${JSON.stringify(record, null, 2)}\n`);
|
|
193
|
+
await rename(staged, target);
|
|
194
|
+
}
|
|
195
|
+
/** The record in `directory`, or `null` when there is none. A malformed record throws. */
|
|
196
|
+
export async function readRecord(directory) {
|
|
197
|
+
let text;
|
|
198
|
+
try {
|
|
199
|
+
text = await readFile(join(directory, VERDICT_FILE), 'utf8');
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
if (isNotFound(error)) {
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
throw error;
|
|
206
|
+
}
|
|
207
|
+
return parseRecord(JSON.parse(text));
|
|
208
|
+
}
|
|
209
|
+
/** The JUnit report a command wrote into `directory`, or `null` when it wrote none. */
|
|
210
|
+
export async function readJunitReport(directory) {
|
|
211
|
+
try {
|
|
212
|
+
return junitFailures(await readFile(join(directory, JUNIT_FILE), 'utf8'));
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
if (isNotFound(error)) {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
throw error;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function isNotFound(error) {
|
|
222
|
+
return typeof error === 'object' && error !== null && 'code' in error && error.code === 'ENOENT';
|
|
223
|
+
}
|
|
224
|
+
function parseRecord(value) {
|
|
225
|
+
if (!isObject(value) || typeof value.task !== 'string' || !(typeof value.hash === 'string' || value.hash === null)) {
|
|
226
|
+
throw new Error(`not a bounded-exec record: ${JSON.stringify(value)}`);
|
|
227
|
+
}
|
|
228
|
+
return { task: value.task, hash: value.hash, verdict: parseVerdict(value.verdict) };
|
|
229
|
+
}
|
|
230
|
+
function parseVerdict(value) {
|
|
231
|
+
if (isObject(value)) {
|
|
232
|
+
switch (value.outcome) {
|
|
233
|
+
case 'passed':
|
|
234
|
+
return { outcome: 'passed' };
|
|
235
|
+
case 'bound':
|
|
236
|
+
if (value.bound === 'total' && typeof value.limitMs === 'number' && typeof value.elapsedMs === 'number') {
|
|
237
|
+
return { outcome: 'bound', bound: 'total', limitMs: value.limitMs, elapsedMs: value.elapsedMs };
|
|
238
|
+
}
|
|
239
|
+
if (value.bound === 'test' && isStrings(value.tests)) {
|
|
240
|
+
return { outcome: 'bound', bound: 'test', tests: value.tests };
|
|
241
|
+
}
|
|
242
|
+
break;
|
|
243
|
+
case 'wedged':
|
|
244
|
+
if (typeof value.idleMs === 'number' && typeof value.elapsedMs === 'number' && isStrings(value.tests)) {
|
|
245
|
+
return { outcome: 'wedged', idleMs: value.idleMs, elapsedMs: value.elapsedMs, tests: value.tests };
|
|
246
|
+
}
|
|
247
|
+
break;
|
|
248
|
+
case 'failed':
|
|
249
|
+
if (typeof value.exitCode === 'number' && isStrings(value.tests)) {
|
|
250
|
+
return { outcome: 'failed', exitCode: value.exitCode, tests: value.tests };
|
|
251
|
+
}
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
throw new Error(`not a bounded-exec verdict: ${JSON.stringify(value)}`);
|
|
256
|
+
}
|
|
257
|
+
function isObject(value) {
|
|
258
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
259
|
+
}
|
|
260
|
+
function isStrings(value) {
|
|
261
|
+
return Array.isArray(value) && value.every((item) => typeof item === 'string');
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Each failed task of the run Nx summarised in `runJson` (its cache directory's `run.json`),
|
|
265
|
+
* judged by the record bounded-exec wrote for exactly that run: same task, same hash. A task
|
|
266
|
+
* with no record, or a record from another hash, is not a bound; nothing is assumed.
|
|
267
|
+
*/
|
|
268
|
+
export async function failedTasksOfRun(runJson, workspaceData) {
|
|
269
|
+
if (!isObject(runJson) || !Array.isArray(runJson.tasks)) {
|
|
270
|
+
throw new Error('run.json has no task list');
|
|
271
|
+
}
|
|
272
|
+
const failed = [];
|
|
273
|
+
for (const entry of runJson.tasks) {
|
|
274
|
+
if (!isObject(entry) || typeof entry.taskId !== 'string' || typeof entry.status !== 'number') {
|
|
275
|
+
throw new Error(`run.json holds a malformed task: ${JSON.stringify(entry)}`);
|
|
276
|
+
}
|
|
277
|
+
if (entry.status === 0) {
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
const task = entry.taskId;
|
|
281
|
+
const record = await readRecord(taskDirectory(workspaceData, task));
|
|
282
|
+
if (record === null) {
|
|
283
|
+
failed.push({ task, bound: false, reason: 'no bounded-exec verdict' });
|
|
284
|
+
}
|
|
285
|
+
else if (record.task !== task || record.hash !== entry.hash) {
|
|
286
|
+
failed.push({
|
|
287
|
+
task,
|
|
288
|
+
bound: false,
|
|
289
|
+
reason: `its verdict is from hash ${record.hash}, not this run's ${entry.hash}`,
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
else if (record.verdict.outcome === 'bound') {
|
|
293
|
+
failed.push({ task, bound: true, verdict: record.verdict });
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
failed.push({ task, bound: false, reason: describeVerdict(record.verdict) });
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return failed;
|
|
300
|
+
}
|
|
301
|
+
export function describeVerdict(verdict) {
|
|
302
|
+
switch (verdict.outcome) {
|
|
303
|
+
case 'passed':
|
|
304
|
+
return 'passed';
|
|
305
|
+
case 'bound':
|
|
306
|
+
return verdict.bound === 'total'
|
|
307
|
+
? `outlived its ${verdict.limitMs}ms bound (${verdict.elapsedMs}ms)`
|
|
308
|
+
: `per-test timeout only: ${verdict.tests.join(', ')}`;
|
|
309
|
+
case 'wedged':
|
|
310
|
+
return `wedged: no test finished for ${verdict.idleMs}ms after ${verdict.elapsedMs}ms; ${verdict.tests.length > 0
|
|
311
|
+
? `still running: ${verdict.tests.join(', ')}`
|
|
312
|
+
: 'the runner named no test still running'}`;
|
|
313
|
+
case 'failed':
|
|
314
|
+
return verdict.tests.length > 0
|
|
315
|
+
? `failed: ${verdict.tests.join(', ')}`
|
|
316
|
+
: `exited ${verdict.exitCode} with no report naming a timeout`;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ShardTimingsOptions } from './schema.js';
|
|
2
|
+
interface ShardTimingsContext {
|
|
3
|
+
root: string;
|
|
4
|
+
projectName?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Replays Bun's test discovery rules for the suite, running no test, and fails listing each discovered file the
|
|
8
|
+
* `--timings` manifests do not name, with the command that refreshes them.
|
|
9
|
+
*/
|
|
10
|
+
export default function shardTimingsExecutor(options: ShardTimingsOptions, context: ShardTimingsContext): Promise<{
|
|
11
|
+
success: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/shard-timings/executor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,wBAA8B,oBAAoB,CAChD,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAkB/B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { posix } from 'node:path';
|
|
2
|
+
import { timingsCoverage, untimedTestFilesReport } from '../../test-timings.js';
|
|
3
|
+
/**
|
|
4
|
+
* Replays Bun's test discovery rules for the suite, running no test, and fails listing each discovered file the
|
|
5
|
+
* `--timings` manifests do not name, with the command that refreshes them.
|
|
6
|
+
*/
|
|
7
|
+
export default async function shardTimingsExecutor(options, context) {
|
|
8
|
+
const projectName = context.projectName;
|
|
9
|
+
if (!projectName) {
|
|
10
|
+
throw new Error('@smoothbricks/nx-plugin:shard-timings requires a project context.');
|
|
11
|
+
}
|
|
12
|
+
const result = await timingsCoverage(context.root, options);
|
|
13
|
+
if (!result.ok) {
|
|
14
|
+
console.error(`shard-timings: ${result.error}`);
|
|
15
|
+
return { success: false };
|
|
16
|
+
}
|
|
17
|
+
const { coverage } = result;
|
|
18
|
+
if (coverage.untimed.length > 0) {
|
|
19
|
+
console.error(untimedTestFilesReport(projectName, options.cwd, coverage));
|
|
20
|
+
return { success: false };
|
|
21
|
+
}
|
|
22
|
+
const manifest = posix.join(options.cwd, coverage.manifests[0] ?? '');
|
|
23
|
+
console.log(`shard-timings: ${manifest} names all ${coverage.files.length} test files the shards run`);
|
|
24
|
+
return { success: true };
|
|
25
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { TimingsShardedSuite } from '../../test-timings.js';
|
|
2
|
+
/** Options of `@smoothbricks/nx-plugin:shard-timings`: the suite whose `--timings` manifests must name every file. */
|
|
3
|
+
export type ShardTimingsOptions = Pick<TimingsShardedSuite, 'cwd' | 'args'>;
|
|
4
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/executors/shard-timings/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,sHAAsH;AACtH,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,EAAE,KAAK,GAAG,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Reporting only: the caller must retain the raw output and propagate the gate's actual exit status. */
|
|
2
|
+
export declare function summarizeFailures(output: string): string;
|
|
3
|
+
/** CLI entry shared by the installed binary and repository host entrypoints; success means reporting succeeded only. */
|
|
4
|
+
export declare function runFailureSummary(args: readonly string[]): number;
|
|
5
|
+
//# sourceMappingURL=failure-summary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"failure-summary.d.ts","sourceRoot":"","sources":["../src/failure-summary.ts"],"names":[],"mappings":"AAwDA,yGAAyG;AACzG,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CA6CxD;AAED,wHAAwH;AACxH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAajE"}
|