@smoothbricks/nx-plugin 0.4.25 → 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 +1078 -98
- 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 +16 -85
- 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 +16 -17
- package/dist/cargo-closure-input.d.ts.map +1 -1
- package/dist/cargo-closure-input.js +37 -44
- 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 +50 -8
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +691 -71
- 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 +108 -12
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +299 -18
- 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 +213 -12
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +624 -177
- 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 +435 -230
- package/dist/managed-assets.d.ts +6 -0
- package/dist/managed-assets.d.ts.map +1 -1
- 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.js +3 -2
- 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 -1
- package/dist/workspace-manifest.d.ts.map +1 -1
- package/executors.json +5 -0
- package/loader.js +13 -11
- package/managed/raw/envrc +33 -62
- 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 +607 -17
- package/managed/raw/tooling/direnv/devenv.smoo.nix +314 -92
- 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 +1009 -118
- 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 -75
- package/package.json +75 -13
- package/runtime-input.sh +81 -0
- package/src/__tests__/counted-cargo-process.ts +286 -0
- package/src/__tests__/counted-cargo.ts +730 -0
- package/src/__tests__/fixture-cargo-home.ts +36 -0
- package/src/__tests__/fixture-nx-env.ts +157 -2
- 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 +17 -86
- 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 -22
- 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 +432 -62
- package/src/cargo-closure-input.ts +51 -57
- package/src/cargo-dev-profile.ts +137 -0
- package/src/cargo-resolve-cache.test.ts +1044 -0
- package/src/cargo-source-hash.test.ts +203 -93
- package/src/cargo-source-hash.ts +762 -75
- package/src/cargo-toolchain-policy.ts +6 -0
- package/src/cargo-workspace.test.ts +320 -0
- package/src/cargo-workspace.ts +344 -18
- 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 +1043 -483
- package/src/ensure-built.ts +870 -197
- 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 +1070 -360
- package/src/index.ts +524 -255
- package/src/linked-snapshots.nx.test.ts +172 -0
- package/src/managed-assets.ts +12 -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 +3 -2
- 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 +495 -0
- package/src/nx-cache-bound.test.ts +109 -0
- 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 +112 -0
- 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 +99 -0
- 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 +181 -0
- 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 -1
- package/test-timings.json +85 -28
- package/managed/raw/tooling/direnv/inherited-devenv.ts +0 -615
- package/managed/raw/tooling/direnv/shared-caches.sh +0 -53
- package/src/__tests__/in-process-nx-index.ts +0 -9
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
import { readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
import { join, resolve } from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
/**
|
|
9
|
+
* A nextest run-wrapper that measures a test's code time rather than its wall time against its class
|
|
10
|
+
* (specs/cowshed/08_testing.md, "Integration tests (real substrate)").
|
|
11
|
+
*
|
|
12
|
+
* A real-APFS test spends part of its wall time queued for the host disk-lifecycle lease, behind
|
|
13
|
+
* every other cowshed process on the host (05_gateway.md, "Disk-lifecycle lease"). That queue is
|
|
14
|
+
* the host's, not the test's code. The wrapper names a fresh lease-wait record in
|
|
15
|
+
* `COWSHED_LEASE_WAIT_RECORD`, runs the test binary, which every disk-lease client of the test's
|
|
16
|
+
* process tree appends its waits to, and then measures the test's code time, its wall time less the
|
|
17
|
+
* union of those waits, against the class it was configured with. It says the split on stderr after
|
|
18
|
+
* the test body, and warns when the code time is over the class; the test keeps its own exit status.
|
|
19
|
+
* A class is a slow warning, never a kill or a failure: the run's no-progress bound ends a hang.
|
|
20
|
+
*
|
|
21
|
+
* Usage, as nextest invokes it: `nextest-code-bound.ts <class-seconds> <test-binary> [args…]`.
|
|
22
|
+
*/
|
|
23
|
+
/** The variable naming the record; the same name every disk-lease client reads. */
|
|
24
|
+
export const LEASE_WAIT_RECORD_ENV = 'COWSHED_LEASE_WAIT_RECORD';
|
|
25
|
+
const INTEGER = /^\d+$/;
|
|
26
|
+
/** Reads a record as its clients write it. Any line that is not one of the two shapes is refused. */
|
|
27
|
+
export function parseWaitRecord(text) {
|
|
28
|
+
const edges = [];
|
|
29
|
+
for (const line of text.split('\n')) {
|
|
30
|
+
if (line === '') {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const fields = line.split(' ');
|
|
34
|
+
const [kind, pid, seq, atUs] = fields;
|
|
35
|
+
const numeric = [pid, seq, atUs].every((field) => field !== undefined && INTEGER.test(field));
|
|
36
|
+
if (kind === 'start' && fields.length === 5 && numeric) {
|
|
37
|
+
edges.push({ kind, pid: Number(pid), seq: Number(seq), atUs: Number(atUs), diskClass: fields[4] });
|
|
38
|
+
}
|
|
39
|
+
else if (kind === 'end' && fields.length === 4 && numeric) {
|
|
40
|
+
edges.push({ kind, pid: Number(pid), seq: Number(seq), atUs: Number(atUs) });
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return { ok: false, error: `line ${JSON.stringify(line)} is neither a wait's start nor its end` };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return { ok: true, edges };
|
|
47
|
+
}
|
|
48
|
+
/** The test's code time: its wall time from `startedUs` to `endedUs` less the union of its waits. */
|
|
49
|
+
export function codeTime(edges, startedUs, endedUs) {
|
|
50
|
+
const starts = new Map();
|
|
51
|
+
const intervals = [];
|
|
52
|
+
let strayEnds = 0;
|
|
53
|
+
for (const edge of edges) {
|
|
54
|
+
const key = `${edge.pid}:${edge.seq}`;
|
|
55
|
+
if (edge.kind === 'start') {
|
|
56
|
+
starts.set(key, { atUs: edge.atUs, pid: edge.pid, seq: edge.seq });
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const start = starts.get(key);
|
|
60
|
+
if (start === undefined) {
|
|
61
|
+
strayEnds += 1;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
starts.delete(key);
|
|
65
|
+
intervals.push([start.atUs, edge.atUs]);
|
|
66
|
+
}
|
|
67
|
+
const open = [...starts.values()].map(({ pid, seq, atUs }) => ({ pid, seq, startedUs: atUs }));
|
|
68
|
+
for (const wait of open) {
|
|
69
|
+
intervals.push([wait.startedUs, endedUs]);
|
|
70
|
+
}
|
|
71
|
+
const waits = intervals.length;
|
|
72
|
+
const clipped = intervals
|
|
73
|
+
.map(([from, to]) => [Math.max(from, startedUs), Math.min(to, endedUs)])
|
|
74
|
+
.filter(([from, to]) => to > from)
|
|
75
|
+
.sort((left, right) => left[0] - right[0]);
|
|
76
|
+
let waitUs = 0;
|
|
77
|
+
let reach = startedUs;
|
|
78
|
+
for (const [from, to] of clipped) {
|
|
79
|
+
const begin = Math.max(from, reach);
|
|
80
|
+
if (to > begin) {
|
|
81
|
+
waitUs += to - begin;
|
|
82
|
+
reach = to;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const wallUs = Math.max(0, endedUs - startedUs);
|
|
86
|
+
return { wallUs, waitUs, codeUs: wallUs - waitUs, waits, open, strayEnds };
|
|
87
|
+
}
|
|
88
|
+
const seconds = (us) => `${(us / 1_000_000).toFixed(1)}s`;
|
|
89
|
+
/** The one line the wrapper prints after the test body. */
|
|
90
|
+
export function describeCodeTime(time, classUs) {
|
|
91
|
+
const verdict = time.codeUs > classUs ? 'OVER its class (a warning)' : 'within its class';
|
|
92
|
+
const parts = [
|
|
93
|
+
`nextest-code-bound: code ${seconds(time.codeUs)} of ${seconds(classUs)}, ${verdict}`,
|
|
94
|
+
`(wall ${seconds(time.wallUs)} less ${seconds(time.waitUs)} waiting for the host disk lease over ${time.waits} waits)`,
|
|
95
|
+
];
|
|
96
|
+
for (const wait of time.open) {
|
|
97
|
+
parts.push(`; pid ${wait.pid}'s wait ${wait.seq} never ended and counts to the test's end`);
|
|
98
|
+
}
|
|
99
|
+
if (time.strayEnds > 0) {
|
|
100
|
+
parts.push(`; ${time.strayEnds} wait ends had no recorded start and count as code time`);
|
|
101
|
+
}
|
|
102
|
+
return parts.join(' ');
|
|
103
|
+
}
|
|
104
|
+
const CLASS_PATTERN = /^\d+(\.\d+)?$/;
|
|
105
|
+
/** The signals the wrapper passes on to the test rather than dying of. */
|
|
106
|
+
const FORWARDED = ['SIGTERM', 'SIGINT', 'SIGHUP'];
|
|
107
|
+
/** Runs the test under the record, reports its code time, and exits as the test did. */
|
|
108
|
+
async function main(argv) {
|
|
109
|
+
const [codeClass, binary, ...args] = argv;
|
|
110
|
+
if (codeClass === undefined || !CLASS_PATTERN.test(codeClass) || Number(codeClass) <= 0 || binary === undefined) {
|
|
111
|
+
process.stderr.write('nextest-code-bound: usage: nextest-code-bound.ts <class-seconds> <test-binary> [args…]\n');
|
|
112
|
+
process.exit(2);
|
|
113
|
+
}
|
|
114
|
+
const classUs = Number(codeClass) * 1_000_000;
|
|
115
|
+
const record = join(tmpdir(), `cowshed-lease-waits-${process.pid}-${randomUUID()}`);
|
|
116
|
+
writeFileSync(record, '', { mode: 0o600, flag: 'wx' });
|
|
117
|
+
const startedUs = Math.round((performance.timeOrigin + performance.now()) * 1000);
|
|
118
|
+
const child = spawn(binary, args, { stdio: 'inherit', env: { ...process.env, [LEASE_WAIT_RECORD_ENV]: record } });
|
|
119
|
+
// nextest stops a test by signalling its process group, which the child is in; the wrapper stays
|
|
120
|
+
// to report what the stopped test spent, and passes on a signal sent to it alone.
|
|
121
|
+
const handlers = FORWARDED.map((signal) => {
|
|
122
|
+
const handler = () => {
|
|
123
|
+
child.kill(signal);
|
|
124
|
+
};
|
|
125
|
+
process.on(signal, handler);
|
|
126
|
+
return { signal, handler };
|
|
127
|
+
});
|
|
128
|
+
const exit = await new Promise((settle) => {
|
|
129
|
+
child.once('error', (error) => {
|
|
130
|
+
process.stderr.write(`nextest-code-bound: could not start ${binary}: ${error.message}\n`);
|
|
131
|
+
settle({ code: 1, signal: null });
|
|
132
|
+
});
|
|
133
|
+
child.once('exit', (code, signal) => settle({ code, signal }));
|
|
134
|
+
});
|
|
135
|
+
const endedUs = Math.round((performance.timeOrigin + performance.now()) * 1000);
|
|
136
|
+
for (const { signal, handler } of handlers) {
|
|
137
|
+
process.removeListener(signal, handler);
|
|
138
|
+
}
|
|
139
|
+
const parsed = parseWaitRecord(readFileSync(record, 'utf8'));
|
|
140
|
+
rmSync(record, { force: true });
|
|
141
|
+
if (!parsed.ok) {
|
|
142
|
+
process.stderr.write(`nextest-code-bound: the lease-wait record ${record} is unreadable: ${parsed.error}\n`);
|
|
143
|
+
process.exit(exit.code === 0 ? 1 : (exit.code ?? 1));
|
|
144
|
+
}
|
|
145
|
+
const time = codeTime(parsed.edges, startedUs, endedUs);
|
|
146
|
+
process.stderr.write(`${describeCodeTime(time, classUs)}\n`);
|
|
147
|
+
if (exit.signal !== null) {
|
|
148
|
+
process.kill(process.pid, exit.signal);
|
|
149
|
+
}
|
|
150
|
+
process.exit(exit.code ?? 1);
|
|
151
|
+
}
|
|
152
|
+
if (process.argv[1] !== undefined && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
153
|
+
await main(process.argv.slice(2));
|
|
154
|
+
}
|
|
@@ -56,9 +56,18 @@ export interface NextestExtractionTiming {
|
|
|
56
56
|
/** The SHA-256 of the archive's bytes: the only identity an extraction is ever looked up by. */
|
|
57
57
|
export declare function nextestArchiveKey(archive: string): Promise<string>;
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
59
|
+
* The directory, inside the Cargo target directory, that holds a workspace's
|
|
60
|
+
* archive extractions. An extraction is content-keyed per-checkout tool state
|
|
61
|
+
* of the same kind as the rest of the target directory: rebuilt from an Nx
|
|
62
|
+
* output, reused by the next run, never an Nx output itself. It therefore lives
|
|
63
|
+
* wherever Cargo's build tree lives, which a checkout that keeps its build state
|
|
64
|
+
* on its own volume already keeps off its source tree.
|
|
65
|
+
*/
|
|
66
|
+
export declare const NEXTEST_EXTRACTION_DIRECTORY = "nextest-extracted";
|
|
67
|
+
/**
|
|
68
|
+
* A workspace's extractions live under one root, each under the hash of the
|
|
69
|
+
* bytes it came from; the lock and staging directories of a key carry that key
|
|
70
|
+
* as their prefix, so cleanup can tell them from another key's.
|
|
62
71
|
*/
|
|
63
72
|
export interface NextestExtractionPaths {
|
|
64
73
|
root: string;
|
|
@@ -66,10 +75,17 @@ export interface NextestExtractionPaths {
|
|
|
66
75
|
lock: string;
|
|
67
76
|
stagingPrefix: string;
|
|
68
77
|
}
|
|
69
|
-
export declare function nextestExtractionPaths(
|
|
78
|
+
export declare function nextestExtractionPaths(root: string, key: string): NextestExtractionPaths;
|
|
79
|
+
/**
|
|
80
|
+
* The extraction root of the Cargo workspace in `cwd`:
|
|
81
|
+
* `<target_directory>/nextest-extracted`, with the target directory Cargo itself
|
|
82
|
+
* reports, so a `build.target-dir` in the repository's Cargo config is honoured
|
|
83
|
+
* exactly as every build of the workspace honours it.
|
|
84
|
+
*/
|
|
85
|
+
export declare function nextestExtractionRoot(cwd: string): Promise<string>;
|
|
70
86
|
/**
|
|
71
|
-
* The directory holding `archive`'s extraction, extracting it
|
|
72
|
-
* caller has yet.
|
|
87
|
+
* The directory under `root` holding `archive`'s extraction, extracting it
|
|
88
|
+
* first if no caller has yet.
|
|
73
89
|
*
|
|
74
90
|
* Correctness does not rest on the lock. An extraction lands under the hash of
|
|
75
91
|
* the bytes it came from by renaming a private staging directory into place,
|
|
@@ -80,12 +96,12 @@ export declare function nextestExtractionPaths(archive: string, key: string): Ne
|
|
|
80
96
|
* runner of one Nx run from unpacking the same bytes side by side, which is the
|
|
81
97
|
* cost it exists to remove.
|
|
82
98
|
*
|
|
83
|
-
* Publishing a key removes every other key's extraction
|
|
99
|
+
* Publishing a key removes every other key's extraction under `root`,
|
|
84
100
|
* including stale locks and staging left by a holder that died. Leftovers of
|
|
85
101
|
* the CURRENT key are not touched: a holder that took over a stale lock may
|
|
86
102
|
* still be extracting into one.
|
|
87
103
|
*/
|
|
88
|
-
export declare function ensureNextestArchiveExtracted(archive: string, extract: NextestArchiveExtractor, onEvent: (event: NextestExtractionEvent) => void, timing?: NextestExtractionTiming): Promise<NextestExtraction>;
|
|
104
|
+
export declare function ensureNextestArchiveExtracted(archive: string, root: string, extract: NextestArchiveExtractor, onEvent: (event: NextestExtractionEvent) => void, timing?: NextestExtractionTiming): Promise<NextestExtraction>;
|
|
89
105
|
/**
|
|
90
106
|
* nextest's own extractor: `nextest list --list-type binaries-only` unpacks the
|
|
91
107
|
* archive and executes nothing from it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nextest-extraction.d.ts","sourceRoot":"","sources":["../src/nextest-extraction.ts"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,6EAA6E,CAAC;AAE9G;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAC7C,eAAO,MAAM,2BAA2B,0CAA0C,CAAC;AACnF,eAAO,MAAM,wBAAwB,uCAAuC,CAAC;AAE7E,0EAA0E;AAC1E,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE9F,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACxE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3F,0EAA0E;AAC1E,MAAM,MAAM,sBAAsB,GAC9B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB;AAID,gGAAgG;AAChG,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAMxE;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,sBAAsB,CAAC,
|
|
1
|
+
{"version":3,"file":"nextest-extraction.d.ts","sourceRoot":"","sources":["../src/nextest-extraction.ts"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,6EAA6E,CAAC;AAE9G;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAC7C,eAAO,MAAM,2BAA2B,0CAA0C,CAAC;AACnF,eAAO,MAAM,wBAAwB,uCAAuC,CAAC;AAE7E,0EAA0E;AAC1E,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE9F,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACxE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3F,0EAA0E;AAC1E,MAAM,MAAM,sBAAsB,GAC9B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB;AAID,gGAAgG;AAChG,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAMxE;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B,sBAAsB,CAAC;AAEhE;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,sBAAsB,CAOxF;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAaxE;AAaD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,EAChD,MAAM,GAAE,uBAAwC,GAC/C,OAAO,CAAC,iBAAiB,CAAC,CAiD5B;AA4GD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,EAAE,uBAiChC,CAAC"}
|
|
@@ -31,8 +31,16 @@ export async function nextestArchiveKey(archive) {
|
|
|
31
31
|
}
|
|
32
32
|
return hash.digest('hex');
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
/**
|
|
35
|
+
* The directory, inside the Cargo target directory, that holds a workspace's
|
|
36
|
+
* archive extractions. An extraction is content-keyed per-checkout tool state
|
|
37
|
+
* of the same kind as the rest of the target directory: rebuilt from an Nx
|
|
38
|
+
* output, reused by the next run, never an Nx output itself. It therefore lives
|
|
39
|
+
* wherever Cargo's build tree lives, which a checkout that keeps its build state
|
|
40
|
+
* on its own volume already keeps off its source tree.
|
|
41
|
+
*/
|
|
42
|
+
export const NEXTEST_EXTRACTION_DIRECTORY = 'nextest-extracted';
|
|
43
|
+
export function nextestExtractionPaths(root, key) {
|
|
36
44
|
return {
|
|
37
45
|
root,
|
|
38
46
|
directory: join(root, key),
|
|
@@ -41,8 +49,35 @@ export function nextestExtractionPaths(archive, key) {
|
|
|
41
49
|
};
|
|
42
50
|
}
|
|
43
51
|
/**
|
|
44
|
-
* The
|
|
45
|
-
*
|
|
52
|
+
* The extraction root of the Cargo workspace in `cwd`:
|
|
53
|
+
* `<target_directory>/nextest-extracted`, with the target directory Cargo itself
|
|
54
|
+
* reports, so a `build.target-dir` in the repository's Cargo config is honoured
|
|
55
|
+
* exactly as every build of the workspace honours it.
|
|
56
|
+
*/
|
|
57
|
+
export async function nextestExtractionRoot(cwd) {
|
|
58
|
+
const args = ['--frozen', 'metadata', '--no-deps', '--format-version', '1'];
|
|
59
|
+
const child = spawn('cargo', args, { cwd, stdio: ['ignore', 'pipe', 'inherit'] });
|
|
60
|
+
const chunks = [];
|
|
61
|
+
child.stdout.on('data', (chunk) => chunks.push(chunk));
|
|
62
|
+
// 'close', not 'exit': stdout may still hold unread metadata when the process exits.
|
|
63
|
+
const [code, signal] = await once(child, 'close');
|
|
64
|
+
if (code !== 0) {
|
|
65
|
+
throw new Error(`cargo ${args.join(' ')} ${code === null ? `died of ${String(signal)}` : `exited with status ${String(code)}`}`);
|
|
66
|
+
}
|
|
67
|
+
return join(cargoTargetDirectory(Buffer.concat(chunks).toString('utf8')), NEXTEST_EXTRACTION_DIRECTORY);
|
|
68
|
+
}
|
|
69
|
+
/** `target_directory` from `cargo metadata --format-version 1` output. */
|
|
70
|
+
function cargoTargetDirectory(metadata) {
|
|
71
|
+
const parsed = JSON.parse(metadata);
|
|
72
|
+
const directory = typeof parsed === 'object' && parsed !== null && 'target_directory' in parsed ? parsed.target_directory : undefined;
|
|
73
|
+
if (typeof directory !== 'string' || directory.length === 0) {
|
|
74
|
+
throw new Error('cargo metadata named no target_directory');
|
|
75
|
+
}
|
|
76
|
+
return directory;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The directory under `root` holding `archive`'s extraction, extracting it
|
|
80
|
+
* first if no caller has yet.
|
|
46
81
|
*
|
|
47
82
|
* Correctness does not rest on the lock. An extraction lands under the hash of
|
|
48
83
|
* the bytes it came from by renaming a private staging directory into place,
|
|
@@ -53,15 +88,15 @@ export function nextestExtractionPaths(archive, key) {
|
|
|
53
88
|
* runner of one Nx run from unpacking the same bytes side by side, which is the
|
|
54
89
|
* cost it exists to remove.
|
|
55
90
|
*
|
|
56
|
-
* Publishing a key removes every other key's extraction
|
|
91
|
+
* Publishing a key removes every other key's extraction under `root`,
|
|
57
92
|
* including stale locks and staging left by a holder that died. Leftovers of
|
|
58
93
|
* the CURRENT key are not touched: a holder that took over a stale lock may
|
|
59
94
|
* still be extracting into one.
|
|
60
95
|
*/
|
|
61
|
-
export async function ensureNextestArchiveExtracted(archive, extract, onEvent, timing = DEFAULT_TIMING) {
|
|
96
|
+
export async function ensureNextestArchiveExtracted(archive, root, extract, onEvent, timing = DEFAULT_TIMING) {
|
|
62
97
|
const started = performance.now();
|
|
63
98
|
const key = await nextestArchiveKey(archive);
|
|
64
|
-
const paths = nextestExtractionPaths(
|
|
99
|
+
const paths = nextestExtractionPaths(root, key);
|
|
65
100
|
if (await isDirectory(paths.directory)) {
|
|
66
101
|
return { kind: 'reused', key, directory: paths.directory };
|
|
67
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-target-policy.d.ts","sourceRoot":"","sources":["../src/package-target-policy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAyB,KAAK,IAAI,EAAc,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"package-target-policy.d.ts","sourceRoot":"","sources":["../src/package-target-policy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAyB,KAAK,IAAI,EAAc,MAAM,0BAA0B,CAAC;AAKxF,OAAO,EAML,KAAK,aAAa,EACnB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAChG,YAAY,EAAE,aAAa,EAAE,CAAC;AAE9B,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7B,kBAAkB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;IAC5D,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACvE,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C;AAED,MAAM,WAAW,0BAA0B;IACzC,wBAAwB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,sBAAsB,CAAC,CAAC;CAC9F;AAsHD,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI,CAGhF;AAoND,wBAAgB,UAAU,CACxB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,OAAO,EACnB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GACtB,MAAM,CAMR;AAgoBD;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,0BAA+B,GAAG,aAAa,EAAE,CAsBlH;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,0BAA+B,GAAG,OAAO,CA8B1G;AAwJD,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,WAAW,EAAE,MAAM,EACnB,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,EACrC,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GACjC,aAAa,EAAE,CAEjB;AAED,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,EACnC,OAAO,GAAE;IAAE,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAAC,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAAO,GAC1F,OAAO,CAMT;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,0BAA+B,GAAG,aAAa,EAAE,CAoBhH;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,0BAA+B,GAAG,OAAO,CA8BxG"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { existsSync, readdirSync, readFileSync
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { getProjects, readJson, updateJson } from 'nx/src/devkit-exports.js';
|
|
4
4
|
import { boundedTestScriptAlias } from './bounded-test-policy.js';
|
|
5
|
+
import { writeJsonFile } from './managed-files/managed-format.js';
|
|
5
6
|
import { isNonSourceDirectory } from './source-directories.js';
|
|
6
7
|
import { BUILD_OUTPUT_DEPENDENCIES, isBuildOutputTargetName, isTestRunnerTargetName, LINUX_PLATFORM_TARGET_GLOBS, MACOS_PLATFORM_TARGET_GLOBS, } from './workspace-config-policy.js';
|
|
7
8
|
export { BUILD_OUTPUT_DEPENDENCIES, PLATFORM_TARGET_GLOBS } from './workspace-config-policy.js';
|
|
@@ -51,9 +52,6 @@ function readJsonObject(path) {
|
|
|
51
52
|
const parsed = JSON.parse(readFileSync(path, 'utf8'));
|
|
52
53
|
return isRecord(parsed) ? parsed : null;
|
|
53
54
|
}
|
|
54
|
-
function writeJsonObject(path, value) {
|
|
55
|
-
writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`);
|
|
56
|
-
}
|
|
57
55
|
function listWorkspacePackageJsonPaths(root) {
|
|
58
56
|
const rootPackagePath = join(root, 'package.json');
|
|
59
57
|
if (!existsSync(rootPackagePath)) {
|
|
@@ -1048,7 +1046,7 @@ export function applyPackageTargetPolicy(root, options = {}) {
|
|
|
1048
1046
|
applyPackageScriptPolicyForPkg(pkg, packagePath, workspaceNames, { resolvedTargets: resolvedProject }) ||
|
|
1049
1047
|
packageChanged;
|
|
1050
1048
|
if (packageChanged) {
|
|
1051
|
-
|
|
1049
|
+
writeJsonFile(packageJsonPath, pkg);
|
|
1052
1050
|
changed = true;
|
|
1053
1051
|
}
|
|
1054
1052
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"release-config-policy.d.ts","sourceRoot":"","sources":["../src/release-config-policy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"release-config-policy.d.ts","sourceRoot":"","sources":["../src/release-config-policy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAIrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,eAAO,MAAM,uBAAuB,4CAA4C,CAAC;AACjF;;;;;;GAMG;AACH,eAAO,MAAM,sCAAsC,QAAgC,CAAC;AACpF,eAAO,MAAM,2BAA2B,4BAA4B,CAAC;AAoBrE;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa,EAAE,CAuFnF;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAyC3E;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,IAAI,GAAG,aAAa,EAAE,CAKlE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAU1D;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CAYtE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAW9D"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { existsSync, readFileSync
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import { readJson, updateJson } from 'nx/src/devkit-exports.js';
|
|
5
|
+
import { writeJsonFile } from './managed-files/managed-format.js';
|
|
5
6
|
export const SMOO_NX_VERSION_ACTIONS = '@smoothbricks/nx-plugin/version-actions';
|
|
6
7
|
/**
|
|
7
8
|
* The same module as a workspace path. Nx resolves `versionActions` with
|
|
@@ -201,7 +202,7 @@ export function applyReleaseConfigPolicy(root) {
|
|
|
201
202
|
}
|
|
202
203
|
const changed = applyReleaseConfig(nxJson);
|
|
203
204
|
if (changed) {
|
|
204
|
-
|
|
205
|
+
writeJsonFile(nxJsonPath, nxJson);
|
|
205
206
|
}
|
|
206
207
|
return changed;
|
|
207
208
|
}
|
|
@@ -217,9 +218,6 @@ function readJsonObject(path) {
|
|
|
217
218
|
return null;
|
|
218
219
|
}
|
|
219
220
|
}
|
|
220
|
-
function writeJsonObject(path, value) {
|
|
221
|
-
writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`);
|
|
222
|
-
}
|
|
223
221
|
function isRecord(value) {
|
|
224
222
|
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
225
223
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one script every Nx runtime input runs through, named as the workspace
|
|
3
|
+
* root's `node_modules` links this package: Nx runs runtime inputs from the
|
|
4
|
+
* workspace root. `runtime-input.sh` explains why it exists: Nx hashes a failed
|
|
5
|
+
* input's error text as its value.
|
|
6
|
+
*/
|
|
7
|
+
export declare const RUNTIME_INPUT_SCRIPT = "node_modules/@smoothbricks/nx-plugin/runtime-input.sh";
|
|
8
|
+
/** A runtime input whose failure stops Nx. `command` is shell words, already quoted. */
|
|
9
|
+
export declare function runtimeInput(command: string): {
|
|
10
|
+
runtime: string;
|
|
11
|
+
};
|
|
12
|
+
/** One shell word: bare when nothing in it is special to `sh`, single-quoted otherwise. */
|
|
13
|
+
export declare function shellWord(word: string): string;
|
|
14
|
+
//# sourceMappingURL=runtime-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-input.d.ts","sourceRoot":"","sources":["../src/runtime-input.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,0DAA0D,CAAC;AAE5F,wFAAwF;AACxF,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAEjE;AAED,2FAA2F;AAC3F,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one script every Nx runtime input runs through, named as the workspace
|
|
3
|
+
* root's `node_modules` links this package: Nx runs runtime inputs from the
|
|
4
|
+
* workspace root. `runtime-input.sh` explains why it exists: Nx hashes a failed
|
|
5
|
+
* input's error text as its value.
|
|
6
|
+
*/
|
|
7
|
+
export const RUNTIME_INPUT_SCRIPT = 'node_modules/@smoothbricks/nx-plugin/runtime-input.sh';
|
|
8
|
+
/** A runtime input whose failure stops Nx. `command` is shell words, already quoted. */
|
|
9
|
+
export function runtimeInput(command) {
|
|
10
|
+
return { runtime: `sh ${RUNTIME_INPUT_SCRIPT} ${command}` };
|
|
11
|
+
}
|
|
12
|
+
/** One shell word: bare when nothing in it is special to `sh`, single-quoted otherwise. */
|
|
13
|
+
export function shellWord(word) {
|
|
14
|
+
return /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", `'"'"'`)}'`;
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Tokens shared by Rust input inference and statement comparison. */
|
|
2
|
+
export interface RustToken {
|
|
3
|
+
readonly text: string;
|
|
4
|
+
readonly literal: boolean;
|
|
5
|
+
readonly local: boolean;
|
|
6
|
+
readonly kind: 'ident' | 'literal' | 'punct' | 'lifetime';
|
|
7
|
+
readonly offset: number;
|
|
8
|
+
}
|
|
9
|
+
/** A Rust lexer that keeps exactly what statement comparison needs: idents, literals, lifetimes, punctuation. */
|
|
10
|
+
export declare function rustTokens(text: string): RustToken[];
|
|
11
|
+
//# sourceMappingURL=rust-tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rust-tokens.d.ts","sourceRoot":"","sources":["../src/rust-tokens.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,CAAC;IAC1D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAUD,iHAAiH;AACjH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,CA2DpD"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const RUST_IDENT = /[A-Za-z_][A-Za-z0-9_]*/uy;
|
|
2
|
+
const RUST_NUMBER = /(?:0[xob][0-9A-Fa-f_]+|[0-9][0-9_]*(?:\.[0-9][0-9_]*)?(?:[eE][+-]?[0-9_]+)?)(?:[iuf](?:8|16|32|64|128|size))?/uy;
|
|
3
|
+
const RUST_RAW_STRING = /b?r(#*)"/uy;
|
|
4
|
+
const RUST_CHAR = /b?'(?:\\(?:u\{[0-9A-Fa-f]+\}|x[0-9A-Fa-f]{2}|.)|[^\\'\n])'/uy;
|
|
5
|
+
/** Longest first: `..` is one token, so a range end (`0..5`) is never read as a tuple index after `.`. */
|
|
6
|
+
const RUST_PUNCT = ['..=', '::', '->', '=>', '==', '!=', '<=', '>=', '&&', '||', '..'];
|
|
7
|
+
/** A Rust lexer that keeps exactly what statement comparison needs: idents, literals, lifetimes, punctuation. */
|
|
8
|
+
export function rustTokens(text) {
|
|
9
|
+
const tokens = [];
|
|
10
|
+
let index = 0;
|
|
11
|
+
const at = (pattern) => {
|
|
12
|
+
pattern.lastIndex = index;
|
|
13
|
+
return pattern.exec(text)?.[0];
|
|
14
|
+
};
|
|
15
|
+
const push = (kind, start) => {
|
|
16
|
+
tokens.push({ text: text.slice(start, index), literal: kind === 'literal', local: false, kind, offset: start });
|
|
17
|
+
};
|
|
18
|
+
while (index < text.length) {
|
|
19
|
+
const char = text[index] ?? '';
|
|
20
|
+
const start = index;
|
|
21
|
+
if (/\s/u.test(char))
|
|
22
|
+
index += 1;
|
|
23
|
+
else if (text.startsWith('//', index)) {
|
|
24
|
+
const end = text.indexOf('\n', index);
|
|
25
|
+
index = end === -1 ? text.length : end;
|
|
26
|
+
}
|
|
27
|
+
else if (text.startsWith('/*', index)) {
|
|
28
|
+
let depth = 0;
|
|
29
|
+
do {
|
|
30
|
+
if (text.startsWith('/*', index))
|
|
31
|
+
depth += 1;
|
|
32
|
+
else if (text.startsWith('*/', index))
|
|
33
|
+
depth -= 1;
|
|
34
|
+
index += text.startsWith('/*', index) || text.startsWith('*/', index) ? 2 : 1;
|
|
35
|
+
} while (depth > 0 && index < text.length);
|
|
36
|
+
}
|
|
37
|
+
else if (at(RUST_RAW_STRING) !== undefined) {
|
|
38
|
+
const raw = at(RUST_RAW_STRING) ?? '';
|
|
39
|
+
const close = `"${raw.slice(raw.indexOf('r') + 1, -1)}`;
|
|
40
|
+
const end = text.indexOf(close, index + raw.length);
|
|
41
|
+
index = end === -1 ? text.length : end + close.length;
|
|
42
|
+
push('literal', start);
|
|
43
|
+
}
|
|
44
|
+
else if (char === '"' || (char === 'b' && text[index + 1] === '"')) {
|
|
45
|
+
index += char === 'b' ? 2 : 1;
|
|
46
|
+
while (index < text.length && text[index] !== '"')
|
|
47
|
+
index += text[index] === '\\' ? 2 : 1;
|
|
48
|
+
index += 1;
|
|
49
|
+
push('literal', start);
|
|
50
|
+
}
|
|
51
|
+
else if (at(RUST_CHAR) !== undefined) {
|
|
52
|
+
index += at(RUST_CHAR)?.length ?? 0;
|
|
53
|
+
push('literal', start);
|
|
54
|
+
}
|
|
55
|
+
else if (char === "'") {
|
|
56
|
+
index += 1;
|
|
57
|
+
index += at(RUST_IDENT)?.length ?? 0;
|
|
58
|
+
push('lifetime', start);
|
|
59
|
+
}
|
|
60
|
+
else if (at(RUST_IDENT) !== undefined) {
|
|
61
|
+
const ident = at(RUST_IDENT) ?? '';
|
|
62
|
+
index += ident.length;
|
|
63
|
+
push(ident === 'true' || ident === 'false' ? 'literal' : 'ident', start);
|
|
64
|
+
}
|
|
65
|
+
else if (tokens.at(-1)?.text === '.' && /[0-9]/u.test(char)) {
|
|
66
|
+
// A tuple index (`pair.0.1`) names a field; lexed as a number it would read `0.1` as one float literal.
|
|
67
|
+
while (/[0-9]/u.test(text[index] ?? ''))
|
|
68
|
+
index += 1;
|
|
69
|
+
push('ident', start);
|
|
70
|
+
}
|
|
71
|
+
else if ((at(RUST_NUMBER) ?? '') !== '') {
|
|
72
|
+
index += at(RUST_NUMBER)?.length ?? 0;
|
|
73
|
+
push('literal', start);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
index += RUST_PUNCT.find((punct) => text.startsWith(punct, index))?.length ?? 1;
|
|
77
|
+
push('punct', start);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return tokens;
|
|
81
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PostTasksExecutionContext, PreTasksExecutionContext } from 'nx/src/project-graph/plugins/public-api.js';
|
|
2
|
+
/** A controller-selected hint namespace, not publication authority or a backend credential. */
|
|
3
|
+
export declare const NX_TASK_RECEIPT_ENV = "COWSHED_NX_TASK_RECEIPT_ID";
|
|
4
|
+
export declare function preTasksExecution(_options: unknown, _context: PreTasksExecutionContext): void;
|
|
5
|
+
export declare function postTasksExecution(_options: unknown, context: PostTasksExecutionContext): Promise<void>;
|
|
6
|
+
//# sourceMappingURL=task-results.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-results.d.ts","sourceRoot":"","sources":["../src/task-results.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AAItH,+FAA+F;AAC/F,eAAO,MAAM,mBAAmB,+BAA+B,CAAC;AAsBhE,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,wBAAwB,GAAG,IAAI,CAO7F;AAqBD,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAe7G"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { mkdir, rename, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { cacheDir, logger } from 'nx/src/devkit-exports.js';
|
|
5
|
+
import typia from 'typia';
|
|
6
|
+
/** A controller-selected hint namespace, not publication authority or a backend credential. */
|
|
7
|
+
export const NX_TASK_RECEIPT_ENV = 'COWSHED_NX_TASK_RECEIPT_ID';
|
|
8
|
+
const isRequestId = (() => {
|
|
9
|
+
return input => "string" === typeof input && RegExp("^[0-9a-f]{32}$").test(input);
|
|
10
|
+
})();
|
|
11
|
+
const WRITTEN = { ok: true };
|
|
12
|
+
function requestId() {
|
|
13
|
+
const value = process.env[NX_TASK_RECEIPT_ENV];
|
|
14
|
+
return isRequestId(value) ? value : undefined;
|
|
15
|
+
}
|
|
16
|
+
export function preTasksExecution(_options, _context) {
|
|
17
|
+
const requested = process.env[NX_TASK_RECEIPT_ENV];
|
|
18
|
+
if (requested !== undefined && !isRequestId(requested)) {
|
|
19
|
+
logger.warn(`${NX_TASK_RECEIPT_ENV} is not a controller-selected 32-hex request id; no task hint will be recorded.`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async function writeHint(hint) {
|
|
23
|
+
const directory = join(cacheDir, '.cowshed-task-results', hint.requestId);
|
|
24
|
+
const invocation = createHash('sha256').update(hint.run.id).digest('hex');
|
|
25
|
+
const destination = join(directory, `${invocation}.json`);
|
|
26
|
+
const temporary = join(directory, `.${invocation}-${process.pid}.tmp`);
|
|
27
|
+
const json = JSON.stringify(hint);
|
|
28
|
+
if (Buffer.byteLength(json) > 1024 * 1024) {
|
|
29
|
+
return { ok: false, path: destination, reason: 'task-results hint exceeds the 1 MiB inspection envelope' };
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
await mkdir(directory, { recursive: true, mode: 0o700 });
|
|
33
|
+
await writeFile(temporary, json, { mode: 0o600, flag: 'wx' });
|
|
34
|
+
await rename(temporary, destination);
|
|
35
|
+
return WRITTEN;
|
|
36
|
+
}
|
|
37
|
+
catch (cause) {
|
|
38
|
+
// A leftover temporary makes the private inspector refuse the whole namespace; it can
|
|
39
|
+
// never be mistaken for a successful hint. The workspace's own retirement owns the bytes.
|
|
40
|
+
return { ok: false, path: destination, reason: String(cause) };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export async function postTasksExecution(_options, context) {
|
|
44
|
+
const id = requestId();
|
|
45
|
+
if (id === undefined)
|
|
46
|
+
return;
|
|
47
|
+
const results = Object.values(context.taskResults);
|
|
48
|
+
// Hash-only API inspections pair the hooks too but ran no task; never overwrite real hints.
|
|
49
|
+
if (results.length === 0)
|
|
50
|
+
return;
|
|
51
|
+
const hint = {
|
|
52
|
+
version: 1,
|
|
53
|
+
requestId: id,
|
|
54
|
+
workspaceRoot: context.workspaceRoot,
|
|
55
|
+
run: { id: context.id, argv: context.argv, startTime: context.startTime, endTime: context.endTime },
|
|
56
|
+
tasks: results.map(({ task, status, code }) => ({ task: { id: task.id, hash: task.hash }, status, code })),
|
|
57
|
+
};
|
|
58
|
+
const written = await writeHint(hint);
|
|
59
|
+
if (!written.ok)
|
|
60
|
+
logger.warn(`Cannot record Nx task-results hint ${written.path}: ${written.reason}`);
|
|
61
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Tree } from 'nx/src/devkit-exports.js';
|
|
2
|
+
/**
|
|
3
|
+
* Everything the test typecheck needs to know about one project's files.
|
|
4
|
+
*
|
|
5
|
+
* `tsconfig.test.json` is a program, and a program that selects none of the
|
|
6
|
+
* project's tests passes `tsc --noEmit` by compiling nothing: the gate is green
|
|
7
|
+
* while no test has ever been typechecked. So its `include` has to come from
|
|
8
|
+
* where the tests are, and one that selects none of them has to be reported
|
|
9
|
+
* rather than trusted.
|
|
10
|
+
*/
|
|
11
|
+
export interface TestProgram {
|
|
12
|
+
/** Workspace-relative root of the project: `tooling`, `packages/app`. */
|
|
13
|
+
readonly projectRoot: string;
|
|
14
|
+
/** Project-relative TypeScript sources under the project, outside any build-output tree. */
|
|
15
|
+
readonly files: readonly string[];
|
|
16
|
+
/** A tsconfig by workspace-relative path; null when the file is absent. */
|
|
17
|
+
readonly readConfig: (path: string) => Record<string, unknown> | null;
|
|
18
|
+
}
|
|
19
|
+
/** A directory listing the walker can use: an Nx `Tree`, or the disk behind a small adapter. */
|
|
20
|
+
export type ProjectTree = Pick<Tree, 'children' | 'isFile'>;
|
|
21
|
+
/** Why a test program typechecks none of what it exists to typecheck. */
|
|
22
|
+
export type TestProgramFault = {
|
|
23
|
+
readonly kind: 'no-tests';
|
|
24
|
+
} | {
|
|
25
|
+
readonly kind: 'tests-unselected';
|
|
26
|
+
readonly tests: readonly string[];
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The TypeScript sources of a project, project-relative and sorted.
|
|
30
|
+
*
|
|
31
|
+
* A directory below the project that is a project of its own (its own manifest or Nx project file) is not part of
|
|
32
|
+
* this one: its files are its own tests, found by its own policy pass, and folding them in would count them twice.
|
|
33
|
+
* A directory that merely carries a tsconfig is not that: in a monorepo of Bun programs such a file routes the
|
|
34
|
+
* directory's files to the parent's program (a `tests/tsconfig.json` extending `../tsconfig.test.json`), and
|
|
35
|
+
* nothing typechecks the directory but that program.
|
|
36
|
+
*/
|
|
37
|
+
export declare function listTypeScriptSources(tree: ProjectTree, projectRoot: string): string[];
|
|
38
|
+
/**
|
|
39
|
+
* The globs a test program's `include` must carry, given the `include` it has.
|
|
40
|
+
*
|
|
41
|
+
* A new file, or a package on the `src/` convention, gets the canonical globs
|
|
42
|
+
* (merging them is a no-op when they are there). A project off the convention
|
|
43
|
+
* that wrote an `include` of its own gets a directory's globs only for the
|
|
44
|
+
* directories whose tests that `include` does not already select, so a
|
|
45
|
+
* hand-written include that already names `direnv`'s tests is never followed by four redundant entries.
|
|
46
|
+
*/
|
|
47
|
+
export declare function includeGlobsFor(program: TestProgram, config: Record<string, unknown>, isNew: boolean): string[];
|
|
48
|
+
/**
|
|
49
|
+
* How, if at all, this program typechecks none of what it exists to typecheck:
|
|
50
|
+
* none of the project's tests, or, for a project with no tests at all, no file.
|
|
51
|
+
* Unknowable is not a fault.
|
|
52
|
+
*/
|
|
53
|
+
export declare function testProgramFault(program: TestProgram, config: Record<string, unknown>): TestProgramFault | null;
|
|
54
|
+
//# sourceMappingURL=test-program.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-program.d.ts","sourceRoot":"","sources":["../src/test-program.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGrD;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW;IAC1B,yEAAyE;IACzE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,4FAA4F;IAC5F,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,2EAA2E;IAC3E,QAAQ,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACvE;AAED,gGAAgG;AAChG,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,QAAQ,CAAC,CAAC;AAE5D,yEAAyE;AACzE,MAAM,MAAM,gBAAgB,GACxB;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GAC7B;IAAE,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAsB7E;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CActF;AAwED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAS/G;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,gBAAgB,GAAG,IAAI,CAO/G"}
|