@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.
Files changed (348) hide show
  1. package/README.md +1078 -98
  2. package/dist/bin/smoo-nx-bound-failures.d.ts +3 -0
  3. package/dist/bin/smoo-nx-bound-failures.d.ts.map +1 -0
  4. package/dist/bin/smoo-nx-bound-failures.js +31 -0
  5. package/dist/bin/smoo-nx-cargo-hash.js +28 -3
  6. package/dist/bin/smoo-nx-exec.js +16 -85
  7. package/dist/bin/smoo-nx-failures.d.ts +3 -0
  8. package/dist/bin/smoo-nx-failures.d.ts.map +1 -0
  9. package/dist/bin/smoo-nx-failures.js +3 -0
  10. package/dist/bin/smoo-nx-nextest-extract.js +3 -2
  11. package/dist/bin/smoo-nx-test-walks.d.ts +3 -0
  12. package/dist/bin/smoo-nx-test-walks.d.ts.map +1 -0
  13. package/dist/bin/smoo-nx-test-walks.js +34 -0
  14. package/dist/bounded-test-policy.d.ts +7 -1
  15. package/dist/bounded-test-policy.d.ts.map +1 -1
  16. package/dist/bounded-test-policy.js +101 -40
  17. package/dist/build-state-output-policy.d.ts +25 -0
  18. package/dist/build-state-output-policy.d.ts.map +1 -0
  19. package/dist/build-state-output-policy.js +64 -0
  20. package/dist/cargo-closure-input.d.ts +16 -17
  21. package/dist/cargo-closure-input.d.ts.map +1 -1
  22. package/dist/cargo-closure-input.js +37 -44
  23. package/dist/cargo-dev-profile.d.ts +37 -0
  24. package/dist/cargo-dev-profile.d.ts.map +1 -0
  25. package/dist/cargo-dev-profile.js +108 -0
  26. package/dist/cargo-source-hash.d.ts +50 -8
  27. package/dist/cargo-source-hash.d.ts.map +1 -1
  28. package/dist/cargo-source-hash.js +691 -71
  29. package/dist/cargo-toolchain-policy.d.ts +4 -0
  30. package/dist/cargo-toolchain-policy.d.ts.map +1 -1
  31. package/dist/cargo-toolchain-policy.js +5 -0
  32. package/dist/cargo-workspace.d.ts +108 -12
  33. package/dist/cargo-workspace.d.ts.map +1 -1
  34. package/dist/cargo-workspace.js +299 -18
  35. package/dist/cross-check-policy.d.ts +21 -3
  36. package/dist/cross-check-policy.d.ts.map +1 -1
  37. package/dist/cross-check-policy.js +24 -6
  38. package/dist/disk-command-policy.d.ts +7 -0
  39. package/dist/disk-command-policy.d.ts.map +1 -0
  40. package/dist/disk-command-policy.js +98 -0
  41. package/dist/ensure-built-receipt.d.ts +25 -0
  42. package/dist/ensure-built-receipt.d.ts.map +1 -0
  43. package/dist/ensure-built-receipt.js +261 -0
  44. package/dist/ensure-built-witness.d.ts +57 -0
  45. package/dist/ensure-built-witness.d.ts.map +1 -0
  46. package/dist/ensure-built-witness.js +412 -0
  47. package/dist/ensure-built.d.ts +213 -12
  48. package/dist/ensure-built.d.ts.map +1 -1
  49. package/dist/ensure-built.js +624 -177
  50. package/dist/eslint-file-set.d.ts +7 -0
  51. package/dist/eslint-file-set.d.ts.map +1 -0
  52. package/dist/eslint-file-set.js +12 -0
  53. package/dist/executors/bounded-exec/cpu-pool.d.ts +63 -0
  54. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -0
  55. package/dist/executors/bounded-exec/cpu-pool.js +379 -0
  56. package/dist/executors/bounded-exec/cpu-tokens.d.ts +82 -0
  57. package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +1 -0
  58. package/dist/executors/bounded-exec/cpu-tokens.js +114 -0
  59. package/dist/executors/bounded-exec/disk-lease.d.ts +61 -0
  60. package/dist/executors/bounded-exec/disk-lease.d.ts.map +1 -0
  61. package/dist/executors/bounded-exec/disk-lease.js +91 -0
  62. package/dist/executors/bounded-exec/executor.d.ts +45 -2
  63. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  64. package/dist/executors/bounded-exec/executor.js +447 -52
  65. package/dist/executors/bounded-exec/gateway-lease.d.ts +52 -0
  66. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -0
  67. package/dist/executors/bounded-exec/gateway-lease.js +143 -0
  68. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +35 -0
  69. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -0
  70. package/dist/executors/bounded-exec/hang-diagnostics.js +231 -0
  71. package/dist/executors/bounded-exec/progress.d.ts +35 -0
  72. package/dist/executors/bounded-exec/progress.d.ts.map +1 -0
  73. package/dist/executors/bounded-exec/progress.js +79 -0
  74. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +3 -0
  75. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -0
  76. package/dist/executors/bounded-exec/ram-temp-fixtures.js +12 -0
  77. package/dist/executors/bounded-exec/ram-temp-held.d.ts +91 -0
  78. package/dist/executors/bounded-exec/ram-temp-held.d.ts.map +1 -0
  79. package/dist/executors/bounded-exec/ram-temp-held.js +152 -0
  80. package/dist/executors/bounded-exec/ram-temp.d.ts +223 -0
  81. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -0
  82. package/dist/executors/bounded-exec/ram-temp.js +1528 -0
  83. package/dist/executors/bounded-exec/schema.d.ts +29 -11
  84. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  85. package/dist/executors/bounded-exec/verdict.d.ts +162 -0
  86. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -0
  87. package/dist/executors/bounded-exec/verdict.js +318 -0
  88. package/dist/executors/shard-timings/executor.d.ts +14 -0
  89. package/dist/executors/shard-timings/executor.d.ts.map +1 -0
  90. package/dist/executors/shard-timings/executor.js +25 -0
  91. package/dist/executors/shard-timings/schema.d.ts +4 -0
  92. package/dist/executors/shard-timings/schema.d.ts.map +1 -0
  93. package/dist/executors/shard-timings/schema.js +1 -0
  94. package/dist/failure-summary.d.ts +5 -0
  95. package/dist/failure-summary.d.ts.map +1 -0
  96. package/dist/failure-summary.js +118 -0
  97. package/dist/generators/create-package/generator.d.ts.map +1 -1
  98. package/dist/generators/create-package/generator.js +6 -2
  99. package/dist/index.d.ts +14 -2
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +435 -230
  102. package/dist/managed-assets.d.ts +6 -0
  103. package/dist/managed-assets.d.ts.map +1 -1
  104. package/dist/managed-files/ci-workflow.d.ts +13 -0
  105. package/dist/managed-files/ci-workflow.d.ts.map +1 -1
  106. package/dist/managed-files/ci-workflow.js +44 -13
  107. package/dist/managed-files/files.d.ts +7 -1
  108. package/dist/managed-files/files.d.ts.map +1 -1
  109. package/dist/managed-files/files.js +62 -8
  110. package/dist/managed-files/json-edit.d.ts +21 -0
  111. package/dist/managed-files/json-edit.d.ts.map +1 -0
  112. package/dist/managed-files/json-edit.js +295 -0
  113. package/dist/managed-files/managed-format.d.ts +33 -1
  114. package/dist/managed-files/managed-format.d.ts.map +1 -1
  115. package/dist/managed-files/managed-format.js +82 -2
  116. package/dist/managed-files/pr-preview-cleanup-workflow.d.ts +7 -0
  117. package/dist/managed-files/pr-preview-cleanup-workflow.d.ts.map +1 -1
  118. package/dist/managed-files/pr-preview-cleanup-workflow.js +68 -4
  119. package/dist/managed-files/publish-workflow.d.ts.map +1 -1
  120. package/dist/managed-files/publish-workflow.js +231 -48
  121. package/dist/managed-files/tree.d.ts +5 -0
  122. package/dist/managed-files/tree.d.ts.map +1 -1
  123. package/dist/managed-files/tree.js +5 -3
  124. package/dist/manifest-hash.js +3 -2
  125. package/dist/nextest-code-bound.d.ts +62 -0
  126. package/dist/nextest-code-bound.d.ts.map +1 -0
  127. package/dist/nextest-code-bound.js +154 -0
  128. package/dist/nextest-extraction.d.ts +24 -8
  129. package/dist/nextest-extraction.d.ts.map +1 -1
  130. package/dist/nextest-extraction.js +42 -7
  131. package/dist/package-target-policy.d.ts.map +1 -1
  132. package/dist/package-target-policy.js +3 -5
  133. package/dist/release-config-policy.d.ts.map +1 -1
  134. package/dist/release-config-policy.js +3 -5
  135. package/dist/runtime-input.d.ts +14 -0
  136. package/dist/runtime-input.d.ts.map +1 -0
  137. package/dist/runtime-input.js +15 -0
  138. package/dist/rust-tokens.d.ts +11 -0
  139. package/dist/rust-tokens.d.ts.map +1 -0
  140. package/dist/rust-tokens.js +81 -0
  141. package/dist/task-results.d.ts +6 -0
  142. package/dist/task-results.d.ts.map +1 -0
  143. package/dist/task-results.js +61 -0
  144. package/dist/test-program.d.ts +54 -0
  145. package/dist/test-program.d.ts.map +1 -0
  146. package/dist/test-program.js +292 -0
  147. package/dist/test-timings.d.ts +71 -0
  148. package/dist/test-timings.d.ts.map +1 -0
  149. package/dist/test-timings.js +393 -0
  150. package/dist/test-walk-policy.d.ts +103 -0
  151. package/dist/test-walk-policy.d.ts.map +1 -0
  152. package/dist/test-walk-policy.js +657 -0
  153. package/dist/testing.d.ts +177 -0
  154. package/dist/testing.d.ts.map +1 -0
  155. package/dist/testing.js +824 -0
  156. package/dist/type-guards.d.ts +3 -0
  157. package/dist/type-guards.d.ts.map +1 -0
  158. package/dist/type-guards.js +4 -0
  159. package/dist/typecheck-test-policy.d.ts +8 -5
  160. package/dist/typecheck-test-policy.d.ts.map +1 -1
  161. package/dist/typecheck-test-policy.js +113 -100
  162. package/dist/workspace-config-policy.d.ts +8 -0
  163. package/dist/workspace-config-policy.d.ts.map +1 -1
  164. package/dist/workspace-config-policy.js +175 -63
  165. package/dist/workspace-index.d.ts +12 -0
  166. package/dist/workspace-index.d.ts.map +1 -0
  167. package/dist/workspace-index.js +17 -0
  168. package/dist/workspace-manifest.d.ts +37 -1
  169. package/dist/workspace-manifest.d.ts.map +1 -1
  170. package/executors.json +5 -0
  171. package/loader.js +13 -11
  172. package/managed/raw/envrc +33 -62
  173. package/managed/raw/git-format-staged.yml +30 -35
  174. package/managed/raw/patches/nx@23.2.1.patch +3484 -0
  175. package/managed/raw/tooling/direnv/apple-developer.sh +83 -0
  176. package/managed/raw/tooling/direnv/developer-links.ts +607 -17
  177. package/managed/raw/tooling/direnv/devenv.smoo.nix +314 -92
  178. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -11
  179. package/managed/raw/tooling/direnv/linked-snapshots.ts +845 -0
  180. package/managed/raw/tooling/direnv/nx-socket-dir.sh +82 -0
  181. package/managed/raw/tooling/direnv/repo-path +14 -2
  182. package/managed/raw/tooling/direnv/setup-environment.ts +1009 -118
  183. package/managed/raw/tooling/direnv/toolchain-stamp.ts +45 -3
  184. package/managed/raw/tooling/direnv/ttsc-env.sh +39 -0
  185. package/managed/raw/tooling/git-hooks/commit-msg.sh +5 -6
  186. package/managed/raw/tooling/git-hooks/pre-commit.sh +7 -6
  187. package/managed/raw/tooling/git-hooks/pre-push.sh +20 -15
  188. package/managed/templates/github/actions/cache-nix-devenv/action.yml +6 -6
  189. package/managed/templates/github/actions/cache-node-modules/action.yml +6 -4
  190. package/managed/templates/github/actions/cache-nx/action.yml +1 -1
  191. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +1 -1
  192. package/managed/templates/github/actions/forgejo-artifact.cjs +99 -0
  193. package/managed/templates/github/actions/forgejo-download-artifact/action.yml +49 -0
  194. package/managed/templates/github/actions/forgejo-download-artifact/index.cjs +7 -0
  195. package/managed/templates/github/actions/forgejo-upload-artifact/action.yml +65 -0
  196. package/managed/templates/github/actions/forgejo-upload-artifact/index.cjs +7 -0
  197. package/managed/templates/github/actions/setup-devenv/action.yml +21 -3
  198. package/managed/templates/github/workflows/managed-files.yml +1 -2
  199. package/nextest.toml +8 -75
  200. package/package.json +75 -13
  201. package/runtime-input.sh +81 -0
  202. package/src/__tests__/counted-cargo-process.ts +286 -0
  203. package/src/__tests__/counted-cargo.ts +730 -0
  204. package/src/__tests__/fixture-cargo-home.ts +36 -0
  205. package/src/__tests__/fixture-nx-env.ts +157 -2
  206. package/src/__tests__/progress-clock.ts +43 -0
  207. package/src/__tests__/runtime-input.ts +23 -0
  208. package/src/bin/smoo-nx-bound-failures.test.ts +127 -0
  209. package/src/bin/smoo-nx-bound-failures.ts +33 -0
  210. package/src/bin/smoo-nx-cargo-hash.ts +28 -3
  211. package/src/bin/smoo-nx-exec.ts +17 -86
  212. package/src/bin/smoo-nx-failures.ts +4 -0
  213. package/src/bin/smoo-nx-nextest-extract.ts +3 -2
  214. package/src/bin/smoo-nx-test-walks.ts +42 -0
  215. package/src/bounded-test-policy.test.ts +268 -22
  216. package/src/bounded-test-policy.ts +114 -42
  217. package/src/build-state-output-policy.test.ts +115 -0
  218. package/src/build-state-output-policy.ts +90 -0
  219. package/src/bun-bootstrap.test.ts +57 -3
  220. package/src/bun-file-packages.test.ts +47 -0
  221. package/src/cargo-closure-input.test.ts +432 -62
  222. package/src/cargo-closure-input.ts +51 -57
  223. package/src/cargo-dev-profile.ts +137 -0
  224. package/src/cargo-resolve-cache.test.ts +1044 -0
  225. package/src/cargo-source-hash.test.ts +203 -93
  226. package/src/cargo-source-hash.ts +762 -75
  227. package/src/cargo-toolchain-policy.ts +6 -0
  228. package/src/cargo-workspace.test.ts +320 -0
  229. package/src/cargo-workspace.ts +344 -18
  230. package/src/cross-check-policy.test.ts +59 -1
  231. package/src/cross-check-policy.ts +25 -6
  232. package/src/disk-command-policy.test.ts +61 -0
  233. package/src/disk-command-policy.ts +107 -0
  234. package/src/ensure-built-receipt.test.ts +184 -0
  235. package/src/ensure-built-receipt.ts +263 -0
  236. package/src/ensure-built-witness.test.ts +344 -0
  237. package/src/ensure-built-witness.ts +252 -0
  238. package/src/ensure-built.test.ts +1043 -483
  239. package/src/ensure-built.ts +870 -197
  240. package/src/eslint-file-set.ts +9 -0
  241. package/src/executors/bounded-exec/cpu-pool.test.ts +454 -0
  242. package/src/executors/bounded-exec/cpu-pool.ts +417 -0
  243. package/src/executors/bounded-exec/cpu-tokens.test.ts +269 -0
  244. package/src/executors/bounded-exec/cpu-tokens.ts +177 -0
  245. package/src/executors/bounded-exec/disk-lease.test.ts +185 -0
  246. package/src/executors/bounded-exec/disk-lease.ts +139 -0
  247. package/src/executors/bounded-exec/executor-host.test.ts +778 -0
  248. package/src/executors/bounded-exec/executor.test.ts +1116 -63
  249. package/src/executors/bounded-exec/executor.ts +565 -67
  250. package/src/executors/bounded-exec/gateway-lease.ts +176 -0
  251. package/src/executors/bounded-exec/hang-diagnostics.test.ts +285 -0
  252. package/src/executors/bounded-exec/hang-diagnostics.ts +283 -0
  253. package/src/executors/bounded-exec/progress.test.ts +79 -0
  254. package/src/executors/bounded-exec/progress.ts +118 -0
  255. package/src/executors/bounded-exec/ram-temp-fixtures.ts +12 -0
  256. package/src/executors/bounded-exec/ram-temp-held.test.ts +264 -0
  257. package/src/executors/bounded-exec/ram-temp-held.ts +242 -0
  258. package/src/executors/bounded-exec/ram-temp-host.test.ts +605 -0
  259. package/src/executors/bounded-exec/ram-temp.test.ts +674 -0
  260. package/src/executors/bounded-exec/ram-temp.ts +1918 -0
  261. package/src/executors/bounded-exec/schema.json +11 -5
  262. package/src/executors/bounded-exec/schema.ts +27 -11
  263. package/src/executors/bounded-exec/verdict.test.ts +440 -0
  264. package/src/executors/bounded-exec/verdict.ts +433 -0
  265. package/src/executors/shard-timings/executor.ts +36 -0
  266. package/src/executors/shard-timings/schema.json +21 -0
  267. package/src/executors/shard-timings/schema.ts +4 -0
  268. package/src/failure-summary.ts +119 -0
  269. package/src/generators/bounded-test-targets/generator.test.ts +4 -4
  270. package/src/generators/bun-test-tracing/generator.test.ts +2 -2
  271. package/src/generators/create-package/generator.test.ts +6 -0
  272. package/src/generators/create-package/generator.ts +6 -2
  273. package/src/host-controller-wiring.test.ts +31 -0
  274. package/src/index.test.ts +1070 -360
  275. package/src/index.ts +524 -255
  276. package/src/linked-snapshots.nx.test.ts +172 -0
  277. package/src/managed-assets.ts +12 -0
  278. package/src/managed-files/ci-workflow.ts +54 -13
  279. package/src/managed-files/files.ts +65 -9
  280. package/src/managed-files/forgejo-artifact.test.ts +395 -0
  281. package/src/managed-files/generator.test.ts +60 -1
  282. package/src/managed-files/json-edit.test.ts +216 -0
  283. package/src/managed-files/json-edit.ts +290 -0
  284. package/src/managed-files/managed-format-json.test.ts +308 -0
  285. package/src/managed-files/managed-format.ts +90 -2
  286. package/src/managed-files/pr-preview-cleanup-workflow.ts +69 -3
  287. package/src/managed-files/publish-workflow.ts +285 -67
  288. package/src/managed-files/repo-path.test.ts +129 -0
  289. package/src/managed-files/trace-db-artifact.test.ts +7 -0
  290. package/src/managed-files/tree.ts +11 -3
  291. package/src/manifest-hash.ts +3 -2
  292. package/src/nextest-code-bound.test.ts +155 -0
  293. package/src/nextest-code-bound.ts +195 -0
  294. package/src/nextest-extraction.test.ts +37 -5
  295. package/src/nextest-extraction.ts +51 -9
  296. package/src/nextest-partitions.test.ts +495 -0
  297. package/src/nx-cache-bound.test.ts +109 -0
  298. package/src/nx-cache-restore-mtime.test.ts +170 -0
  299. package/src/nx-daemon-claim.test.ts +277 -0
  300. package/src/nx-daemon-idle-cpu.test.ts +81 -0
  301. package/src/nx-daemon-idle-policy.test.ts +51 -0
  302. package/src/nx-daemon-ignore-files.test.ts +210 -0
  303. package/src/nx-daemon-root-normalization.test.ts +105 -0
  304. package/src/nx-daemon-validity.test.ts +925 -0
  305. package/src/nx-dot-input-policy.test.ts +353 -0
  306. package/src/nx-failure-life-cycles.test.ts +207 -0
  307. package/src/nx-files-archive-racy.test.ts +97 -0
  308. package/src/nx-foreign-workspace-env.test.ts +329 -0
  309. package/src/nx-incomplete-run-summary.test.ts +70 -0
  310. package/src/nx-plugin-load-errors.test.ts +120 -0
  311. package/src/nx-project-resolution-cache.test.ts +176 -0
  312. package/src/nx-raw-inputs.test.ts +166 -0
  313. package/src/nx-resident-graph-workers.test.ts +112 -0
  314. package/src/nx-run-information.test.ts +118 -0
  315. package/src/nx-skipped-task-exit.test.ts +180 -0
  316. package/src/nx-state-location.test.ts +63 -0
  317. package/src/nx-store-resolution.test.ts +99 -0
  318. package/src/nx-task-graph-cycles.test.ts +148 -0
  319. package/src/nx-task-output-lease.test.ts +414 -0
  320. package/src/nx-use-local.test.ts +103 -0
  321. package/src/package-target-policy.ts +3 -6
  322. package/src/release-config-policy.ts +3 -6
  323. package/src/runtime-input.test.ts +215 -0
  324. package/src/runtime-input.ts +17 -0
  325. package/src/rust-tokens.ts +78 -0
  326. package/src/serial-group-wiring.test.ts +326 -0
  327. package/src/task-history-namespace.test.ts +181 -0
  328. package/src/task-results.test.ts +226 -0
  329. package/src/task-results.ts +75 -0
  330. package/src/test-program.test.ts +303 -0
  331. package/src/test-program.ts +341 -0
  332. package/src/test-timings.test.ts +240 -0
  333. package/src/test-timings.ts +311 -0
  334. package/src/test-walk-policy.test.ts +585 -0
  335. package/src/test-walk-policy.ts +731 -0
  336. package/src/testing.test.ts +509 -0
  337. package/src/testing.ts +922 -0
  338. package/src/type-guards.ts +4 -0
  339. package/src/typecheck-test-policy.test.ts +496 -11
  340. package/src/typecheck-test-policy.ts +137 -103
  341. package/src/workspace-config-policy.test.ts +212 -13
  342. package/src/workspace-config-policy.ts +101 -73
  343. package/src/workspace-index.ts +18 -0
  344. package/src/workspace-manifest.ts +41 -1
  345. package/test-timings.json +85 -28
  346. package/managed/raw/tooling/direnv/inherited-devenv.ts +0 -615
  347. package/managed/raw/tooling/direnv/shared-caches.sh +0 -53
  348. package/src/__tests__/in-process-nx-index.ts +0 -9
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { existsSync, realpathSync } from 'node:fs';
2
2
  import { readdir, readFile } from 'node:fs/promises';
3
3
  import { createRequire } from 'node:module';
4
- import { dirname, isAbsolute, join, posix, relative, resolve } from 'node:path';
4
+ import { dirname, isAbsolute, join, posix, relative, resolve, sep } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
 
7
7
  import {
@@ -13,8 +13,9 @@ import {
13
13
  } from 'nx/src/devkit-exports.js';
14
14
  import { AggregateCreateNodesError } from 'nx/src/project-graph/error-types.js';
15
15
  import { parse as parseToml } from 'smol-toml';
16
+ import { type ParsedCommandLine, parseJsonConfigFileContent, readConfigFile, sys as typescriptSys } from 'typescript';
16
17
 
17
- import { BOUNDED_TEST_KILL_AFTER_MS, BOUNDED_TEST_TIMEOUT_MS } from './bounded-test-policy.js';
18
+ import { BOUNDED_TEST_IDLE_TIMEOUT_MS, BOUNDED_TEST_KILL_AFTER_MS } from './bounded-test-policy.js';
18
19
  import {
19
20
  CARGO_CLOSURE_INPUT,
20
21
  type CargoClosureSource,
@@ -22,7 +23,11 @@ import {
22
23
  indexedCargoManifests,
23
24
  resolveCargoClosureSource,
24
25
  } from './cargo-closure-input.js';
25
- import { CARGO_TOOLCHAIN_NAMED_INPUT, CARGO_TOOLCHAIN_PIN_INPUTS } from './cargo-toolchain-policy.js';
26
+ import {
27
+ CARGO_TOOLCHAIN_NAMED_INPUT,
28
+ CARGO_TOOLCHAIN_PIN_INPUTS,
29
+ cargoRuntimeInput,
30
+ } from './cargo-toolchain-policy.js';
26
31
  import {
27
32
  type AttributedCargoWorkspacePackage,
28
33
  attributeCargoWorkspacePackages,
@@ -34,6 +39,7 @@ import {
34
39
  type CargoCrossTestTarget,
35
40
  type CargoInputsCache,
36
41
  cargoPackageTestInputs,
42
+ cargoTestGroupTargetName,
37
43
  cargoTestPackageTargetName,
38
44
  createCargoInputsCache,
39
45
  exceptionalTestFilter,
@@ -41,6 +47,9 @@ import {
41
47
  listCargoWorkspacePackages,
42
48
  NEXTEST_REPO_CONFIG_PATH,
43
49
  nextestToolConfigArg,
50
+ PLUGIN_NEXTEST_CONFIG_PATH,
51
+ type SerialTestGroup,
52
+ serialTestGroups,
44
53
  } from './cargo-workspace.js';
45
54
  import {
46
55
  CARGO_CROSS_LINT_COMMAND,
@@ -54,6 +63,7 @@ import {
54
63
  cargoCrossTestTargetName,
55
64
  cargoFrozen,
56
65
  } from './cross-check-policy.js';
66
+ import type { EslintFileSet } from './eslint-file-set.js';
57
67
  import { hashVersionlessCrateManifests } from './manifest-hash.js';
58
68
  import {
59
69
  EXTRACTED_BINARIES_METADATA,
@@ -61,15 +71,19 @@ import {
61
71
  EXTRACTED_TARGET_DIR,
62
72
  NEXTEST_EXTRACT_BIN,
63
73
  } from './nextest-extraction.js';
74
+ import { runtimeInput, shellWord } from './runtime-input.js';
64
75
  import { isNonSourceDirectory } from './source-directories.js';
76
+ import { postTasksExecution, preTasksExecution } from './task-results.js';
77
+ import { SHARD_TIMINGS_EXECUTOR, SHARD_TIMINGS_TARGET, timingsShardedSuite } from './test-timings.js';
65
78
  import {
66
79
  isBuildOutputTargetName,
67
80
  isTestRunnerTargetName,
68
81
  PLATFORM_TARGET_GLOBS,
69
82
  RELEASE_CONFIGURATION,
70
83
  } from './workspace-config-policy.js';
84
+ import { globIndexedFiles } from './workspace-index.js';
71
85
 
72
- export { CARGO_TEST_COMPILE_TARGET };
86
+ export { CARGO_TEST_COMPILE_TARGET, postTasksExecution, preTasksExecution };
73
87
 
74
88
  /** Makes a version live and proves it answers; never cached. */
75
89
  export const DEPLOY_TARGET = 'deploy';
@@ -78,8 +92,8 @@ export const DEPLOY_BUILD_TARGET = 'deploy-build';
78
92
 
79
93
  /** The workspace-wide manifests a release rewrites: the version of every member, and the lockfile mirror of it. */
80
94
  const RELEASE_REWRITTEN_WORKSPACE_INPUTS = ['{workspaceRoot}/package.json', '{workspaceRoot}/bun.lock'];
81
- /** Installed-toolchain files a TypeScript task reads that no config can name. */
82
- const TYPESCRIPT_PATCH_INPUTS = ['{workspaceRoot}/patches/**/*'];
95
+ /** Installed patch bytes and pins affect the compiler; Markdown explains them but is not loaded. */
96
+ const TYPESCRIPT_PATCH_INPUTS = ['{workspaceRoot}/patches/**/*', '!{workspaceRoot}/patches/**/*.md'];
83
97
  /**
84
98
  * The workspace's own base config, hashed for every TypeScript task whether or
85
99
  * not this project's chain reaches it: it is where a workspace puts the options
@@ -88,6 +102,23 @@ const TYPESCRIPT_PATCH_INPUTS = ['{workspaceRoot}/patches/**/*'];
88
102
  */
89
103
  const WORKSPACE_TSCONFIG_BASE_INPUT = '{workspaceRoot}/tsconfig.base.json';
90
104
 
105
+ /**
106
+ * The native compiler a typecheck runs, apart from the one emit runs: devenv.smoo.nix builds it
107
+ * from a pinned source revision and exports its path. The typecheck targets run it directly,
108
+ * not through ttsc: ttsc auto-loads a dependency's transform plugin (typia) and then checks
109
+ * inside that plugin's host, which links ttsc's own compiler and never runs the pinned one.
110
+ * Transform diagnostics stay enforced where the transform runs: for the lib program in `tsc-js`'s
111
+ * emit, for test files when the test runner transforms them. A test file no test executes has
112
+ * its types checked here but its transform calls checked nowhere. Hashed by the store path,
113
+ * which carries the revision, so a compiler bump misses the cache. The command refuses an unset
114
+ * variable: falling back would check with another compiler under the same key.
115
+ */
116
+ const TYPECHECK_COMPILER_ENV = 'SMOO_TYPECHECK_TSC';
117
+ const TYPECHECK_COMPILER_INPUT = { env: TYPECHECK_COMPILER_ENV };
118
+ function typecheckCommand(args: string): string {
119
+ return `"\${${TYPECHECK_COMPILER_ENV}:?is unset, enter the devenv shell (devenv.smoo.nix builds the typecheck compiler)}" ${args}`;
120
+ }
121
+
91
122
  /**
92
123
  * The two release-rewritten files hashed by field instead of by byte, for a
93
124
  * check that only reads them.
@@ -97,9 +128,18 @@ const WORKSPACE_TSCONFIG_BASE_INPUT = '{workspaceRoot}/tsconfig.base.json';
97
128
  * name, version and dependency specifiers — and every one of those is already
98
129
  * hashed from the member's own `package.json`. Dropping that section keeps the
99
130
  * resolution table, which is the reason the lockfile is an input at all.
131
+ *
132
+ * The root manifest also drops `scripts`, `smoo` and `nx`. No lint or
133
+ * typecheck reads them: `scripts` are commands a developer runs, `smoo` holds
134
+ * the developer links whose linked bytes reach the hash only through their own
135
+ * inputs, and the root project's `nx` configuration is hashed as that
136
+ * project's configuration. Hashing them made a root `postinstall` edit or a
137
+ * developer-link edit re-key every lint task (74, measured in a consumer
138
+ * workspace). The dependency fields, `overrides`, `patchedDependencies` and
139
+ * `workspaces` stay hashed.
100
140
  */
101
141
  const VERSIONLESS_TOOLCHAIN_MANIFEST_INPUTS = [
102
- { json: '{workspaceRoot}/package.json', excludeFields: ['version'] },
142
+ { json: '{workspaceRoot}/package.json', excludeFields: ['version', 'scripts', 'smoo', 'nx'] },
103
143
  { json: '{workspaceRoot}/bun.lock', excludeFields: ['workspaces'] },
104
144
  ];
105
145
 
@@ -304,35 +344,95 @@ const ESLINT_CONFIG_FILES = [
304
344
  'eslint.config.cts',
305
345
  ];
306
346
 
307
- async function javaScriptSourceFiles(directory: string): Promise<string[]> {
308
- if (!existsSync(directory)) return [];
309
- const files: string[] = [];
310
- for (const entry of await readdir(directory, { withFileTypes: true })) {
311
- if (entry.isDirectory()) {
312
- if (!isNonSourceDirectory(entry.name)) {
313
- files.push(...(await javaScriptSourceFiles(join(directory, entry.name))));
314
- }
315
- } else if (entry.isFile() && /\.[cm]?[jt]sx?$/.test(entry.name)) {
316
- files.push(join(directory, entry.name));
317
- }
318
- }
319
- return files.sort();
347
+ /** Every JavaScript and TypeScript module kind ESLint is handed. */
348
+ const ESLINT_SOURCES_GLOB = '**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}';
349
+
350
+ /**
351
+ * The JavaScript and TypeScript files of Nx's workspace file index, listed once
352
+ * per graph computation; `null` when no workspace ESLint config enables ESLint.
353
+ *
354
+ * The ESLint file list is part of the lint target's command, metadata and
355
+ * inputs, and Nx hashes the whole target configuration into every task that
356
+ * reaches the project. A walk of the tree also listed gitignored generated
357
+ * modules a build had left on disk, so every such task's key depended on
358
+ * whether a build had run in that checkout: one workspace's graph listed them
359
+ * and a fresh fork's did not, which alone re-keyed 197 of 510 gate tasks.
360
+ * Drawing the list from the index makes the plugin and the hasher agree on one
361
+ * file set.
362
+ */
363
+ async function indexedEslintSources(workspaceRoot: string): Promise<ReadonlySet<string> | null> {
364
+ if (!ESLINT_CONFIG_FILES.some((name) => existsSync(join(workspaceRoot, name)))) return null;
365
+ return new Set(await globIndexedFiles(workspaceRoot, [ESLINT_SOURCES_GLOB]));
366
+ }
367
+
368
+ /**
369
+ * Read a tsconfig with this plugin's own TypeScript. `@nx/js`'s readTsConfig does an
370
+ * undeclared `require('typescript')` resolved from its own location: where that lands on the
371
+ * TypeScript 7 native package (whose entry exports only its version), `sys` is undefined and
372
+ * graph construction dies reading `sys.readFile`. The plugin declares TypeScript 6, whose
373
+ * `sys` this uses, so the resolution is the one this package's manifest promises.
374
+ */
375
+ function readTestTsConfig(testConfig: string): ParsedCommandLine {
376
+ const readResult = readConfigFile(testConfig, typescriptSys.readFile);
377
+ return parseJsonConfigFileContent(readResult.config, typescriptSys, dirname(testConfig));
320
378
  }
321
379
 
322
- async function projectLintCommands(projectRoot: string, workspaceRoot: string): Promise<string[]> {
380
+ function projectLintCommands(
381
+ projectRoot: string,
382
+ workspaceRoot: string,
383
+ eslintSources: ReadonlySet<string> | null,
384
+ ): { commands: string[]; inputs: string[]; eslintFileSet: EslintFileSet | null } {
323
385
  const commands: string[] = [];
386
+ const inputs: string[] = [];
387
+ let eslintFileSet: EslintFileSet | null = null;
324
388
  const absoluteProjectRoot = join(workspaceRoot, projectRoot);
325
389
  const quote = (path: string) => `'${path.replaceAll("'", "'\"'\"'")}'`;
326
390
  if (BIOME_CONFIG_FILES.some((name) => existsSync(join(workspaceRoot, name)))) {
327
391
  commands.push(`biome check --files-ignore-unknown=true ${quote(projectRoot)}`);
328
392
  }
329
- if (ESLINT_CONFIG_FILES.some((name) => existsSync(join(workspaceRoot, name)))) {
330
- const sourceFiles = await javaScriptSourceFiles(join(absoluteProjectRoot, 'src'));
331
- if (sourceFiles.length > 0) {
332
- commands.push(`eslint ${sourceFiles.map((file) => quote(relative(workspaceRoot, file))).join(' ')}`);
393
+ if (eslintSources !== null) {
394
+ const sourcePrefix = projectRoot === '.' ? 'src/' : `${posix.normalize(projectRoot)}/src/`;
395
+ const sourceFiles = new Set<string>();
396
+ for (const path of eslintSources) {
397
+ if (
398
+ path.startsWith(sourcePrefix) &&
399
+ !path.slice(sourcePrefix.length).split('/').slice(0, -1).some(isNonSourceDirectory)
400
+ ) {
401
+ sourceFiles.add(path);
402
+ }
403
+ }
404
+ const testConfig = join(absoluteProjectRoot, 'tsconfig.test.json');
405
+ if (existsSync(testConfig)) {
406
+ // A test program can live anywhere the declaration selects, not just src.
407
+ // Use the compiler's file set and the existing declaration-chain hasher,
408
+ // so inherited includes and files outside this project keep their keys.
409
+ const program: ParsedCommandLine = readTestTsConfig(testConfig);
410
+ const errors = program.errors.filter(({ code }) => code !== 18003);
411
+ if (errors.length > 0) {
412
+ throw new Error(
413
+ `${testConfig}: ${errors.map(({ code, messageText }) => `TS${code}: ${JSON.stringify(messageText)}`).join('; ')}`,
414
+ );
415
+ }
416
+ inputs.push('{projectRoot}/tsconfig.test.json');
417
+ for (const file of program.fileNames) {
418
+ const path = relative(workspaceRoot, file).split(sep).join('/');
419
+ if (path === '..' || path.startsWith('../') || isAbsolute(path)) {
420
+ throw new Error(`${testConfig}: test source ${file} is outside the workspace and cannot be hashed`);
421
+ }
422
+ // Only a module Nx indexes is linted and keyed. An ignored one is build
423
+ // output that a fresh checkout lacks; a JSON file is not ESLint's.
424
+ if (!eslintSources.has(path) || path.split('/').some(isNonSourceDirectory)) continue;
425
+ sourceFiles.add(path);
426
+ inputs.push(`{workspaceRoot}/${path}`);
427
+ }
428
+ }
429
+ if (sourceFiles.size > 0) {
430
+ const files = [...sourceFiles].sort();
431
+ eslintFileSet = { command: `eslint ${files.map(quote).join(' ')}`, files };
432
+ commands.push(eslintFileSet.command);
333
433
  }
334
434
  }
335
- return commands;
435
+ return { commands, inputs: [...new Set(inputs)], eslintFileSet };
336
436
  }
337
437
 
338
438
  type NapiArchitecture = 'arm64' | 'x64';
@@ -415,22 +515,29 @@ const CARGO_INPUTS = [
415
515
  // build really reads is the package's `napi` block (binary name, targets) and
416
516
  // the `@napi-rs/cli` it runs; those are hashed as such by napiInputs().
417
517
  const CARGO_OUTPUT_INPUTS = CARGO_INPUTS;
418
- const REPO_ROOT_CARGO_OUTPUT_INPUTS = [
419
- '{workspaceRoot}/**/*.rs',
420
- '{workspaceRoot}/**/Cargo.toml',
421
- '{workspaceRoot}/Cargo.lock',
422
- '{workspaceRoot}/**/.cargo/config.toml',
423
- '{workspaceRoot}/scripts/*.sh',
424
- '!{workspaceRoot}/**/target/**',
425
- ];
426
518
  // The toolchain half of a cargo task's identity lives in its own module
427
519
  // because `smoo monorepo validate` reads the same two constants to refuse a
428
520
  // declaration that drops it. See cargo-toolchain-policy.ts for why it is the
429
521
  // declared pin and not the ambient environment.
430
522
 
431
- function cargoRuntimeInput(projectRoot: string, command: string): { runtime: string } {
432
- const quotedRoot = `'${projectRoot.replaceAll("'", "'\"'\"'")}'`;
433
- return { runtime: `cd ${quotedRoot} && ${command}` };
523
+ /** A runtime input that changes when the file's bytes do: the runtime hashes the file itself. */
524
+ function fileHashInput(path: string): { runtime: string } {
525
+ return runtimeInput(
526
+ `bun -e 'console.log(new Bun.CryptoHasher("sha256").update(require("node:fs").readFileSync(process.argv[1])).digest("hex"))' ${shellWord(path)}`,
527
+ );
528
+ }
529
+
530
+ /**
531
+ * One shell command that runs `steps` in order and stops at the first failure.
532
+ *
533
+ * For a step that CONSUMES what an earlier step produces — the archive needs
534
+ * its directory, `wasm-bindgen` reads the `.wasm` that `cargo build` writes.
535
+ * The order lives in the command because that is the only place a
536
+ * producer-consumer pair inside one task can state it: `nx:run-commands`'
537
+ * `commands` array is a set of independent commands that Nx runs side by side.
538
+ */
539
+ function sequence(steps: readonly string[]): string {
540
+ return steps.join(' && ');
434
541
  }
435
542
 
436
543
  /**
@@ -465,9 +572,11 @@ function napiInputs(projectRoot: string, repoRooted: boolean): TargetConfigurati
465
572
  // by its path from there whichever way the Cargo invocation is rooted.
466
573
  const packageJson = `./${posix.join(projectRoot, 'package.json')}`;
467
574
  return [
468
- ...(repoRooted ? REPO_ROOT_CARGO_OUTPUT_INPUTS : CARGO_OUTPUT_INPUTS),
575
+ CARGO_CLOSURE_INPUT,
576
+ '{projectRoot}/scripts/*.sh',
577
+ ...(repoRooted ? ['{workspaceRoot}/scripts/*.sh'] : []),
469
578
  ...CARGO_TOOLCHAIN_PIN_INPUTS,
470
- { runtime: `bun -e 'console.log(JSON.stringify(require(${JSON.stringify(packageJson)}).napi ?? null))'` },
579
+ runtimeInput(`bun -e 'console.log(JSON.stringify(require(${JSON.stringify(packageJson)}).napi ?? null))'`),
471
580
  { externalDependencies: ['@napi-rs/cli'] },
472
581
  ];
473
582
  }
@@ -551,11 +660,11 @@ function cargoWasmTargetDirectory(
551
660
  ): string {
552
661
  const cwd = repoRooted ? '.' : projectRoot;
553
662
  const crateDir = posix.join(cwd, posix.dirname(config.manifestPath));
554
- const owner =
555
- cargoWorkspace !== undefined &&
556
- cargoWorkspace.packages.some((plan) => posix.join(cargoWorkspace.projectRoot, plan.package.dir) === crateDir)
557
- ? cargoWorkspace.projectRoot
558
- : crateDir;
663
+ const owner = cargoWorkspace?.packages.some(
664
+ (plan) => posix.join(cargoWorkspace.projectRoot, plan.package.dir) === crateDir,
665
+ )
666
+ ? cargoWorkspace.projectRoot
667
+ : crateDir;
559
668
  return posix.relative(cwd, posix.join(owner, 'target'));
560
669
  }
561
670
 
@@ -567,26 +676,28 @@ function createCargoWasmTarget(
567
676
  ): TargetConfiguration {
568
677
  const outputDirectory = repoRooted ? posix.join(projectRoot, config.outputDirectory) : config.outputDirectory;
569
678
  const cargoSelection = repoRooted ? `-p ${config.cargoPackage}` : `--manifest-path ${config.manifestPath}`;
570
- const commands = (profile: CargoProfile): string[] => [
571
- cargoFrozen(`build${CARGO_PROFILE_FLAG[profile]} --target wasm32-unknown-unknown ${cargoSelection}`),
572
- ...config.targets.map(
573
- ({ bindgenTarget, outputName }) =>
574
- `wasm-bindgen --target ${bindgenTarget} --out-dir ${outputDirectory}/${outputName} ` +
575
- `${cargoTargetDirectory}/wasm32-unknown-unknown/${CARGO_PROFILE_OUTPUT_DIR[profile]}/${config.libraryName}.wasm`,
576
- ),
577
- ];
679
+ const buildCommand = (profile: CargoProfile): string =>
680
+ sequence([
681
+ cargoFrozen(`build${CARGO_PROFILE_FLAG[profile]} --target wasm32-unknown-unknown ${cargoSelection}`),
682
+ ...config.targets.map(
683
+ ({ bindgenTarget, outputName }) =>
684
+ `wasm-bindgen --target ${bindgenTarget} --out-dir ${outputDirectory}/${outputName} ` +
685
+ `${cargoTargetDirectory}/wasm32-unknown-unknown/${CARGO_PROFILE_OUTPUT_DIR[profile]}/${config.libraryName}.wasm`,
686
+ ),
687
+ ]);
578
688
  return {
579
689
  executor: 'nx:run-commands',
580
690
  cache: true,
581
691
  dependsOn: ['^build'],
582
- inputs: repoRooted ? REPO_ROOT_CARGO_OUTPUT_INPUTS : CARGO_OUTPUT_INPUTS,
692
+ inputs: repoRooted
693
+ ? [CARGO_CLOSURE_INPUT, '{workspaceRoot}/scripts/*.sh', '{projectRoot}/scripts/*.sh']
694
+ : CARGO_OUTPUT_INPUTS,
583
695
  outputs: [`{projectRoot}/${config.outputDirectory}`],
584
696
  options: {
585
- commands: commands('dev'),
697
+ command: buildCommand('dev'),
586
698
  cwd: repoRooted ? '.' : projectRoot,
587
- parallel: false,
588
699
  },
589
- configurations: { [RELEASE_CONFIGURATION]: { commands: commands('release') } },
700
+ configurations: { [RELEASE_CONFIGURATION]: { command: buildCommand('release') } },
590
701
  };
591
702
  }
592
703
 
@@ -597,11 +708,11 @@ function createCargoWasmTarget(
597
708
  * in its own unbounded target. Cargo reuses incremental compilation locally;
598
709
  * Nx cannot cache this warming action without restoring shared mutable state.
599
710
  *
600
- * Cargo flocks one `target/` per invocation. Nx must not run two cargo
601
- * writers on that directory at once — that is a mutex, not a deadlock, and
602
- * the second process sits in "Blocking waiting for file lock" until a
603
- * timeout. Inference serializes writers that share the default target dir
604
- * (`napi-debug` after compile).
711
+ * Cargo flocks one `target/` per invocation and owns that lock: a second cargo
712
+ * process on the same directory waits inside cargo ("Blocking waiting for file
713
+ * lock"). Inference adds no edge to keep writers apart — an edge says one
714
+ * target consumes another's output, and none of these do. These are unbounded
715
+ * `nx:run-commands` targets, so a wait is not charged against a test budget.
605
716
  *
606
717
  * Clippy runs ONCE over the whole workspace, in that same `target/`, rather
607
718
  * than once per crate. Clippy of a crate is a check build of its whole
@@ -645,6 +756,9 @@ function createCargoTestCompileTarget(projectRoot: string): TargetConfiguration
645
756
  * Cached, unlike `cargo-test-compile`, because it produces a VALUE: one file,
646
757
  * not a mutable build tree Nx would have to restore. `--workspace` matches the
647
758
  * clippy selection exactly, so both gates unify features the same way.
759
+ *
760
+ * The directory and the archive are ONE command: nextest does not create the
761
+ * archive's parent, so the archive step consumes what the `mkdir` produced.
648
762
  */
649
763
  function createCargoTestArchiveTarget(projectRoot: string, toolConfig: string): TargetConfiguration {
650
764
  return {
@@ -653,14 +767,13 @@ function createCargoTestArchiveTarget(projectRoot: string, toolConfig: string):
653
767
  inputs: CARGO_INPUTS,
654
768
  outputs: [`{projectRoot}/${CARGO_TEST_ARCHIVE_FILE}`],
655
769
  options: {
656
- commands: [
770
+ command: sequence([
657
771
  `mkdir -p ${posix.dirname(CARGO_TEST_ARCHIVE_FILE)}`,
658
772
  cargoFrozen(
659
773
  `nextest archive --workspace --archive-file ${CARGO_TEST_ARCHIVE_FILE} --user-config-file none ${toolConfig}`,
660
774
  ),
661
- ],
775
+ ]),
662
776
  cwd: projectRoot,
663
- parallel: false,
664
777
  },
665
778
  };
666
779
  }
@@ -703,9 +816,15 @@ function createCargoCrossTestTargets(
703
816
  ): Record<string, TargetConfiguration> {
704
817
  const { target: triple, cargo } = crossTarget;
705
818
  const archiveFile = cargoCrossTestArchiveFile(triple);
819
+ const archiveCommand = sequence([
820
+ `mkdir -p ${posix.dirname(archiveFile)}`,
821
+ `cargo-nextest nextest archive --workspace --target ${triple} --frozen ` +
822
+ `--archive-file ${archiveFile} --user-config-file none ${toolConfig}`,
823
+ ]);
824
+ const archiveExecutor = 'nx:run-commands';
706
825
  return {
707
826
  [cargoCrossTestArchiveTargetName(triple)]: {
708
- executor: 'nx:run-commands',
827
+ executor: archiveExecutor,
709
828
  cache: true,
710
829
  // The toolchain inputs every cached cargo target carries, plus the
711
830
  // declared driver's own bytes. Those toolchain inputs are attached
@@ -717,23 +836,19 @@ function createCargoCrossTestTargets(
717
836
  // must never hash equal to the same sources built under another. The
718
837
  // declared driver is hashed by its own bytes; nothing samples the shell
719
838
  // that supplies it, which is why this hash is the same bare and inside
720
- // the cross profile.
839
+ // the cross profile. For the same reason it names its npm packages here.
721
840
  inputs: [
722
841
  ...archiveInputs,
723
842
  ...CARGO_TOOLCHAIN_PIN_INPUTS,
724
843
  ...(cargo === undefined ? [] : [`{projectRoot}/${cargo}`]),
725
844
  cargoRuntimeInput(projectRoot, 'rustc -vV && cargo -V && cargo nextest --version'),
845
+ { externalDependencies: cargoCommandNpmPackages({ executor: archiveExecutor }, archiveCommand) },
726
846
  ],
727
847
  outputs: [`{projectRoot}/${archiveFile}`],
728
848
  dependsOn: [CARGO_FETCH_TARGET],
729
849
  options: {
730
- commands: [
731
- `mkdir -p ${posix.dirname(archiveFile)}`,
732
- `cargo-nextest nextest archive --workspace --target ${triple} --frozen ` +
733
- `--archive-file ${archiveFile} --user-config-file none ${toolConfig}`,
734
- ],
850
+ command: archiveCommand,
735
851
  cwd: projectRoot,
736
- parallel: false,
737
852
  // `CARGO` is cargo's own driver variable and the only seam nextest
738
853
  // offers: it shells out to `$CARGO metadata` and
739
854
  // `$CARGO test --no-run --target <triple>`, so the declared script
@@ -754,7 +869,7 @@ function createCargoCrossTestTargets(
754
869
  `cargo-nextest nextest run --archive-file ${archiveFile} --workspace-remap . ` +
755
870
  `--no-tests=pass --user-config-file none ${toolConfig}`,
756
871
  cwd: projectRoot,
757
- timeoutMs: BOUNDED_TEST_TIMEOUT_MS,
872
+ idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
758
873
  killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
759
874
  },
760
875
  },
@@ -770,13 +885,47 @@ function createCargoTestTarget(projectRoot: string): TargetConfiguration {
770
885
  options: {
771
886
  command: cargoFrozen('test --workspace'),
772
887
  cwd: projectRoot,
773
- timeoutMs: BOUNDED_TEST_TIMEOUT_MS,
888
+ idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
774
889
  killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
775
890
  },
776
891
  };
777
892
  }
778
893
 
779
894
  const PLUGIN_NEXTEST_CONFIG = fileURLToPath(new URL('../nextest.toml', import.meta.url));
895
+ /**
896
+ * The nextest run-wrapper a serial group names to bound each test's code time.
897
+ * The group's target hashes it, so changing the wrapper reruns the group.
898
+ */
899
+ const PLUGIN_NEXTEST_CODE_BOUND = fileURLToPath(new URL('../src/nextest-code-bound.ts', import.meta.url));
900
+
901
+ const PLUGIN_PACKAGE = '@smoothbricks/nx-plugin';
902
+ /**
903
+ * Whether this plugin runs as an installed npm package. Inside the repository
904
+ * that develops it, it is a workspace project, and Nx refuses a workspace
905
+ * project named as an `externalDependencies` entry.
906
+ */
907
+ const PLUGIN_IS_INSTALLED = fileURLToPath(new URL('..', import.meta.url))
908
+ .split(sep)
909
+ .includes('node_modules');
910
+
911
+ /**
912
+ * The npm packages a cached cargo target runs, for its `externalDependencies`.
913
+ * Cargo runs none. A target this plugin's executor runs, or whose command reads
914
+ * the installed plugin's files (the nextest tool config, the archive
915
+ * extractor), runs the plugin. Without the input Nx keys every task whose
916
+ * executor is not an `@nx/` one on every package in the lockfile, so a
917
+ * lockfile-only commit re-ran every cargo verdict.
918
+ */
919
+ export function cargoCommandNpmPackages(
920
+ target: TargetConfiguration,
921
+ commandText: string,
922
+ installed = PLUGIN_IS_INSTALLED,
923
+ ): string[] {
924
+ const runsPlugin =
925
+ target.executor?.startsWith(`${PLUGIN_PACKAGE}:`) === true ||
926
+ commandText.includes(`node_modules/${PLUGIN_PACKAGE}/`);
927
+ return installed && runsPlugin ? [PLUGIN_PACKAGE] : [];
928
+ }
780
929
 
781
930
  /**
782
931
  * How far the versionless manifest treatment reaches in this workspace.
@@ -859,8 +1008,10 @@ function createNodesHandler(hostPlatform: NapiPlatform | null): CreateNodesHandl
859
1008
  const results: CreateNodesResultV2 = [];
860
1009
  const errors: Array<[file: string | null, error: Error]> = [];
861
1010
  let cargoWorkspaces: CargoWorkspace[];
1011
+ let eslintSources: ReadonlySet<string> | null;
862
1012
  try {
863
- cargoWorkspaces = await resolveCargoWorkspaces(projectConfigurationFiles, context.workspaceRoot);
1013
+ cargoWorkspaces = await resolveCargoWorkspaces(projectConfigurationFiles, context.workspaceRoot, hostPlatform);
1014
+ eslintSources = await indexedEslintSources(context.workspaceRoot);
864
1015
  } catch (error) {
865
1016
  throw new AggregateCreateNodesError([[null, error instanceof Error ? error : new Error(String(error))]], results);
866
1017
  }
@@ -886,6 +1037,7 @@ function createNodesHandler(hostPlatform: NapiPlatform | null): CreateNodesHandl
886
1037
  context.workspaceRoot,
887
1038
  hostPlatform,
888
1039
  cargoWorkspaces,
1040
+ eslintSources,
889
1041
  versionless,
890
1042
  ),
891
1043
  ]);
@@ -894,9 +1046,6 @@ function createNodesHandler(hostPlatform: NapiPlatform | null): CreateNodesHandl
894
1046
  }
895
1047
  }),
896
1048
  );
897
- // A project that failed before reaching its closure never awaited Cargo;
898
- // no process this call started may outlive it.
899
- await Promise.all(cargoWorkspaces.map((workspace) => workspace.closureSource));
900
1049
 
901
1050
  if (errors.length > 0) {
902
1051
  throw new AggregateCreateNodesError(errors, results);
@@ -928,7 +1077,7 @@ function isBuildOutputPackageJson(packageJsonPath: string): boolean {
928
1077
  return BUILD_OUTPUT_SEGMENTS.some((segment) => normalized.includes(segment));
929
1078
  }
930
1079
 
931
- export default { createNodesV2 };
1080
+ export default { createNodesV2, postTasksExecution, preTasksExecution };
932
1081
 
933
1082
  interface PackageJson {
934
1083
  bin?: unknown;
@@ -1012,6 +1161,7 @@ async function createProjectTargets(
1012
1161
  workspaceRoot: string,
1013
1162
  hostPlatform: NapiPlatform | null,
1014
1163
  cargoWorkspaces: readonly CargoWorkspace[],
1164
+ eslintSources: ReadonlySet<string> | null,
1015
1165
  versionless: VersionlessManifestPolicy | null,
1016
1166
  ) {
1017
1167
  const projectRoot = dirname(packageJsonPath);
@@ -1109,11 +1259,17 @@ async function createProjectTargets(
1109
1259
  targets.typecheck = {
1110
1260
  executor: 'nx:run-commands',
1111
1261
  cache: true,
1112
- inputs: [selfProduction, dependencyProduction, ...checkInputs, '{projectRoot}/tsconfig.lib.json'],
1262
+ inputs: [
1263
+ selfProduction,
1264
+ dependencyProduction,
1265
+ ...checkInputs,
1266
+ TYPECHECK_COMPILER_INPUT,
1267
+ '{projectRoot}/tsconfig.lib.json',
1268
+ ],
1113
1269
  outputs: [],
1114
1270
  dependsOn: ['^*-js', ...(cargoWasmConfig ? ['cargo-wasm'] : [])],
1115
1271
  options: {
1116
- command: 'ttsc -p tsconfig.lib.json --noEmit',
1272
+ command: typecheckCommand('-p tsconfig.lib.json --noEmit'),
1117
1273
  cwd: projectRoot,
1118
1274
  },
1119
1275
  };
@@ -1123,10 +1279,16 @@ async function createProjectTargets(
1123
1279
  targets['typecheck-tests'] = {
1124
1280
  executor: 'nx:run-commands',
1125
1281
  cache: true,
1126
- inputs: [selfDefault, dependencyProduction, ...checkInputs, '{projectRoot}/tsconfig.test.json'],
1282
+ inputs: [
1283
+ selfDefault,
1284
+ dependencyProduction,
1285
+ ...checkInputs,
1286
+ TYPECHECK_COMPILER_INPUT,
1287
+ '{projectRoot}/tsconfig.test.json',
1288
+ ],
1127
1289
  dependsOn: ['typecheck'],
1128
1290
  options: {
1129
- command: 'ttsc -p tsconfig.test.json --noEmit',
1291
+ command: typecheckCommand('-p tsconfig.test.json --noEmit'),
1130
1292
  cwd: projectRoot,
1131
1293
  },
1132
1294
  };
@@ -1134,7 +1296,7 @@ async function createProjectTargets(
1134
1296
  executor: 'nx:run-commands',
1135
1297
  continuous: true,
1136
1298
  options: {
1137
- command: 'ttsc -p tsconfig.test.json --noEmit --watch',
1299
+ command: typecheckCommand('-p tsconfig.test.json --noEmit --watch'),
1138
1300
  cwd: projectRoot,
1139
1301
  },
1140
1302
  };
@@ -1209,13 +1371,12 @@ async function createProjectTargets(
1209
1371
  // inferred list here, once when Nx merges the same declaration over this
1210
1372
  // result — duplicating the very edges the spread exists to add.
1211
1373
  //
1212
- // `dependsOn` REPLACES rather than unions. These lists are not a bag of
1213
- // independent wishes; they are the serialization chain that keeps two cargo
1214
- // writers off one flocked `target/` (see CARGO_TEST_COMPILE_TARGET), and their
1215
- // ORDER carries the invariant. A package that must re-route the chain — build
1216
- // its artifact ahead of the test run, or drop `cargo-test-compile` because it
1217
- // compiles differently — can only say so by replacing the list; a union would
1218
- // make every inferred edge unremovable and a corrected order unrepresentable.
1374
+ // `dependsOn` REPLACES rather than unions. These lists state what each target
1375
+ // consumes — the fetched registry, the archive, the debug addon — and a
1376
+ // package that must re-route one (build its artifact ahead of the test run,
1377
+ // or drop `cargo-test-compile` because it compiles differently) can only say
1378
+ // so by replacing the list; a union would make every inferred edge
1379
+ // unremovable and a corrected order unrepresentable.
1219
1380
  // Additive intent already has a spelling (`"..."` above), so a plugin-local
1220
1381
  // additive key would be a second convention beside a working one.
1221
1382
  //
@@ -1260,7 +1421,7 @@ async function createProjectTargets(
1260
1421
  targets[CARGO_TEST_COMPILE_TARGET].inputs = workspaceCargoInputs;
1261
1422
  targets[CARGO_TEST_ARCHIVE_TARGET] = createCargoTestArchiveTarget(
1262
1423
  cargoWorkspaceRoot,
1263
- nextestToolConfigArg(workspaceRoot, cargoWorkspaceRoot, PLUGIN_NEXTEST_CONFIG),
1424
+ nextestToolConfigArg(cargoWorkspaceRoot),
1264
1425
  );
1265
1426
  // `archive.include` lives in the repository's nextest config, so that file
1266
1427
  // decides what the archive CONTAINS, not merely how a run behaves.
@@ -1272,14 +1433,26 @@ async function createProjectTargets(
1272
1433
  for (const crossTarget of listCargoCrossTestTargets(join(workspaceRoot, cargoWorkspaceRoot))) {
1273
1434
  Object.assign(
1274
1435
  targets,
1275
- createCargoCrossTestTargets(
1276
- cargoWorkspaceRoot,
1277
- nextestToolConfigArg(workspaceRoot, cargoWorkspaceRoot, PLUGIN_NEXTEST_CONFIG),
1278
- crossTarget,
1279
- [...workspaceCargoInputs, `{projectRoot}/${NEXTEST_REPO_CONFIG_PATH}`],
1280
- ),
1436
+ createCargoCrossTestTargets(cargoWorkspaceRoot, nextestToolConfigArg(cargoWorkspaceRoot), crossTarget, [
1437
+ ...workspaceCargoInputs,
1438
+ `{projectRoot}/${NEXTEST_REPO_CONFIG_PATH}`,
1439
+ ]),
1281
1440
  );
1282
1441
  }
1442
+ // A serial group's filter can span members, so no single crate owns it. The root
1443
+ // owns each group's runner beside the archive it executes, and gives it the inputs
1444
+ // of exactly the members its filter can select from (`filterScope`): a group scoped
1445
+ // to its packages reruns only when their sources or local dependencies change,
1446
+ // and an unscoped one hashes every member, as the archive itself does.
1447
+ for (const group of cargoWorkspace.serialGroups) {
1448
+ targets[cargoTestGroupTargetName(group.group)] = cargoTestGroupTarget(
1449
+ cargoWorkspace,
1450
+ await cargoTestRunnerInputs(workspaceRoot, cargoWorkspace, serialGroupMemberDirs(cargoWorkspace, group)),
1451
+ group,
1452
+ );
1453
+ }
1454
+ // Every project's crate pieces. The serial groups' runners are the gate's (`test`, below), so
1455
+ // `cargo-test` is the ordinary suite alone and a run of it never reaches a group's real-image tests.
1283
1456
  const aggregateDependencies = cargoWorkspace.packages.flatMap((plan) =>
1284
1457
  plan.pieces.map((piece) =>
1285
1458
  cargoTargetDependency(projectName, {
@@ -1307,7 +1480,6 @@ async function createProjectTargets(
1307
1480
  options: {
1308
1481
  commands: ['cargo fmt --all --check', CARGO_LINT_CLIPPY_COMMAND],
1309
1482
  cwd: cargoWorkspaceRoot,
1310
- parallel: false,
1311
1483
  },
1312
1484
  };
1313
1485
  validationTargets.push('cargo-lint');
@@ -1348,13 +1520,6 @@ async function createProjectTargets(
1348
1520
  cwd: cargoWorkspaceRoot,
1349
1521
  },
1350
1522
  };
1351
- if (!targets.test && !('test' in declaredTargets) && typeof packageJson.scripts?.test !== 'string') {
1352
- targets.test = {
1353
- executor: 'nx:noop',
1354
- cache: true,
1355
- dependsOn: [CARGO_TEST_TARGET],
1356
- };
1357
- }
1358
1523
  // Mutation runs are minutes-to-hours: never cached, never part of build/lint.
1359
1524
  // CI runs these per-PR via `cargo mutants --in-diff` (see mutants.toml docs).
1360
1525
  targets.mutation = {
@@ -1387,6 +1552,8 @@ async function createProjectTargets(
1387
1552
  workspaceRoot,
1388
1553
  cargoWorkspace,
1389
1554
  );
1555
+ // Serial-group runners belong to the workspace root, outside inferred ordinary tests. Explicit repository
1556
+ // aggregates can reach them; their own inputs decide whether each runner executes or replays from cache.
1390
1557
  if (!isCargoWorkspaceRoot) {
1391
1558
  targets[CARGO_TEST_TARGET] = {
1392
1559
  executor: 'nx:noop',
@@ -1415,6 +1582,7 @@ async function createProjectTargets(
1415
1582
  targets.test = {
1416
1583
  executor: 'nx:noop',
1417
1584
  cache: true,
1585
+ // Ordinary tests never infer an edge to a serial group; host aggregates are explicit repository config.
1418
1586
  dependsOn: [CARGO_TEST_TARGET],
1419
1587
  };
1420
1588
  }
@@ -1448,8 +1616,8 @@ async function createProjectTargets(
1448
1616
  // Derived from the command text rather than a curated list of target names:
1449
1617
  // the fact that makes a target need this is that it runs frozen cargo, so a
1450
1618
  // frozen target added later is covered without anyone remembering to. The edge
1451
- // goes on EVERY frozen target, not just the head of the serialization chain,
1452
- // so re-routing that chain cannot strip a surviving target's precondition.
1619
+ // goes on EVERY frozen target, so re-routing one target's `dependsOn` cannot
1620
+ // strip another's precondition.
1453
1621
  // Package-rooted workspaces fetch beside their package.json; members of a
1454
1622
  // repository-root workspace all depend on the root project's one fetch.
1455
1623
  //
@@ -1472,6 +1640,8 @@ async function createProjectTargets(
1472
1640
  // there is nothing for Nx to restore in its place.
1473
1641
  cache: false,
1474
1642
  options: {
1643
+ // One fetch per manifest, independent of the others: Cargo's own
1644
+ // package-cache lock arbitrates the CARGO_HOME they share.
1475
1645
  commands: [...frozenCargoManifests]
1476
1646
  .sort()
1477
1647
  .map((manifestPath) =>
@@ -1480,9 +1650,6 @@ async function createProjectTargets(
1480
1650
  : `${CARGO_FETCH_COMMAND} --manifest-path ${manifestPath}`,
1481
1651
  ),
1482
1652
  cwd: projectRoot,
1483
- // Two fetches into one CARGO_HOME contend on its package-cache flock;
1484
- // serializing here spends the wait in Nx instead of inside cargo.
1485
- parallel: false,
1486
1653
  },
1487
1654
  };
1488
1655
  for (const [name, target] of Object.entries(targets)) {
@@ -1509,6 +1676,8 @@ async function createProjectTargets(
1509
1676
 
1510
1677
  // Cache verdicts and dedicated artifacts, never Cargo's shared mutable build
1511
1678
  // directories. Resolve tool versions from the command's actual directory.
1679
+ // Name the npm packages the command runs (cargoCommandNpmPackages) unless
1680
+ // the target already does.
1512
1681
  for (const [name, target] of Object.entries(targets)) {
1513
1682
  const text = targetCommandText(target);
1514
1683
  if (!text.includes(CARGO_FROZEN_PREFIX)) continue;
@@ -1520,15 +1689,18 @@ async function createProjectTargets(
1520
1689
  : text.includes('nextest ')
1521
1690
  ? ' && cargo nextest --version'
1522
1691
  : '';
1692
+ const inputs = target.inputs ?? CARGO_INPUTS;
1693
+ const namesPackages = inputs.some((input) => typeof input === 'object' && 'externalDependencies' in input);
1523
1694
  target.inputs = [
1524
- ...(target.inputs ?? CARGO_INPUTS),
1695
+ ...inputs,
1525
1696
  ...CARGO_TOOLCHAIN_PIN_INPUTS,
1526
1697
  cargoRuntimeInput(typeof cwd === 'string' ? cwd : projectRoot, `rustc -vV && cargo -V${versions}`),
1698
+ ...(namesPackages ? [] : [{ externalDependencies: cargoCommandNpmPackages(target, text) }]),
1527
1699
  ];
1528
1700
  }
1529
1701
 
1530
- // Cargo flocks the workspace's default target/. Keep every writer out of the
1531
- // bounded test window by placing N-API debug builds behind the root compile.
1702
+ // `build` warms the test executables' compile; in a nested package that names
1703
+ // the root workspace's one compile.
1532
1704
  const cargoTestCompileDependency: CargoTargetDependency | null = targets[CARGO_TEST_COMPILE_TARGET]
1533
1705
  ? CARGO_TEST_COMPILE_TARGET
1534
1706
  : isCargoProject && cargoWorkspace
@@ -1538,24 +1710,21 @@ async function createProjectTargets(
1538
1710
  })
1539
1711
  : null;
1540
1712
  const napiDebug = targets['napi-debug'];
1541
- if (napiDebug && cargoTestCompileDependency) {
1542
- const dependsOn = napiDebug.dependsOn ?? [];
1543
- if (!hasCargoTargetDependency(dependsOn, cargoTestCompileDependency)) {
1544
- napiDebug.dependsOn = [...dependsOn, cargoTestCompileDependency];
1545
- }
1546
- }
1547
1713
  if (napiDebug && cargoWorkspace) {
1548
1714
  // A crate whose project also builds the debug cdylib runs its tests after
1549
1715
  // that build: the tests dlopen what `napi-debug` writes into `target/debug`,
1550
- // and an archived test binary still loads it from this tree. The old serial
1551
- // chain gave the same guarantee by accident, to whichever crate happened to
1552
- // be first; this states it for exactly the crates that own the artifact.
1553
- for (const plan of cargoPackagePlans) {
1554
- for (const piece of plan.pieces) {
1555
- const target = targets[piece.targetName];
1556
- if (target && !hasCargoTargetDependency(target.dependsOn ?? [], 'napi-debug')) {
1557
- target.dependsOn = [...(target.dependsOn ?? []), 'napi-debug'];
1558
- }
1716
+ // and an archived test binary still loads it from this tree.
1717
+ const runners = [
1718
+ ...cargoPackagePlans.flatMap((plan) => plan.pieces.map((piece) => piece.targetName)),
1719
+ // The root owns the serial groups' runners, so they take its build as its pieces do.
1720
+ ...(ownsCargoWorkspaceTargets
1721
+ ? cargoWorkspace.serialGroups.map((group) => cargoTestGroupTargetName(group.group))
1722
+ : []),
1723
+ ];
1724
+ for (const name of runners) {
1725
+ const target = targets[name];
1726
+ if (target && !hasCargoTargetDependency(target.dependsOn ?? [], 'napi-debug')) {
1727
+ target.dependsOn = [...(target.dependsOn ?? []), 'napi-debug'];
1559
1728
  }
1560
1729
  }
1561
1730
  } else if (napiDebug) {
@@ -1565,9 +1734,7 @@ async function createProjectTargets(
1565
1734
  }
1566
1735
  const dependsOn = target.dependsOn ?? [];
1567
1736
  if (dependsOn.includes(CARGO_TEST_COMPILE_TARGET) && !dependsOn.includes('napi-debug')) {
1568
- target.dependsOn = dependsOn.map((dependency) =>
1569
- dependency === CARGO_TEST_COMPILE_TARGET ? 'napi-debug' : dependency,
1570
- );
1737
+ target.dependsOn = [...dependsOn, 'napi-debug'];
1571
1738
  }
1572
1739
  }
1573
1740
  const cargoTest = targets[CARGO_TEST_TARGET];
@@ -1583,36 +1750,12 @@ async function createProjectTargets(
1583
1750
  }
1584
1751
  }
1585
1752
 
1586
- // `build` lists cargo-test-compile beside the host's platform binaries, and
1587
- // every one of those is a `napi build` — another cargo writer on the
1588
- // workspace's default `target/`, which cargo flocks.
1589
- //
1590
- // Only `cargo-napi` gets the ordering edge. A platform-suffixed target may NOT
1591
- // have one: `validatePlatformTargetDependencies` (package-target-policy.ts:674)
1592
- // walks each platform target's dependency closure and refuses any member of a
1593
- // different family, because the publish flow builds and collects one platform
1594
- // at a time — a `*-macos` collect that reached a familyless sibling would drag
1595
- // in work the macOS runner has no business doing. `cargo-napi` carries no
1596
- // platform suffix, so it is not scanned and the edge is legal there.
1597
- //
1598
- // The platform binaries therefore stay Nx siblings of cargo-test-compile and
1599
- // serialize on cargo's flock instead of on a graph edge. That is the same
1600
- // arrangement `cli-<arch>-<os>` and `napi-<arch>-<os>` already have with each
1601
- // other — both `napi build` on one target dir — so this adds a third
1602
- // participant to an existing wait, not a new hazard. The flock makes them wait;
1603
- // it does not corrupt anything, and these are unbounded `nx:run-commands`
1604
- // targets, so the wait is not charged against a test budget.
1605
- const cargoWriterNames = hostPlatformTargetNames(
1753
+ // The inferring host's own platform binaries join the aggregate `build`;
1754
+ // publish still owns foreign platforms.
1755
+ const hostPlatformBinaries = hostPlatformTargetNames(
1606
1756
  [...Object.keys(declaredTargets), ...Object.keys(targets)],
1607
1757
  hostPlatform,
1608
1758
  );
1609
- const cargoNapi = targets['cargo-napi'];
1610
- if (cargoNapi && cargoTestCompileDependency) {
1611
- const dependsOn = cargoNapi.dependsOn ?? [];
1612
- if (!hasCargoTargetDependency(dependsOn, cargoTestCompileDependency)) {
1613
- cargoNapi.dependsOn = [...dependsOn, cargoTestCompileDependency];
1614
- }
1615
- }
1616
1759
 
1617
1760
  // A deploy is never cached; the build half beside it always is.
1618
1761
  //
@@ -1694,9 +1837,7 @@ async function createProjectTargets(
1694
1837
  executor: 'nx:noop',
1695
1838
  cache: true,
1696
1839
  outputs: [],
1697
- // `cargo-napi` is both an output family and a serialized cargo writer, so
1698
- // the two sources overlap; the Set keeps one edge per target while holding
1699
- // the order the families are listed in.
1840
+ // One edge per target, in the order the sources are listed.
1700
1841
  dependsOn: [
1701
1842
  ...new Set([
1702
1843
  '^build',
@@ -1704,7 +1845,7 @@ async function createProjectTargets(
1704
1845
  // reuses its incremental state; Nx never restores that shared state.
1705
1846
  ...(cargoTestCompileDependency ? [cargoTestCompileDependency] : []),
1706
1847
  ...buildOutputTargetNames([...Object.keys(declaredTargets), ...Object.keys(targets)]),
1707
- ...cargoWriterNames,
1848
+ ...hostPlatformBinaries,
1708
1849
  ]),
1709
1850
  ],
1710
1851
  };
@@ -1759,16 +1900,42 @@ async function createProjectTargets(
1759
1900
  }
1760
1901
  }
1761
1902
 
1762
- const lintCommands = await projectLintCommands(projectRoot, workspaceRoot);
1903
+ // A Bun suite that `--shard` splits and a `--timings` manifest balances gets a
1904
+ // check, which `lint` depends on, that the manifest names every file the
1905
+ // shards run: Bun charges an unnamed file the median, and unnamed files
1906
+ // cluster into one shard. Uncached, because Bun's discovery also finds
1907
+ // gitignored files that no Nx input keys, and the check only walks a tree.
1908
+ const sharded = timingsShardedSuite(projectRoot, declaredTargets);
1909
+ if (!sharded.ok) {
1910
+ throw new Error(`${packageJsonPath}: ${sharded.error}`);
1911
+ }
1912
+ if (sharded.suite !== null) {
1913
+ targets[SHARD_TIMINGS_TARGET] = {
1914
+ executor: SHARD_TIMINGS_EXECUTOR,
1915
+ cache: false,
1916
+ outputs: [],
1917
+ options: { cwd: sharded.suite.cwd, args: sharded.suite.args },
1918
+ };
1919
+ validationTargets.push(SHARD_TIMINGS_TARGET);
1920
+ }
1921
+
1922
+ const {
1923
+ commands: lintCommands,
1924
+ inputs: lintProgramInputs,
1925
+ eslintFileSet,
1926
+ } = projectLintCommands(projectRoot, workspaceRoot, eslintSources);
1763
1927
  if (validationTargets.length > 0 || lintCommands.length > 0) {
1764
1928
  targets.lint = {
1765
1929
  executor: lintCommands.length > 0 ? 'nx:run-commands' : 'nx:noop',
1930
+ ...(eslintFileSet === null ? {} : { metadata: { eslintFileSet } }),
1766
1931
  cache: true,
1767
1932
  dependsOn: validationTargets,
1768
1933
  outputs: [],
1769
1934
  inputs: [
1770
1935
  selfDefault,
1936
+ dependencyProduction,
1771
1937
  ...checkInputs,
1938
+ ...lintProgramInputs,
1772
1939
  ...[...BIOME_CONFIG_FILES, ...ESLINT_CONFIG_FILES].flatMap((name) => [
1773
1940
  `{workspaceRoot}/${name}`,
1774
1941
  `{projectRoot}/${name}`,
@@ -1777,7 +1944,7 @@ async function createProjectTargets(
1777
1944
  ],
1778
1945
  ...(lintCommands.length > 0
1779
1946
  ? {
1780
- options: { commands: lintCommands, cwd: '.', parallel: false },
1947
+ options: { commands: lintCommands, cwd: '.' },
1781
1948
  }
1782
1949
  : {}),
1783
1950
  };
@@ -1817,7 +1984,7 @@ async function createProjectTargets(
1817
1984
  if (closureSources.length > 0) {
1818
1985
  namedInputs[CARGO_CLOSURE_INPUT] = await cargoClosureInputs(
1819
1986
  projectRoot,
1820
- await Promise.all(closureSources.map((workspace) => workspace.closureSource)),
1987
+ closureSources.map((workspace) => workspace.closureSource),
1821
1988
  );
1822
1989
  }
1823
1990
  return {
@@ -2185,8 +2352,8 @@ function createNapiTestTarget(projectRoot: string, hasDedicatedBunfig: boolean):
2185
2352
  // Routes the package's native loader to the napi-debug artifact under
2186
2353
  // .cache/native-debug instead of the packaged dist/native tree.
2187
2354
  env: { NAPI_DEBUG_ADDON: '1' },
2188
- timeoutMs: 120000,
2189
- killAfterMs: 10000,
2355
+ idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
2356
+ killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
2190
2357
  },
2191
2358
  };
2192
2359
  }
@@ -2296,14 +2463,12 @@ interface CargoWorkspace {
2296
2463
  packages: CargoPackagePlan[];
2297
2464
  rootProjectName: string;
2298
2465
  projectRoot: string;
2466
+ /** The repository's serial test groups, each with one runner beside the archive (see `serialTestGroups`). */
2467
+ serialGroups: SerialTestGroup[];
2299
2468
  /** One derivation memo for the whole graph computation (see cargoPackageTestInputs). */
2300
2469
  inputsCache: CargoInputsCache;
2301
- /**
2302
- * Cargo's own resolve, started once per graph computation and awaited only
2303
- * where a project's `cargoClosure` is built, so the `cargo metadata` process
2304
- * overlaps the rest of inference.
2305
- */
2306
- closureSource: Promise<CargoClosureSource>;
2470
+ /** The content-keyed Cargo resolve, checked before publishing any project's closure. */
2471
+ closureSource: CargoClosureSource;
2307
2472
  }
2308
2473
 
2309
2474
  type CargoTargetDependency = NonNullable<TargetConfiguration['dependsOn']>[number];
@@ -2317,6 +2482,7 @@ function cargoTargetDependency(currentProjectName: string, target: CargoTargetRe
2317
2482
  async function resolveCargoWorkspaces(
2318
2483
  packageJsonPaths: readonly string[],
2319
2484
  workspaceRoot: string,
2485
+ hostPlatform: NapiPlatform | null,
2320
2486
  ): Promise<CargoWorkspace[]> {
2321
2487
  const projects: Array<{ name: string; root: string }> = [];
2322
2488
  for (const packageJsonPath of packageJsonPaths) {
@@ -2349,26 +2515,37 @@ async function resolveCargoWorkspaces(
2349
2515
  ).map((pkg) => ({ ...pkg, dir: posix.relative(rootProject.root, pkg.dir) || '.' }));
2350
2516
  const packages: CargoPackagePlan[] = [];
2351
2517
  const exceptional = exceptionalTestFilter(PLUGIN_NEXTEST_CONFIG);
2518
+ // A serial group runs only where its declared cfg holds, macOS. Elsewhere it is not inferred and
2519
+ // no piece excludes its tests: nextest does not apply the group there, so the pieces select them.
2520
+ const serialGroups =
2521
+ hostPlatform?.targetFamily === 'macos'
2522
+ ? serialTestGroups(join(workspaceRoot, rootProject.root, NEXTEST_REPO_CONFIG_PATH))
2523
+ : [];
2524
+ // A serial group's tests belong to that group's one runner, so every per-crate
2525
+ // piece excludes them: each test is selected by exactly one target.
2526
+ const serialExclusion = serialGroups.length === 0 ? null : serialGroups.map((group) => group.filter).join(' or ');
2527
+ const notSerial = serialExclusion === null ? [] : [`not (${serialExclusion})`];
2352
2528
  for (const pkg of attributed) {
2353
2529
  const pieces: CargoTestPiece[] = [];
2354
2530
  const sharded = pkg.testShards > 1;
2355
2531
  const pin = sharded && exceptional !== null ? exceptional : null;
2356
- const shardable = pin === null ? `package(${pkg.name})` : `package(${pkg.name}) and not (${pin})`;
2532
+ const ordinary = [`package(${pkg.name})`, ...(pin === null ? [] : [`not (${pin})`]), ...notSerial].join(' and ');
2357
2533
  for (let index = 1; index <= pkg.testShards; index += 1) {
2358
2534
  const targetName = cargoTestPackageTargetName(pkg.name, sharded ? `shard${index}` : undefined);
2359
2535
  pieces.push({
2360
2536
  extra: sharded ? ` --partition hash:${index}/${pkg.testShards}` : '',
2361
- selector: shardable,
2537
+ selector: ordinary,
2362
2538
  targetName,
2363
2539
  });
2364
2540
  }
2365
2541
  if (pin !== null) {
2366
- const targetName = cargoTestPackageTargetName(pkg.name, CARGO_TEST_EXCEPTIONS_SUFFIX);
2367
- pieces.push({
2368
- extra: '',
2369
- selector: `package(${pkg.name}) and (${pin})`,
2370
- targetName,
2371
- });
2542
+ for (let index = 1; index <= pkg.testShards; index += 1) {
2543
+ pieces.push({
2544
+ extra: ` --partition hash:${index}/${pkg.testShards}`,
2545
+ selector: [`package(${pkg.name}) and (${pin})`, ...notSerial].join(' and '),
2546
+ targetName: cargoTestPackageTargetName(pkg.name, `${CARGO_TEST_EXCEPTIONS_SUFFIX}-shard${index}`),
2547
+ });
2548
+ }
2372
2549
  }
2373
2550
  packages.push({ package: pkg, pieces });
2374
2551
  }
@@ -2377,25 +2554,30 @@ async function resolveCargoWorkspaces(
2377
2554
  rootProjectName: rootProject.name,
2378
2555
  projectRoot: rootProject.root,
2379
2556
  inputsCache: createCargoInputsCache(),
2557
+ serialGroups,
2380
2558
  });
2381
2559
  }
2382
2560
  if (found.length === 0) return [];
2383
2561
  // Started only once every workspace listed cleanly, so a listing that throws
2384
2562
  // leaves no Cargo process behind.
2385
2563
  const indexedManifests = indexedCargoManifests(workspaceRoot);
2386
- return found.map((workspace) => ({
2387
- ...workspace,
2388
- closureSource: resolveCargoClosureSource(
2389
- posix.join(workspace.projectRoot, 'Cargo.toml'),
2390
- workspaceRoot,
2391
- indexedManifests,
2392
- ),
2393
- }));
2564
+ return Promise.all(
2565
+ found.map(async (workspace) => ({
2566
+ ...workspace,
2567
+ closureSource: await resolveCargoClosureSource(
2568
+ posix.join(workspace.projectRoot, 'Cargo.toml'),
2569
+ workspaceRoot,
2570
+ indexedManifests,
2571
+ workspace.inputsCache.compiledInFiles,
2572
+ ),
2573
+ })),
2574
+ );
2394
2575
  }
2395
2576
 
2396
2577
  /**
2397
2578
  * One bounded target per crate; a crate that declares `smoothbricks.test.shards`
2398
- * gets one per shard plus one for the tests nextest.toml singles out.
2579
+ * gets that many ordinary and exceptional shards, so a class of tests with its
2580
+ * own time bound never delays an ordinary shard.
2399
2581
  *
2400
2582
  * Every piece EXECUTES, it never builds: it runs the binaries
2401
2583
  * `cargo-test-archive` compiled once for the whole workspace. That is what
@@ -2422,9 +2604,11 @@ async function resolveCargoWorkspaces(
2422
2604
  * from `--archive-file` is the Rust standard library directory: nextest has no
2423
2605
  * flag to remap it, so a run uses the producing toolchain's own sysroot rather
2424
2606
  * than the archived copy of it — the same toolchain, because the archive's hash
2425
- * covers the toolchain pin. The extraction lives under `target/nextest`, never
2426
- * in an Nx output: it is a multi-GB tree for a cached verdict that has no
2427
- * outputs.
2607
+ * covers the toolchain pin. The extraction lives in Cargo's own target
2608
+ * directory (`<target_directory>/nextest-extracted`), never in an Nx output: it
2609
+ * is a multi-GB tree for a cached verdict that has no outputs, rebuilt from the
2610
+ * archive like the rest of the build tree, and a checkout that keeps its build
2611
+ * state off its source tree keeps the extraction there with it.
2428
2612
  *
2429
2613
  * `--workspace-remap .` is not cosmetic. An archive records the ABSOLUTE paths
2430
2614
  * of the tree that produced it; without the remap, a restored archive hands
@@ -2437,17 +2621,16 @@ async function resolveCargoWorkspaces(
2437
2621
  * time: a test that spawns `env!("CARGO_BIN_EXE_x")` holds the producing tree's
2438
2622
  * path and must read the runtime variable instead to survive relocation.
2439
2623
  *
2440
- * nextest.toml singles some tests out with an override, and each such class
2441
- * breaks a shard in its own way — a `test-group` is scoped to one nextest RUN
2442
- * so the hash would dissolve it, and a raised `slow-timeout` marks a test whose
2443
- * cost is not the suite's. Those are lifted OUT of the hash into one target and
2444
- * the shards run the exact complement, so which tests a shard holds stops
2445
- * depending on how the hash happened to fall.
2624
+ * nextest.toml singles some tests out with an override: a raised `slow-timeout`
2625
+ * marks a test whose cost is not the suite's. Those are lifted OUT of the hash
2626
+ * into their own hash-partitioned targets and the ordinary shards run the exact
2627
+ * complement, so which tests a shard holds stops depending on how the hash
2628
+ * happened to fall.
2446
2629
  *
2447
2630
  * The two filtersets are exact complements, so their union is the crate whatever
2448
- * either one matches. Every piece uses `--no-tests=pass`: a valid workspace
2449
- * member may expose no nextest tests, a small suite can leave a declared hash
2450
- * shard empty, and platform-specific exceptions may not exist on this host.
2631
+ * either one matches. Every piece uses `--no-fail-fast`, so one failing test does not stop the rest of its
2632
+ * piece, and `--no-tests=pass`: a valid workspace member may expose no nextest tests, a small suite can
2633
+ * leave a declared hash shard empty, and platform-specific exceptions may not exist on this host.
2451
2634
  * Manifest discovery proves the package exists and generates the selector from
2452
2635
  * its Cargo name, so accepting an empty run cannot hide a misspelled package.
2453
2636
  *
@@ -2456,9 +2639,9 @@ async function resolveCargoWorkspaces(
2456
2639
  * Detecting that regression requires a separate coverage policy rather than
2457
2640
  * making valid empty crates and shards fail execution.
2458
2641
  *
2459
- * Pieces fan out rather than chain. The chain existed because every runner was
2460
- * a cargo writer on one flocked `target/`; a reused-build run writes nothing
2461
- * there, so the only serialization left is the one extraction per archive.
2642
+ * Pieces fan out rather than chain: a reused-build run writes nothing to cargo's
2643
+ * `target/`, so no piece waits on another. The one extraction per archive is
2644
+ * coordinated by `smoo-nx-nextest-extract` itself.
2462
2645
  */
2463
2646
  async function addCargoTestTargets(
2464
2647
  targets: Record<string, TargetConfiguration>,
@@ -2468,70 +2651,156 @@ async function addCargoTestTargets(
2468
2651
  workspace: CargoWorkspace,
2469
2652
  ): Promise<string[]> {
2470
2653
  const targetNames: string[] = [];
2471
- const toolConfig = nextestToolConfigArg(workspaceRoot, workspace.projectRoot, PLUGIN_NEXTEST_CONFIG);
2472
- // Relative to the runner's cwd, so the hashed command is the same in every checkout.
2473
- const extractBin = posix.join(posix.relative(workspace.projectRoot, '.'), NEXTEST_EXTRACT_BIN);
2474
- const reuseExtraction =
2475
- `--binaries-metadata "$extracted/${EXTRACTED_BINARIES_METADATA}" ` +
2476
- `--cargo-metadata "$extracted/${EXTRACTED_CARGO_METADATA}" ` +
2477
- `--target-dir-remap "$extracted/${EXTRACTED_TARGET_DIR}"`;
2478
2654
  for (const plan of workspace.packages) {
2479
2655
  if (plan.package.projectRoot !== projectRoot) {
2480
2656
  continue;
2481
2657
  }
2482
- // Workspace-anchored for the reason `cargoPackageTestInputs` gives: a
2483
- // `{projectRoot}` glob hashes only files this project owns, and sibling
2484
- // manifests belong to whichever nested project holds them.
2485
- const inputRoot = posix.join('{workspaceRoot}', workspace.projectRoot);
2486
- // A workspace nextest build unifies features across every selected member.
2487
- // A sibling manifest can therefore change this crate's tests without being
2488
- // a path dependency. Track those manifests, not unrelated sibling sources.
2489
- //
2490
- // The repository's own nextest config layers OVER the plugin's tool config,
2491
- // so it decides timeouts, groups and archive contents: a cached verdict that
2492
- // ignored it would survive the change that invalidates it.
2493
- const inputs: NonNullable<TargetConfiguration['inputs']> = [
2494
- ...new Set([
2495
- ...(await cargoPackageTestInputs({
2496
- workspaceRoot,
2497
- absoluteProjectRoot: join(workspaceRoot, workspace.projectRoot),
2498
- memberDir: plan.package.dir,
2499
- cache: workspace.inputsCache,
2500
- })),
2501
- ...workspace.packages.map((member) => posix.join(inputRoot, member.package.dir, 'Cargo.toml')),
2502
- posix.join(inputRoot, NEXTEST_REPO_CONFIG_PATH),
2503
- ]),
2504
- {
2505
- runtime: `bun -e 'console.log(new Bun.CryptoHasher("sha256").update(require("node:fs").readFileSync(process.argv[1])).digest("hex"))' '${PLUGIN_NEXTEST_CONFIG.replaceAll("'", "'\"'\"'")}'`,
2506
- },
2507
- ];
2658
+ const inputs = await cargoTestRunnerInputs(workspaceRoot, workspace, [plan.package.dir]);
2508
2659
  const archive = cargoTargetDependency(currentProjectName, {
2509
2660
  projectName: workspace.rootProjectName,
2510
2661
  targetName: CARGO_TEST_ARCHIVE_TARGET,
2511
2662
  });
2512
2663
  for (const piece of plan.pieces) {
2513
2664
  targetNames.push(piece.targetName);
2514
- targets[piece.targetName] = {
2515
- executor: '@smoothbricks/nx-plugin:bounded-exec',
2516
- cache: true,
2517
- inputs,
2518
- dependsOn: [archive],
2519
- options: {
2520
- command:
2521
- `extracted="$(node ${extractBin} ${CARGO_TEST_ARCHIVE_FILE})" && ` +
2522
- cargoFrozen(
2523
- `nextest run ${reuseExtraction} --workspace-remap . -E '${piece.selector}'${piece.extra} --no-tests=pass --user-config-file none ${toolConfig}`,
2524
- ),
2525
- cwd: workspace.projectRoot,
2526
- timeoutMs: BOUNDED_TEST_TIMEOUT_MS,
2527
- killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
2528
- },
2529
- };
2665
+ targets[piece.targetName] = cargoTestRunnerTarget(workspace, archive, inputs, piece);
2530
2666
  }
2531
2667
  }
2532
2668
  return targetNames;
2533
2669
  }
2534
2670
 
2671
+ /**
2672
+ * The member directories a serial group's runner hashes: the packages its filter is scoped to,
2673
+ * or every member when it is not. A scope naming a package that is not a member is a config
2674
+ * error, refused rather than hashed as nothing.
2675
+ */
2676
+ function serialGroupMemberDirs(workspace: CargoWorkspace, group: SerialTestGroup): string[] {
2677
+ if (group.scope.kind === 'workspace') {
2678
+ return workspace.packages.map((plan) => plan.package.dir);
2679
+ }
2680
+ return group.scope.packages.map((name) => {
2681
+ const member = workspace.packages.find((plan) => plan.package.name === name);
2682
+ if (member === undefined) {
2683
+ throw new Error(
2684
+ `test-group "${group.group}" selects package(${name}), which is not a member of the Cargo workspace at ` +
2685
+ `${workspace.projectRoot || '.'}`,
2686
+ );
2687
+ }
2688
+ return member.package.dir;
2689
+ });
2690
+ }
2691
+
2692
+ /**
2693
+ * The inputs of the runners that select crates from one cargo workspace: the
2694
+ * sources of the crates they select, every member manifest, and the repository's
2695
+ * nextest config.
2696
+ *
2697
+ * Workspace-anchored for the reason `cargoPackageTestInputs` gives: a
2698
+ * `{projectRoot}` glob hashes only files this project owns, and sibling manifests
2699
+ * belong to whichever nested project holds them. A workspace nextest build unifies
2700
+ * features across every selected member, so a sibling manifest can change a crate's
2701
+ * tests without being a path dependency: track those manifests, not unrelated
2702
+ * sibling sources.
2703
+ *
2704
+ * The repository's own nextest config layers OVER the plugin's tool config, so it
2705
+ * decides timeouts, groups and archive contents: a cached verdict that ignored it
2706
+ * would survive the change that invalidates it.
2707
+ */
2708
+ async function cargoTestRunnerInputs(
2709
+ workspaceRoot: string,
2710
+ workspace: CargoWorkspace,
2711
+ memberDirs: readonly string[],
2712
+ ): Promise<NonNullable<TargetConfiguration['inputs']>> {
2713
+ const inputRoot = posix.join('{workspaceRoot}', workspace.projectRoot);
2714
+ const sources = await Promise.all(
2715
+ memberDirs.map((memberDir) =>
2716
+ cargoPackageTestInputs({
2717
+ workspaceRoot,
2718
+ absoluteProjectRoot: join(workspaceRoot, workspace.projectRoot),
2719
+ memberDir,
2720
+ cache: workspace.inputsCache,
2721
+ }),
2722
+ ),
2723
+ );
2724
+ return [
2725
+ ...new Set([
2726
+ ...sources.flat(),
2727
+ ...workspace.packages.map((member) => posix.join(inputRoot, member.package.dir, 'Cargo.toml')),
2728
+ posix.join(inputRoot, NEXTEST_REPO_CONFIG_PATH),
2729
+ ]),
2730
+ fileHashInput(PLUGIN_NEXTEST_CONFIG_PATH),
2731
+ ];
2732
+ }
2733
+
2734
+ /**
2735
+ * One `nextest run` over a filterset against the workspace's archive. Every runner of the
2736
+ * workspace builds its command here, so the extraction, reuse-build, tool config and cwd cannot
2737
+ * drift between the per-crate pieces and the serial groups.
2738
+ */
2739
+ function nextestRunnerCommand(workspace: CargoWorkspace, selector: string, flags: string): string {
2740
+ const toolConfig = nextestToolConfigArg(workspace.projectRoot);
2741
+ // Relative to the runner's cwd, so the hashed command is the same in every checkout.
2742
+ const extractBin = posix.join(posix.relative(workspace.projectRoot, '.'), NEXTEST_EXTRACT_BIN);
2743
+ const reuseExtraction =
2744
+ `--binaries-metadata "$extracted/${EXTRACTED_BINARIES_METADATA}" ` +
2745
+ `--cargo-metadata "$extracted/${EXTRACTED_CARGO_METADATA}" ` +
2746
+ `--target-dir-remap "$extracted/${EXTRACTED_TARGET_DIR}"`;
2747
+ return (
2748
+ `extracted="$(node ${extractBin} ${CARGO_TEST_ARCHIVE_FILE})" && ` +
2749
+ cargoFrozen(
2750
+ `nextest run ${reuseExtraction} --workspace-remap . -E ${shellWord(selector)}${flags} --user-config-file none ${toolConfig}`,
2751
+ )
2752
+ );
2753
+ }
2754
+
2755
+ /** One per-crate piece: a bounded run of its partition of the archive's tests. */
2756
+ function cargoTestRunnerTarget(
2757
+ workspace: CargoWorkspace,
2758
+ archive: CargoTargetDependency,
2759
+ inputs: NonNullable<TargetConfiguration['inputs']>,
2760
+ piece: CargoTestPiece,
2761
+ ): TargetConfiguration {
2762
+ return {
2763
+ executor: '@smoothbricks/nx-plugin:bounded-exec',
2764
+ cache: true,
2765
+ inputs,
2766
+ dependsOn: [archive],
2767
+ options: {
2768
+ command: nextestRunnerCommand(workspace, piece.selector, `${piece.extra} --no-fail-fast --no-tests=pass`),
2769
+ cwd: workspace.projectRoot,
2770
+ idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
2771
+ killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
2772
+ },
2773
+ };
2774
+ }
2775
+
2776
+ /**
2777
+ * A serial group's runner: a nextest run of the group's selection with no partition and no thread
2778
+ * flag, the group being serial because its test-group declares `max-threads = 1`, so it asks for one
2779
+ * CPU token. It is bounded by progress like every test target: a group of slow tests runs as long as
2780
+ * it keeps finishing them. It runs `--no-fail-fast`, so an ordinary failure runs the group's remaining
2781
+ * tests and a failed verdict lists the failed ones, and `--no-tests=fail`, so a filter that selects
2782
+ * nothing fails rather than passing a group that ran no test.
2783
+ */
2784
+ function cargoTestGroupTarget(
2785
+ workspace: CargoWorkspace,
2786
+ inputs: NonNullable<TargetConfiguration['inputs']>,
2787
+ group: SerialTestGroup,
2788
+ ): TargetConfiguration {
2789
+ return {
2790
+ executor: '@smoothbricks/nx-plugin:bounded-exec',
2791
+ cache: true,
2792
+ inputs: [...inputs, fileHashInput(PLUGIN_NEXTEST_CODE_BOUND)],
2793
+ dependsOn: [CARGO_TEST_ARCHIVE_TARGET],
2794
+ options: {
2795
+ command: nextestRunnerCommand(workspace, group.filter, ' --no-fail-fast --no-tests=fail'),
2796
+ cwd: workspace.projectRoot,
2797
+ idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
2798
+ killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
2799
+ parallelism: 1,
2800
+ },
2801
+ };
2802
+ }
2803
+
2535
2804
  function hasCargoTargetDependency(
2536
2805
  dependencies: readonly CargoTargetDependency[],
2537
2806
  expected: CargoTargetDependency,