@smoothbricks/nx-plugin 0.5.6 → 0.6.0

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 (440) hide show
  1. package/README.md +1095 -360
  2. package/dist/.build-inputs.json +138 -0
  3. package/dist/bin/smoo-nx-cargo-toolchain.d.ts +3 -0
  4. package/dist/bin/smoo-nx-cargo-toolchain.d.ts.map +1 -0
  5. package/dist/bin/smoo-nx-cargo-toolchain.js +8 -0
  6. package/dist/bin/smoo-nx-forbidden-spellings.d.ts +3 -0
  7. package/dist/bin/smoo-nx-forbidden-spellings.d.ts.map +1 -0
  8. package/dist/bin/smoo-nx-forbidden-spellings.js +32 -0
  9. package/dist/bin/smoo-nx-nextest-timings.d.ts +3 -0
  10. package/dist/bin/smoo-nx-nextest-timings.d.ts.map +1 -0
  11. package/dist/bin/smoo-nx-nextest-timings.js +28 -0
  12. package/dist/bounded-test-policy.d.ts +1 -1
  13. package/dist/bounded-test-policy.d.ts.map +1 -1
  14. package/dist/bounded-test-policy.js +14 -15
  15. package/dist/build-state-output-policy.d.ts +95 -1
  16. package/dist/build-state-output-policy.d.ts.map +1 -1
  17. package/dist/build-state-output-policy.js +368 -30
  18. package/dist/bun-lock-scope.d.ts +44 -0
  19. package/dist/bun-lock-scope.d.ts.map +1 -0
  20. package/dist/bun-lock-scope.js +97 -0
  21. package/dist/cargo-build-script-env.d.ts +49 -0
  22. package/dist/cargo-build-script-env.d.ts.map +1 -0
  23. package/dist/cargo-build-script-env.js +324 -0
  24. package/dist/cargo-closure-input.d.ts +31 -4
  25. package/dist/cargo-closure-input.d.ts.map +1 -1
  26. package/dist/cargo-closure-input.js +66 -6
  27. package/dist/cargo-retention-hook.d.ts +17 -0
  28. package/dist/cargo-retention-hook.d.ts.map +1 -0
  29. package/dist/cargo-retention-hook.js +85 -0
  30. package/dist/cargo-source-hash.d.ts +25 -7
  31. package/dist/cargo-source-hash.d.ts.map +1 -1
  32. package/dist/cargo-source-hash.js +108 -43
  33. package/dist/cargo-toolchain-paths.d.ts +40 -0
  34. package/dist/cargo-toolchain-paths.d.ts.map +1 -0
  35. package/dist/cargo-toolchain-paths.js +84 -0
  36. package/dist/cargo-toolchain-policy.d.ts +25 -8
  37. package/dist/cargo-toolchain-policy.d.ts.map +1 -1
  38. package/dist/cargo-toolchain-policy.js +39 -5
  39. package/dist/cargo-workspace.d.ts +10 -4
  40. package/dist/cargo-workspace.d.ts.map +1 -1
  41. package/dist/cargo-workspace.js +65 -95
  42. package/dist/cross-check-policy.d.ts +9 -9
  43. package/dist/cross-check-policy.d.ts.map +1 -1
  44. package/dist/cross-check-policy.js +11 -11
  45. package/dist/disk-command-policy.d.ts.map +1 -1
  46. package/dist/disk-command-policy.js +1 -0
  47. package/dist/ensure-built-receipt.d.ts +13 -5
  48. package/dist/ensure-built-receipt.d.ts.map +1 -1
  49. package/dist/ensure-built-receipt.js +126 -47
  50. package/dist/ensure-built-witness.d.ts +27 -8
  51. package/dist/ensure-built-witness.d.ts.map +1 -1
  52. package/dist/ensure-built-witness.js +45 -15
  53. package/dist/ensure-built.d.ts.map +1 -1
  54. package/dist/ensure-built.js +9 -1
  55. package/dist/eslint-config-closure.d.ts +7 -0
  56. package/dist/eslint-config-closure.d.ts.map +1 -0
  57. package/dist/eslint-config-closure.js +346 -0
  58. package/dist/executors/all-verdicts/executor.d.ts +35 -0
  59. package/dist/executors/all-verdicts/executor.d.ts.map +1 -0
  60. package/dist/executors/all-verdicts/executor.js +133 -0
  61. package/dist/executors/all-verdicts/schema.d.ts +10 -0
  62. package/dist/executors/all-verdicts/schema.d.ts.map +1 -0
  63. package/dist/executors/all-verdicts/schema.js +2 -0
  64. package/dist/executors/bounded-exec/bounds.d.ts +56 -0
  65. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -0
  66. package/dist/executors/bounded-exec/bounds.js +43 -0
  67. package/dist/executors/bounded-exec/cpu-pool.d.ts +33 -36
  68. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  69. package/dist/executors/bounded-exec/cpu-pool.js +54 -119
  70. package/dist/executors/bounded-exec/executor.d.ts +19 -12
  71. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  72. package/dist/executors/bounded-exec/executor.js +371 -239
  73. package/dist/executors/bounded-exec/gateway-lease.d.ts +22 -19
  74. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
  75. package/dist/executors/bounded-exec/gateway-lease.js +81 -28
  76. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +18 -1
  77. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  78. package/dist/executors/bounded-exec/hang-diagnostics.js +148 -30
  79. package/dist/executors/bounded-exec/lease-wait.d.ts +43 -0
  80. package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -0
  81. package/dist/executors/bounded-exec/lease-wait.js +68 -0
  82. package/dist/executors/bounded-exec/lock-wait.d.ts +51 -0
  83. package/dist/executors/bounded-exec/lock-wait.d.ts.map +1 -0
  84. package/dist/executors/bounded-exec/lock-wait.js +108 -0
  85. package/dist/executors/bounded-exec/owned-subtree.d.ts +84 -0
  86. package/dist/executors/bounded-exec/owned-subtree.d.ts.map +1 -0
  87. package/dist/executors/bounded-exec/owned-subtree.js +178 -0
  88. package/dist/executors/bounded-exec/progress.d.ts +4 -1
  89. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  90. package/dist/executors/bounded-exec/progress.js +5 -2
  91. package/dist/executors/bounded-exec/ram-attach.d.ts +19 -0
  92. package/dist/executors/bounded-exec/ram-attach.d.ts.map +1 -0
  93. package/dist/executors/bounded-exec/ram-attach.js +207 -0
  94. package/dist/executors/bounded-exec/ram-detach.d.ts +25 -0
  95. package/dist/executors/bounded-exec/ram-detach.d.ts.map +1 -0
  96. package/dist/executors/bounded-exec/ram-detach.js +207 -0
  97. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +76 -0
  98. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -1
  99. package/dist/executors/bounded-exec/ram-temp-fixtures.js +296 -0
  100. package/dist/executors/bounded-exec/ram-temp.d.ts +388 -88
  101. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  102. package/dist/executors/bounded-exec/ram-temp.js +1213 -399
  103. package/dist/executors/bounded-exec/run-cpu-pool.d.ts +4 -4
  104. package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
  105. package/dist/executors/bounded-exec/run-cpu-pool.js +20 -30
  106. package/dist/executors/bounded-exec/runner-hook.js +14 -5
  107. package/dist/executors/bounded-exec/runner-lifecycle.d.ts +14 -1
  108. package/dist/executors/bounded-exec/runner-lifecycle.d.ts.map +1 -1
  109. package/dist/executors/bounded-exec/runner-lifecycle.js +27 -6
  110. package/dist/executors/bounded-exec/{cpu-tokens.d.ts → runner-sizing.d.ts} +14 -42
  111. package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -0
  112. package/dist/executors/bounded-exec/{cpu-tokens.js → runner-sizing.js} +5 -35
  113. package/dist/executors/bounded-exec/runtime-pin.d.ts +73 -0
  114. package/dist/executors/bounded-exec/runtime-pin.d.ts.map +1 -0
  115. package/dist/executors/bounded-exec/runtime-pin.js +167 -0
  116. package/dist/executors/bounded-exec/schema.d.ts +18 -1
  117. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  118. package/dist/executors/bounded-exec/verdict.d.ts +40 -11
  119. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  120. package/dist/executors/bounded-exec/verdict.js +88 -19
  121. package/dist/executors/cargo-zigbuild/executor.d.ts +21 -0
  122. package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
  123. package/dist/executors/cargo-zigbuild/executor.js +67 -12
  124. package/dist/executors/clean-outputs/executor.js +1 -0
  125. package/dist/executors/scriptc-native/executor.d.ts +79 -0
  126. package/dist/executors/scriptc-native/executor.d.ts.map +1 -0
  127. package/dist/executors/scriptc-native/executor.js +367 -0
  128. package/dist/executors/scriptc-native/ffi-paths.d.ts +9 -0
  129. package/dist/executors/scriptc-native/ffi-paths.d.ts.map +1 -0
  130. package/dist/executors/scriptc-native/ffi-paths.js +25 -0
  131. package/dist/executors/scriptc-native/schema.d.ts +34 -0
  132. package/dist/executors/scriptc-native/schema.d.ts.map +1 -0
  133. package/dist/executors/scriptc-native/schema.js +1 -0
  134. package/dist/executors/typescript-emit/executor.d.ts +3 -1
  135. package/dist/executors/typescript-emit/executor.d.ts.map +1 -1
  136. package/dist/executors/typescript-emit/executor.js +164 -33
  137. package/dist/forbidden-spelling-policy.d.ts +56 -0
  138. package/dist/forbidden-spelling-policy.d.ts.map +1 -0
  139. package/dist/forbidden-spelling-policy.js +176 -0
  140. package/dist/generators/create-package/generator.d.ts.map +1 -1
  141. package/dist/generators/create-package/generator.js +3 -4
  142. package/dist/graph-input-contract.d.ts +14 -0
  143. package/dist/graph-input-contract.d.ts.map +1 -1
  144. package/dist/graph-input-contract.js +67 -2
  145. package/dist/index.d.ts +23 -6
  146. package/dist/index.d.ts.map +1 -1
  147. package/dist/index.js +676 -215
  148. package/dist/managed-assets.d.ts +2 -0
  149. package/dist/managed-assets.d.ts.map +1 -1
  150. package/dist/managed-files/files.d.ts +3 -3
  151. package/dist/managed-files/files.d.ts.map +1 -1
  152. package/dist/managed-files/files.js +28 -3
  153. package/dist/managed-files/managed-format.d.ts.map +1 -1
  154. package/dist/managed-files/managed-format.js +1 -0
  155. package/dist/nextest-code-bound.js +1 -0
  156. package/dist/nextest-timings.d.ts +35 -0
  157. package/dist/nextest-timings.d.ts.map +1 -0
  158. package/dist/nextest-timings.js +168 -0
  159. package/dist/owned-installation.d.ts +6 -5
  160. package/dist/owned-installation.d.ts.map +1 -1
  161. package/dist/owned-installation.js +150 -26
  162. package/dist/package-target-policy.d.ts.map +1 -1
  163. package/dist/package-target-policy.js +2 -3
  164. package/dist/process-children.d.ts +7 -0
  165. package/dist/process-children.d.ts.map +1 -0
  166. package/dist/process-children.darwin.d.ts +7 -0
  167. package/dist/process-children.darwin.d.ts.map +1 -0
  168. package/dist/process-children.darwin.js +13 -0
  169. package/dist/process-children.js +14 -0
  170. package/dist/process-children.linux.d.ts +8 -0
  171. package/dist/process-children.linux.d.ts.map +1 -0
  172. package/dist/process-children.linux.js +25 -0
  173. package/dist/process-group.d.ts +108 -0
  174. package/dist/process-group.d.ts.map +1 -0
  175. package/dist/process-group.js +171 -0
  176. package/dist/process-listing.d.ts +7 -0
  177. package/dist/process-listing.d.ts.map +1 -0
  178. package/dist/process-listing.js +51 -0
  179. package/dist/producer-receipts.d.ts +8 -2
  180. package/dist/producer-receipts.d.ts.map +1 -1
  181. package/dist/producer-receipts.js +75 -48
  182. package/dist/task-graph-policy.d.ts +21 -0
  183. package/dist/task-graph-policy.d.ts.map +1 -0
  184. package/dist/task-graph-policy.js +91 -0
  185. package/dist/test-timings.js +4 -4
  186. package/dist/test-walk-policy.d.ts +14 -5
  187. package/dist/test-walk-policy.d.ts.map +1 -1
  188. package/dist/test-walk-policy.js +8 -2
  189. package/dist/testing.d.ts +73 -28
  190. package/dist/testing.d.ts.map +1 -1
  191. package/dist/testing.js +217 -223
  192. package/dist/tool-bins.d.ts +33 -0
  193. package/dist/tool-bins.d.ts.map +1 -0
  194. package/dist/tool-bins.js +72 -0
  195. package/dist/typecheck-test-policy.d.ts.map +1 -1
  196. package/dist/typecheck-test-policy.js +3 -4
  197. package/dist/wait-why-policy.d.ts +28 -0
  198. package/dist/wait-why-policy.d.ts.map +1 -0
  199. package/dist/wait-why-policy.js +223 -0
  200. package/dist/workspace-config-policy.d.ts +14 -8
  201. package/dist/workspace-config-policy.d.ts.map +1 -1
  202. package/dist/workspace-config-policy.js +60 -16
  203. package/dist/workspace-manifest.d.ts +41 -6
  204. package/dist/workspace-manifest.d.ts.map +1 -1
  205. package/dist/workspace-manifest.js +57 -0
  206. package/executors.json +21 -1
  207. package/loader.js +2 -0
  208. package/managed/raw/envrc +11 -0
  209. package/managed/raw/patches/nx@23.2.1.patch +2840 -199
  210. package/managed/raw/patches/ttsc@0.34.1.patch +119 -0
  211. package/managed/raw/tooling/direnv/cargo-fetch-bound.ts +245 -0
  212. package/managed/raw/tooling/direnv/cargo-fetch-run.ts +299 -0
  213. package/managed/raw/tooling/direnv/compiler-variables.sh +42 -0
  214. package/managed/raw/tooling/direnv/developer-links.ts +464 -25
  215. package/managed/raw/tooling/direnv/devenv.smoo.nix +78 -38
  216. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -12
  217. package/managed/raw/tooling/direnv/installed-bun-links.ts +308 -0
  218. package/managed/raw/tooling/direnv/linked-snapshots.ts +62 -3
  219. package/managed/raw/tooling/direnv/nx-socket-dir.sh +56 -17
  220. package/managed/raw/tooling/direnv/repo-path +68 -6
  221. package/managed/raw/tooling/direnv/secret-references.ts +13 -4
  222. package/managed/raw/tooling/direnv/setup-environment.ts +128 -537
  223. package/managed/raw/tooling/direnv/toolchain-stamp.ts +4 -2
  224. package/managed/raw/tooling/direnv/ttsc-env.sh +9 -0
  225. package/managed/raw/tooling/direnv/uv-relocation.ts +227 -0
  226. package/managed/raw/tooling/git-hooks/commit-msg.sh +2 -1
  227. package/managed/raw/tooling/git-hooks/pre-commit.sh +2 -1
  228. package/managed/raw/tooling/git-hooks/pre-push.sh +2 -1
  229. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +85 -7
  230. package/managed/templates/github/actions/save-nix-devenv/action.yml +12 -2
  231. package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
  232. package/package.json +77 -13
  233. package/src/bin/smoo-nx-cargo-toolchain.ts +11 -0
  234. package/src/bin/smoo-nx-forbidden-spellings.ts +33 -0
  235. package/src/bin/smoo-nx-nextest-timings.ts +31 -0
  236. package/src/bounded-test-policy.ts +12 -14
  237. package/src/build-state-output-policy.ts +458 -34
  238. package/src/bun-lock-scope.ts +108 -0
  239. package/src/cargo-build-script-env.ts +265 -0
  240. package/src/cargo-closure-input.ts +74 -7
  241. package/src/cargo-retention-hook.ts +94 -0
  242. package/src/cargo-source-hash.ts +138 -41
  243. package/src/cargo-toolchain-paths.ts +95 -0
  244. package/src/cargo-toolchain-policy.ts +49 -5
  245. package/src/cargo-workspace.ts +72 -123
  246. package/src/cross-check-policy.ts +12 -10
  247. package/src/disk-command-policy.ts +1 -0
  248. package/src/ensure-built-receipt.ts +132 -39
  249. package/src/ensure-built-witness.ts +62 -10
  250. package/src/ensure-built.ts +11 -1
  251. package/src/eslint-config-closure.ts +357 -0
  252. package/src/executors/all-verdicts/executor.ts +164 -0
  253. package/src/executors/all-verdicts/schema.json +22 -0
  254. package/src/executors/all-verdicts/schema.ts +10 -0
  255. package/src/executors/bounded-exec/bounds.ts +76 -0
  256. package/src/executors/bounded-exec/cpu-pool.ts +51 -117
  257. package/src/executors/bounded-exec/executor.ts +423 -259
  258. package/src/executors/bounded-exec/gateway-lease.ts +82 -33
  259. package/src/executors/bounded-exec/hang-diagnostics.ts +173 -31
  260. package/src/executors/bounded-exec/lease-wait.ts +89 -0
  261. package/src/executors/bounded-exec/lock-wait.ts +141 -0
  262. package/src/executors/bounded-exec/owned-subtree.ts +235 -0
  263. package/src/executors/bounded-exec/progress.ts +9 -3
  264. package/src/executors/bounded-exec/ram-attach.ts +238 -0
  265. package/src/executors/bounded-exec/ram-detach.ts +226 -0
  266. package/src/executors/bounded-exec/ram-temp-fixtures.ts +358 -0
  267. package/src/executors/bounded-exec/ram-temp-registry.txt +440 -0
  268. package/src/executors/bounded-exec/ram-temp.ts +1497 -460
  269. package/src/executors/bounded-exec/run-cpu-pool.ts +22 -30
  270. package/src/executors/bounded-exec/runner-hook.ts +14 -6
  271. package/src/executors/bounded-exec/runner-lifecycle.ts +31 -8
  272. package/src/executors/bounded-exec/{cpu-tokens.ts → runner-sizing.ts} +13 -59
  273. package/src/executors/bounded-exec/runtime-pin.ts +232 -0
  274. package/src/executors/bounded-exec/schema.json +11 -2
  275. package/src/executors/bounded-exec/schema.ts +19 -1
  276. package/src/executors/bounded-exec/verdict.ts +137 -34
  277. package/src/executors/cargo-zigbuild/executor.ts +82 -8
  278. package/src/executors/clean-outputs/executor.ts +1 -0
  279. package/src/executors/scriptc-native/executor.ts +394 -0
  280. package/src/executors/scriptc-native/ffi-paths.ts +29 -0
  281. package/src/executors/scriptc-native/schema.json +60 -0
  282. package/src/executors/scriptc-native/schema.ts +34 -0
  283. package/src/executors/typescript-emit/executor.ts +205 -38
  284. package/src/forbidden-spelling-policy.ts +226 -0
  285. package/src/generators/create-package/generator.ts +7 -7
  286. package/src/graph-input-contract.ts +61 -2
  287. package/src/index.ts +792 -225
  288. package/src/managed-assets.ts +3 -0
  289. package/src/managed-files/files.ts +28 -3
  290. package/src/managed-files/managed-format.ts +1 -0
  291. package/src/nextest-code-bound.ts +1 -0
  292. package/src/nextest-timings.ts +106 -0
  293. package/src/owned-installation.ts +150 -23
  294. package/src/package-target-policy.ts +2 -3
  295. package/src/process-children.darwin.ts +14 -0
  296. package/src/process-children.linux.ts +33 -0
  297. package/src/process-children.ts +22 -0
  298. package/src/process-group.ts +209 -0
  299. package/src/process-listing.ts +54 -0
  300. package/src/producer-receipts.ts +68 -45
  301. package/src/task-graph-policy.ts +98 -0
  302. package/src/test-walk-policy.ts +23 -8
  303. package/src/testing.ts +240 -232
  304. package/src/tool-bins.ts +108 -0
  305. package/src/typecheck-test-policy.ts +2 -3
  306. package/src/wait-why-policy.ts +226 -0
  307. package/src/workspace-config-policy.ts +63 -15
  308. package/src/workspace-manifest.ts +89 -6
  309. package/test-timings.json +123 -98
  310. package/dist/bin/smoo-nx-failures.d.ts +0 -3
  311. package/dist/bin/smoo-nx-failures.d.ts.map +0 -1
  312. package/dist/bin/smoo-nx-failures.js +0 -3
  313. package/dist/bin/smoo-nx-nextest-extract.d.ts +0 -3
  314. package/dist/bin/smoo-nx-nextest-extract.d.ts.map +0 -1
  315. package/dist/bin/smoo-nx-nextest-extract.js +0 -42
  316. package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +0 -1
  317. package/dist/failure-summary.d.ts +0 -5
  318. package/dist/failure-summary.d.ts.map +0 -1
  319. package/dist/failure-summary.js +0 -118
  320. package/dist/nextest-extraction.d.ts +0 -117
  321. package/dist/nextest-extraction.d.ts.map +0 -1
  322. package/dist/nextest-extraction.js +0 -303
  323. package/managed/raw/patches/ttsc@0.30.4.patch +0 -2255
  324. package/src/__tests__/cargo-closure-filesets.ts +0 -94
  325. package/src/__tests__/cargo-closure-fixture.ts +0 -113
  326. package/src/__tests__/counted-cargo-process.ts +0 -286
  327. package/src/__tests__/counted-cargo.ts +0 -713
  328. package/src/__tests__/directory-change.ts +0 -27
  329. package/src/__tests__/fixture-cargo-home.ts +0 -36
  330. package/src/__tests__/fixture-nx-env.ts +0 -193
  331. package/src/__tests__/owned-installation.ts +0 -13
  332. package/src/__tests__/past-tick.ts +0 -12
  333. package/src/__tests__/progress-clock.ts +0 -43
  334. package/src/__tests__/runtime-input.ts +0 -23
  335. package/src/bin/smoo-nx-bound-failures.test.ts +0 -127
  336. package/src/bin/smoo-nx-failures.ts +0 -4
  337. package/src/bin/smoo-nx-nextest-extract.ts +0 -44
  338. package/src/bounded-test-policy.test.ts +0 -1029
  339. package/src/build-state-output-policy.test.ts +0 -115
  340. package/src/bun-bootstrap.test.ts +0 -102
  341. package/src/bun-file-packages.test.ts +0 -47
  342. package/src/cargo-closure-filesets.test.ts +0 -63
  343. package/src/cargo-closure-input.property.test.ts +0 -50
  344. package/src/cargo-closure-input.test.ts +0 -506
  345. package/src/cargo-closure-key.test.ts +0 -240
  346. package/src/cargo-resolve-cache.test.ts +0 -1181
  347. package/src/cargo-source-hash.test.ts +0 -707
  348. package/src/cargo-workspace.test.ts +0 -615
  349. package/src/cross-check-policy.test.ts +0 -316
  350. package/src/disk-command-policy.test.ts +0 -61
  351. package/src/ensure-built-receipt.test.ts +0 -279
  352. package/src/ensure-built-witness.test.ts +0 -688
  353. package/src/ensure-built.test.ts +0 -1462
  354. package/src/executors/bounded-exec/cargo-progress-host.test.ts +0 -332
  355. package/src/executors/bounded-exec/cpu-pool.test.ts +0 -684
  356. package/src/executors/bounded-exec/cpu-tokens.test.ts +0 -519
  357. package/src/executors/bounded-exec/disk-lease.test.ts +0 -219
  358. package/src/executors/bounded-exec/executor-host.test.ts +0 -800
  359. package/src/executors/bounded-exec/executor.test.ts +0 -1819
  360. package/src/executors/bounded-exec/go-progress-host.test.ts +0 -171
  361. package/src/executors/bounded-exec/hang-diagnostics.test.ts +0 -291
  362. package/src/executors/bounded-exec/progress.test.ts +0 -139
  363. package/src/executors/bounded-exec/ram-temp-held.test.ts +0 -264
  364. package/src/executors/bounded-exec/ram-temp-host.test.ts +0 -635
  365. package/src/executors/bounded-exec/ram-temp.test.ts +0 -750
  366. package/src/executors/bounded-exec/run-cpu-pool.test.ts +0 -79
  367. package/src/executors/bounded-exec/runner-hook.test.ts +0 -193
  368. package/src/executors/bounded-exec/runner-lifecycle.test.ts +0 -82
  369. package/src/executors/bounded-exec/verdict.test.ts +0 -545
  370. package/src/executors/cargo-zigbuild/executor.test.ts +0 -129
  371. package/src/executors/clean-outputs/executor.test.ts +0 -20
  372. package/src/executors/typescript-emit/executor.test.ts +0 -83
  373. package/src/failure-summary.ts +0 -119
  374. package/src/generators/bounded-test-targets/generator.test.ts +0 -138
  375. package/src/generators/bun-test-tracing/generator.test.ts +0 -250
  376. package/src/generators/create-package/generator.test.ts +0 -190
  377. package/src/generators/make-public/generator.test.ts +0 -137
  378. package/src/graph-input-contract.test.ts +0 -379
  379. package/src/host-controller-wiring.test.ts +0 -31
  380. package/src/index.test.ts +0 -3319
  381. package/src/linked-snapshots.nx.test.ts +0 -254
  382. package/src/managed-files/forgejo-artifact.test.ts +0 -395
  383. package/src/managed-files/generator.test.ts +0 -243
  384. package/src/managed-files/github-host-cache-isolation.test.ts +0 -86
  385. package/src/managed-files/json-edit.test.ts +0 -216
  386. package/src/managed-files/managed-content.test.ts +0 -166
  387. package/src/managed-files/managed-format-json.test.ts +0 -308
  388. package/src/managed-files/repo-path.test.ts +0 -172
  389. package/src/managed-files/setup-devenv-free-disk.test.ts +0 -95
  390. package/src/managed-files/trace-db-artifact.test.ts +0 -7
  391. package/src/managed-files/tree-permissions.test.ts +0 -109
  392. package/src/managed-files/tree.test.ts +0 -123
  393. package/src/manifest-hash.test.ts +0 -219
  394. package/src/nextest-code-bound.test.ts +0 -161
  395. package/src/nextest-extraction.test.ts +0 -216
  396. package/src/nextest-extraction.ts +0 -371
  397. package/src/nextest-partitions.test.ts +0 -501
  398. package/src/nx-cache-bound.test.ts +0 -109
  399. package/src/nx-cache-restore-mtime.test.ts +0 -170
  400. package/src/nx-daemon-claim.test.ts +0 -279
  401. package/src/nx-daemon-idle-cpu.test.ts +0 -80
  402. package/src/nx-daemon-idle-policy.test.ts +0 -111
  403. package/src/nx-daemon-ignore-files.test.ts +0 -210
  404. package/src/nx-daemon-root-normalization.test.ts +0 -105
  405. package/src/nx-daemon-start-never.test.ts +0 -292
  406. package/src/nx-daemon-validity.test.ts +0 -1055
  407. package/src/nx-dot-input-policy.test.ts +0 -353
  408. package/src/nx-failure-life-cycles.test.ts +0 -207
  409. package/src/nx-files-archive-racy.test.ts +0 -97
  410. package/src/nx-foreign-workspace-env.test.ts +0 -329
  411. package/src/nx-incomplete-run-summary.test.ts +0 -70
  412. package/src/nx-plugin-load-errors.test.ts +0 -120
  413. package/src/nx-project-graph-errors.test.ts +0 -70
  414. package/src/nx-project-resolution-cache.test.ts +0 -176
  415. package/src/nx-raw-inputs.test.ts +0 -166
  416. package/src/nx-resident-graph-workers.test.ts +0 -112
  417. package/src/nx-run-information.test.ts +0 -118
  418. package/src/nx-skipped-task-exit.test.ts +0 -180
  419. package/src/nx-state-location.test.ts +0 -63
  420. package/src/nx-store-resolution.test.ts +0 -81
  421. package/src/nx-task-graph-cycles.test.ts +0 -148
  422. package/src/nx-task-output-lease.test.ts +0 -550
  423. package/src/nx-use-local.test.ts +0 -105
  424. package/src/owned-installation.test.ts +0 -105
  425. package/src/package-target-policy.test.ts +0 -1014
  426. package/src/producer-receipts.test.ts +0 -285
  427. package/src/release-config-policy.test.ts +0 -311
  428. package/src/runtime-input.test.ts +0 -393
  429. package/src/serial-group-wiring.test.ts +0 -326
  430. package/src/task-history-namespace.test.ts +0 -181
  431. package/src/task-results.test.ts +0 -228
  432. package/src/test-clock-policy.test.ts +0 -338
  433. package/src/test-program.test.ts +0 -303
  434. package/src/test-timings.test.ts +0 -240
  435. package/src/test-walk-policy.test.ts +0 -620
  436. package/src/testing.test.ts +0 -509
  437. package/src/typecheck-test-policy.test.ts +0 -1468
  438. package/src/typescript-resolution.test.ts +0 -76
  439. package/src/version-actions.test.ts +0 -80
  440. package/src/workspace-config-policy.test.ts +0 -737
@@ -1,353 +0,0 @@
1
- import { expect, it } from 'bun:test';
2
- import { execFileSync, spawn, spawnSync } from 'node:child_process';
3
- import {
4
- appendFile,
5
- lstat,
6
- mkdir,
7
- mkdtemp,
8
- readFile,
9
- readlink,
10
- realpath,
11
- rm,
12
- symlink,
13
- writeFile,
14
- } from 'node:fs/promises';
15
- import { createRequire } from 'node:module';
16
- import { tmpdir } from 'node:os';
17
- import { dirname, join, relative, resolve } from 'node:path';
18
- import { createInterface } from 'node:readline';
19
- import { Watcher, WorkspaceContext } from 'nx/src/native/index.js';
20
- import { globWithWorkspaceContextSync, resetWorkspaceContext } from 'nx/src/utils/workspace-context.js';
21
- import { guardEvent } from './__tests__/counted-cargo.js';
22
- import { fixtureNxEnv, withNxFixture } from './__tests__/fixture-nx-env.js';
23
- import { awaitExit, processTable, terminate } from './testing.js';
24
-
25
- const repositoryRoot = join(import.meta.dir, '../../..');
26
- const lintScript = join(repositoryRoot, 'tooling/lint-dot-inputs.ts');
27
-
28
- // The root `.nxignore` before the dot-input policy: the cowshed runtime directory and
29
- // the devenv paths only, so every other untracked dot path was indexed. Comments omitted.
30
- const PREVIOUS_NXIGNORE = `modules/
31
- .cowshed/
32
- tooling/direnv/.devenv*/
33
- tooling/direnv/.direnv/
34
- `;
35
-
36
- // Untracked dot state a checkout accumulates: the daemon's and job records, editor and
37
- // Bun staging, devenv and direnv caches. None of it is a project input.
38
- const RUNTIME_DOT_STATE = [
39
- '.cowshed/cache/nx/workspace-data/d/daemon.log',
40
- '.cowshed/job/1/stdout.log',
41
- '.cowshed/run/supervisor.pid',
42
- '.icm-session/state.json',
43
- '.fseventsd/0000000000000001',
44
- '.proof-01234567.bun-build',
45
- 'tooling/direnv/.devenv/state/cache',
46
- 'tooling/direnv/.direnv/cache/env',
47
- ];
48
-
49
- // A tracked dot path the watcher must keep reporting: its own edit wakes the graph.
50
- const TRACKED_DOT_WRITE = '.github/workflows/ci.yml';
51
-
52
- function trackedDotPaths(): string[] {
53
- return execFileSync('git', ['ls-files', '-z', '--full-name'], { cwd: repositoryRoot, encoding: 'utf8' })
54
- .split('\0')
55
- .filter((path) => path.split('/').some((part) => part.startsWith('.')));
56
- }
57
-
58
- /**
59
- * A git checkout holding the repository's tracked dot inputs (same names, contents,
60
- * and symlinks) plus the runtime state above, under the given root `.nxignore`.
61
- */
62
- async function workspace(nxignore: string): Promise<string> {
63
- const root = await realpath(await mkdtemp(join(tmpdir(), 'nx-dot-input-policy-')));
64
- execFileSync('git', ['init', '--quiet', root], { stdio: 'pipe' });
65
- for (const path of trackedDotPaths()) {
66
- const source = join(repositoryRoot, path);
67
- const target = join(root, path);
68
- await mkdir(dirname(target), { recursive: true });
69
- if ((await lstat(source)).isSymbolicLink()) {
70
- const link = await readlink(source);
71
- const input = resolve(dirname(source), link);
72
- const inputPath = relative(repositoryRoot, input);
73
- if (inputPath.startsWith('..')) throw new Error(`tracked dot input ${path} links outside the checkout`);
74
- await mkdir(dirname(join(root, inputPath)), { recursive: true });
75
- await writeFile(join(root, inputPath), await readFile(input));
76
- await symlink(link, target);
77
- } else {
78
- await writeFile(target, await readFile(source));
79
- }
80
- }
81
- await writeFile(join(root, '.nxignore'), nxignore);
82
- execFileSync('git', ['add', '--force', '--', ...trackedDotPaths()], { cwd: root, stdio: 'pipe' });
83
- for (const path of RUNTIME_DOT_STATE) {
84
- await mkdir(dirname(join(root, path)), { recursive: true });
85
- await writeFile(join(root, path), `runtime ${path}\n`);
86
- }
87
- return root;
88
- }
89
-
90
- async function withWorkspace<T>(nxignore: string, use: (root: string) => Promise<T>): Promise<T> {
91
- const root = await workspace(nxignore);
92
- try {
93
- return await use(root);
94
- } finally {
95
- await rm(root, { recursive: true, force: true });
96
- }
97
- }
98
-
99
- /** The candidates Nx's workspace file index holds, as the project graph's file map sees them. */
100
- function indexed(root: string, candidates: string[]): string[] {
101
- resetWorkspaceContext();
102
- const matched = new Set(globWithWorkspaceContextSync(root, candidates));
103
- return candidates.filter((path) => matched.has(path)).sort();
104
- }
105
-
106
- /**
107
- * Paths the native watcher reports once `TRACKED_DOT_WRITE` changes, after the runtime
108
- * state is written. The watcher is the one the daemon subscribes to, with no filter of
109
- * its own: it reports whatever its `.nxignore` lets through.
110
- */
111
- async function reportedAfterWrites(root: string): Promise<string[]> {
112
- const reported = new Set<string>();
113
- const failures: string[] = [];
114
- let watcher: Watcher | undefined;
115
- let pending: { path: string; resolve(): void; reject(error: Error): void } | undefined;
116
- try {
117
- watcher = new Watcher(root);
118
- // Native watch() registers the filesystem subscription synchronously.
119
- watcher.watch((error, events) => {
120
- if (error !== null) {
121
- failures.push(error);
122
- pending?.reject(new Error(error));
123
- }
124
- for (const event of events) {
125
- reported.add(event.path);
126
- if (event.path === pending?.path) {
127
- pending.resolve();
128
- pending = undefined;
129
- }
130
- }
131
- });
132
- const observed = new Promise<void>((resolve, reject) => {
133
- pending = { path: TRACKED_DOT_WRITE, resolve, reject };
134
- });
135
- const writes = (async () => {
136
- for (const path of RUNTIME_DOT_STATE) await appendFile(join(root, path), 'round 1\n');
137
- await appendFile(join(root, TRACKED_DOT_WRITE), 'round 1\n');
138
- })();
139
- await guardEvent(Promise.all([observed, writes]), `native watcher callback for ${TRACKED_DOT_WRITE}`, () =>
140
- JSON.stringify({ pending: pending?.path, reported: [...reported], failures }),
141
- );
142
- for (const event of watcher.forceFlushPending()) reported.add(event.path);
143
- expect(failures).toEqual([]);
144
- return [...reported].sort();
145
- } finally {
146
- await watcher?.stop();
147
- }
148
- }
149
-
150
- function runLint(cwd: string) {
151
- return spawnSync(process.execPath, [lintScript], { cwd, encoding: 'utf8' });
152
- }
153
-
154
- it('indexes every tracked dot input and none of the untracked dot state', async () => {
155
- const tracked = trackedDotPaths();
156
- const candidates = [...tracked, ...RUNTIME_DOT_STATE];
157
- const nxignore = await readFile(join(repositoryRoot, '.nxignore'), 'utf8');
158
-
159
- const before = await withWorkspace(PREVIOUS_NXIGNORE, async (root) => indexed(root, candidates));
160
- // The previous policy indexed untracked dot state: the reproduction of the bug.
161
- expect(before).toContain('.icm-session/state.json');
162
- expect(before).toContain('.fseventsd/0000000000000001');
163
-
164
- const after = await withWorkspace(nxignore, async (root) => indexed(root, candidates));
165
- expect(after.filter((path) => !tracked.includes(path))).toEqual([]);
166
- // The policy changes the untracked state alone: every tracked input indexes as before.
167
- expect(after).toEqual(before.filter((path) => tracked.includes(path)));
168
- expect(after).toContain('.github/workflows/ci.yml');
169
- expect(after).toContain('.cargo/config.toml');
170
- });
171
-
172
- it('keeps the watcher reporting tracked dot inputs and silent about untracked dot state', async () => {
173
- const nxignore = await readFile(join(repositoryRoot, '.nxignore'), 'utf8');
174
-
175
- // The previous policy wakes the watcher on the daemon-style runtime writes.
176
- const previous = await withWorkspace(PREVIOUS_NXIGNORE, reportedAfterWrites);
177
- expect(previous).toContain('.icm-session/state.json');
178
-
179
- const current = await withWorkspace(nxignore, reportedAfterWrites);
180
- expect(current).toContain(TRACKED_DOT_WRITE);
181
- expect(current.filter((path) => RUNTIME_DOT_STATE.includes(path))).toEqual([]);
182
- });
183
-
184
- it('fails the lint when a tracked dot path lacks its re-include line, and passes with it', async () => {
185
- const nxignore = await readFile(join(repositoryRoot, '.nxignore'), 'utf8');
186
- const withoutGithub = nxignore.replace('!/.github\n', '');
187
- expect(withoutGithub).not.toBe(nxignore);
188
-
189
- await withWorkspace(withoutGithub, async (root) => {
190
- const result = runLint(root);
191
- expect(result.status).not.toBe(0);
192
- expect(result.stderr).toContain('missing "!/.github" after ".*"');
193
- expect(result.stderr).toContain(TRACKED_DOT_WRITE);
194
- });
195
-
196
- await withWorkspace(nxignore, async (root) => {
197
- const result = runLint(root);
198
- expect(result.stderr).toBe('');
199
- expect(result.status).toBe(0);
200
- });
201
-
202
- // The checkout itself must pass the same lint.
203
- const checkout = runLint(repositoryRoot);
204
- expect(checkout.stderr).toBe('');
205
- expect(checkout.status).toBe(0);
206
- });
207
-
208
- it('rejects a newly tracked dot input until its explicit negation is added', async () => {
209
- const nxignore = await readFile(join(repositoryRoot, '.nxignore'), 'utf8');
210
- await withWorkspace(nxignore, async (root) => {
211
- await writeFile(join(root, '.new-input'), 'tracked input\n');
212
- execFileSync('git', ['add', '--force', '.new-input'], { cwd: root });
213
- const missing = runLint(root);
214
- expect(missing.status).not.toBe(0);
215
- expect(missing.stderr).toContain('missing "!/.new-input"');
216
- await appendFile(join(root, '.nxignore'), '!/.new-input\n');
217
- const included = runLint(root);
218
- expect(included.status, included.stderr).toBe(0);
219
- });
220
- });
221
-
222
- it('preserves tracked input hashes and the graph while dot staging never causes graph passes', async () => {
223
- const nxignore = await readFile(join(repositoryRoot, '.nxignore'), 'utf8');
224
- await withNxFixture('nx-dot-graph-', async ({ workspace: root, socketDirectory }) => {
225
- const copied = await workspace(PREVIOUS_NXIGNORE);
226
- try {
227
- // Reuse the complete tracked-dot fixture, including real symlink targets.
228
- execFileSync('cp', ['-R', `${copied}/.`, root]);
229
- } finally {
230
- await rm(copied, { recursive: true, force: true });
231
- }
232
- await symlink(join(repositoryRoot, 'node_modules'), join(root, 'node_modules'), 'dir');
233
- await writeFile(join(root, 'nx.json'), '{}\n');
234
- await writeFile(join(root, 'package.json'), '{"name":"dot-graph-proof","private":true}\n');
235
- await mkdir(join(root, 'p'));
236
- await writeFile(join(root, 'p/project.json'), '{"name":"p","targets":{"check":{"executor":"nx:noop"}}}\n');
237
- const env = { ...fixtureNxEnv(root, socketDirectory), NX_DAEMON: 'true' };
238
- const nx = join(repositoryRoot, 'node_modules/.bin/nx');
239
- const graphPath = join(root, '.nx/graph.json');
240
- const graph = async () => {
241
- const result = spawnSync('node', [nx, 'graph', '--file', graphPath], { cwd: root, env, encoding: 'utf8' });
242
- expect(result.status, result.stdout + result.stderr).toBe(0);
243
- const parsed: unknown = JSON.parse(await readFile(graphPath, 'utf8'));
244
- return parsed;
245
- };
246
- const tracked = new Set(trackedDotPaths().filter((path) => path !== '.nxignore'));
247
- // The policy file intentionally changes; all other tracked input bytes do not.
248
- const beforeHashes = Object.fromEntries(
249
- new WorkspaceContext(root, join(root, '.nx/hash-proof'))
250
- .allFileData()
251
- .filter(({ file }) => tracked.has(file))
252
- .map(({ file, hash }) => [file, hash]),
253
- );
254
- const beforeGraph = await graph();
255
- const previous: unknown = JSON.parse(
256
- await readFile(join(root, '.nx/workspace-data/d/server-process.json'), 'utf8'),
257
- );
258
- if (
259
- typeof previous !== 'object' ||
260
- previous === null ||
261
- !('processId' in previous) ||
262
- typeof previous.processId !== 'number'
263
- ) {
264
- throw new Error('the graph proof did not start its owned daemon');
265
- }
266
- const beforeProcesses = (await processTable()).filter(({ pid }) => pid === previous.processId);
267
- await writeFile(join(root, '.nxignore'), nxignore);
268
- // Let the old startup ignore snapshot retire before requesting the new graph.
269
- await awaitExit(beforeProcesses, 'the daemon whose ignore policy changed');
270
- const started = spawnSync('node', [nx, 'daemon', '--start'], { cwd: root, env, encoding: 'utf8' });
271
- expect(started.status, started.stdout + started.stderr).toBe(0);
272
- const afterGraph = await graph();
273
- expect(afterGraph).toEqual(beforeGraph);
274
- const afterHashes = Object.fromEntries(
275
- new WorkspaceContext(root, join(root, '.nx/hash-proof'))
276
- .allFileData()
277
- .filter(({ file }) => tracked.has(file))
278
- .map(({ file, hash }) => [file, hash]),
279
- );
280
- expect(afterHashes).toEqual(beforeHashes);
281
- expect(Object.keys(beforeHashes)).toContain(TRACKED_DOT_WRITE);
282
- const logPath = join(root, '.nx/workspace-data/d/daemon.log');
283
- const passes = async () =>
284
- (await readFile(logPath, 'utf8'))
285
- .split('\n')
286
- .filter((line) => line.includes('Updated workspace context based on watched changes')).length;
287
- // IPC readiness and callbacks prove the daemon routed the native batch;
288
- // a log append alone is not a client readiness signal.
289
- const clientPath = createRequire(import.meta.url).resolve('nx/src/daemon/client/client');
290
- const observer = spawn(
291
- 'node',
292
- [
293
- '-e',
294
- `
295
- const { daemonClient } = require(${JSON.stringify(clientPath)});
296
- daemonClient.registerFileWatcher({ watchProjects: 'all', includeGlobalWorkspaceFiles: true }, (error, data) => {
297
- if (error !== null) { console.log('error:' + error); process.exit(1); }
298
- for (const { path } of data.changedFiles) console.log(path);
299
- }).then(() => console.log('ready'), error => { console.log('error:' + error); process.exit(1); });
300
- `,
301
- ],
302
- { cwd: root, env, stdio: ['ignore', 'pipe', 'pipe'] },
303
- );
304
- let stderr = '';
305
- observer.stderr.setEncoding('utf8').on('data', (text: string) => {
306
- stderr += text;
307
- });
308
- const ended = new Promise<void>((resolve) => observer.once('exit', () => resolve()));
309
- const lines = createInterface({ input: observer.stdout })[Symbol.asyncIterator]();
310
- try {
311
- const ready = await guardEvent(lines.next(), 'the daemon file watcher to register', () => stderr);
312
- expect(ready.done).toBe(false);
313
- expect(ready.value, stderr).toBe('ready');
314
- const beforePasses = await passes();
315
- for (const path of RUNTIME_DOT_STATE) await appendFile(join(root, path), 'staging write\n');
316
- // The real graph request flushes the daemon's pending native watch batch.
317
- expect(await graph()).toEqual(afterGraph);
318
- const ignoredPasses = await passes();
319
- expect(ignoredPasses).toBe(beforePasses);
320
- await appendFile(join(root, TRACKED_DOT_WRITE), '\n# tracked edit\n');
321
- for (;;) {
322
- const changed = await guardEvent(
323
- lines.next(),
324
- `the daemon watcher to report ${TRACKED_DOT_WRITE}`,
325
- () => stderr,
326
- );
327
- if (changed.done || changed.value.startsWith('error:')) {
328
- throw new Error(`daemon watcher ended before the tracked edit: ${changed.value}\n${stderr}`);
329
- }
330
- if (changed.value === TRACKED_DOT_WRITE) break;
331
- }
332
- await graph();
333
- const trackedPasses = await passes();
334
- expect(trackedPasses).toBeGreaterThan(beforePasses);
335
- console.log(
336
- JSON.stringify({
337
- proof: 'nx-dot-input-policy',
338
- trackedDotPaths: tracked.size + 1,
339
- unchangedFileHashes: Object.keys(beforeHashes).length,
340
- unchangedGraph: true,
341
- beforePasses,
342
- ignoredPasses,
343
- trackedPasses,
344
- runtimePaths: RUNTIME_DOT_STATE,
345
- }),
346
- );
347
- } finally {
348
- if (observer.pid !== undefined && observer.exitCode === null && observer.signalCode === null)
349
- terminate(observer.pid);
350
- await ended;
351
- }
352
- });
353
- });
@@ -1,207 +0,0 @@
1
- import { Database } from 'bun:sqlite';
2
- import { expect, it } from 'bun:test';
3
- import { spawnSync } from 'node:child_process';
4
- import { mkdir, readdir, readFile, writeFile } from 'node:fs/promises';
5
- import { join } from 'node:path';
6
- import { fixtureNxEnv, withNxFixture } from './__tests__/fixture-nx-env.js';
7
-
8
- /**
9
- * Guards the complete pre-start failure boundary in the installed Nx patch, not only StoreRunInformationLifeCycle.
10
- * A hash failure has neither an execution start nor a hash: retain its failure in run.json, but do not invent a
11
- * native/legacy execution-history row, elapsed duration or executed profile interval. Valid database failures still
12
- * propagate. Drop these hunks only when upstream supports the same lifecycle ordering, retaining these regressions.
13
- */
14
- const nxRoot = join(import.meta.dir, '../../../node_modules/nx/dist/src');
15
-
16
- const setup = `
17
- const assert = require('node:assert/strict');
18
- const fs = require('node:fs');
19
- const path = require('node:path');
20
- const nx = (file) => require(path.join(${JSON.stringify(nxRoot)}, file));
21
- const { CompositeLifeCycle } = nx('tasks-runner/life-cycle.js');
22
- const { StoreRunInformationLifeCycle } = nx('tasks-runner/life-cycles/store-run-information-life-cycle.js');
23
- const makeTask = (id, timing = {}) => ({
24
- id: 'p:' + id, target: { project: 'p', target: id }, overrides: {}, outputs: [], cache: false, ...timing,
25
- });
26
- const unstarted = makeTask('unstarted', { endTime: 125 });
27
- const hashedUnstarted = makeTask('hashed-unstarted', { hash: 'hashed-unstarted', endTime: 125 });
28
- const unhashedStarted = makeTask('unhashed-started', { startTime: 100, endTime: 125 });
29
- const supplied = makeTask('supplied', { hash: 'supplied', startTime: 0, endTime: 125 });
30
- const notified = makeTask('notified', { hash: 'notified' });
31
- const stored = [];
32
- const store = new StoreRunInformationLifeCycle('hash failure regression', (run) => stored.push(run));
33
- async function complete(reporter) {
34
- const lifecycle = new CompositeLifeCycle([store, reporter]);
35
- await lifecycle.startCommand();
36
- await lifecycle.startTasks([notified, unhashedStarted], { groupId: 0 });
37
- notified.endTime = Date.now();
38
- await lifecycle.endTasks([
39
- { task: unstarted, status: 'failure', code: 1, terminalOutput: 'HASH_TASKS write EPIPE' },
40
- { task: hashedUnstarted, status: 'failure', code: 1 },
41
- { task: unhashedStarted, status: 'failure', code: 1 },
42
- { task: supplied, status: 'success', code: 0 },
43
- { task: notified, status: 'success', code: 0 },
44
- ], { groupId: 0 });
45
- await lifecycle.endCommand();
46
- assert.equal(unstarted.startTime, undefined);
47
- assert.equal(unstarted.hash, undefined);
48
- const failedRun = stored[0].tasks.find((task) => task.taskId === unstarted.id);
49
- assert.equal(failedRun.status, 1);
50
- assert.equal(failedRun.startTime, undefined);
51
- assert.equal(failedRun.hash, undefined);
52
- assert.equal(stored[0].tasks.find((task) => task.taskId === supplied.id).startTime, '1970-01-01T00:00:00.000Z');
53
- fs.writeFileSync('stored-run.json', JSON.stringify(stored));
54
- }
55
- `;
56
-
57
- async function fixture(body: (root: string, env: Record<string, string>) => Promise<void>) {
58
- await withNxFixture('nx-failure-lifecycle-', async ({ workspace, socketDirectory }) => {
59
- await mkdir(join(workspace, '.nx/workspace-data'), { recursive: true });
60
- await writeFile(join(workspace, 'package.json'), '{"name":"failure-lifecycle-fixture","private":true}\n');
61
- await writeFile(join(workspace, 'nx.json'), '{}\n');
62
- await body(workspace, fixtureNxEnv(workspace, socketDirectory));
63
- });
64
- }
65
-
66
- function run(root: string, env: Record<string, string>, program: string) {
67
- const child = spawnSync('node', ['-e', `${setup}\n${program}`], { cwd: root, env, encoding: 'utf8' });
68
- if (child.error) throw child.error;
69
- expect(child.signal, child.stdout + child.stderr).toBeNull();
70
- return child;
71
- }
72
-
73
- async function expectStoredFailure(root: string) {
74
- const stored: unknown = JSON.parse(await readFile(join(root, 'stored-run.json'), 'utf8'));
75
- expect(stored).toMatchObject([
76
- {
77
- tasks: [
78
- { taskId: 'p:unstarted', status: 1, endTime: '1970-01-01T00:00:00.125Z' },
79
- { taskId: 'p:hashed-unstarted', status: 1 },
80
- { taskId: 'p:unhashed-started', status: 1 },
81
- { taskId: 'p:supplied', status: 0 },
82
- { taskId: 'p:notified', status: 0 },
83
- ],
84
- },
85
- ]);
86
- }
87
-
88
- it('completes Store plus native task history without fabricating hash/start, retaining valid history', async () => {
89
- await fixture(async (root, env) => {
90
- const child = run(
91
- root,
92
- env,
93
- `
94
- const { TaskDetails } = nx('native/index.js');
95
- const { getDbConnection } = nx('utils/db-connection.js');
96
- new TaskDetails(getDbConnection()).recordTaskDetails([
97
- { hash: 'supplied', project: 'p', target: 'supplied' },
98
- { hash: 'notified', project: 'p', target: 'notified' },
99
- ]);
100
- const { getTasksHistoryLifeCycle } = nx('tasks-runner/life-cycles/task-history-life-cycle.js');
101
- const history = getTasksHistoryLifeCycle();
102
- complete(history).then(() => assert.deepEqual(history.startTimings, {}));
103
- `,
104
- );
105
- expect(child.status, child.stdout + child.stderr).toBe(0);
106
- await expectStoredFailure(root);
107
- const files = (await readdir(join(root, '.nx/workspace-data'))).filter((file) => file.endsWith('.db'));
108
- expect(files).toHaveLength(1);
109
- const file = files[0];
110
- if (file === undefined) throw new Error('no fixture Nx history database');
111
- const database = new Database(join(root, '.nx/workspace-data', file), { readwrite: true });
112
- try {
113
- expect(
114
- database
115
- .query<{ hash: string; status: string; code: number }, []>(
116
- 'SELECT hash, status, code FROM task_history ORDER BY hash',
117
- )
118
- .all(),
119
- ).toEqual([
120
- { hash: 'notified', status: 'success', code: 0 },
121
- { hash: 'supplied', status: 'success', code: 0 },
122
- ]);
123
- } finally {
124
- database.close();
125
- }
126
- });
127
- });
128
-
129
- it('completes Store plus legacy task history without fabricating hash/start, retaining valid history', async () => {
130
- await fixture(async (root, env) => {
131
- const child = run(
132
- root,
133
- env,
134
- `
135
- const { LegacyTaskHistoryLifeCycle } = nx('tasks-runner/life-cycles/task-history-life-cycle-old.js');
136
- const history = new LegacyTaskHistoryLifeCycle();
137
- complete(history).then(() => assert.deepEqual(history.startTimings, {}));
138
- `,
139
- );
140
- expect(child.status, child.stdout + child.stderr).toBe(0);
141
- await expectStoredFailure(root);
142
- const lines = (await readFile(join(root, '.nx/workspace-data/task-history.csv'), 'utf8')).trim().split('\n');
143
- expect(lines).toHaveLength(3);
144
- expect(lines[0]).toBe('project,target,configuration,hash,code,status,start,end');
145
- expect(lines[1]).toBe('p,supplied,,supplied,0,success,0,125');
146
- expect(lines[2]).toMatch(/^p,notified,,notified,0,success,\d+,\d+$/);
147
- });
148
- });
149
-
150
- it('completes Store plus timing diagnostics with null duration for an unstarted task', async () => {
151
- await fixture(async (root, env) => {
152
- const child = run(
153
- root,
154
- env,
155
- `
156
- const { TaskTimingsLifeCycle } = nx('tasks-runner/life-cycles/task-timings-life-cycle.js');
157
- complete(new TaskTimingsLifeCycle());
158
- `,
159
- );
160
- expect(child.status, child.stdout + child.stderr).toBe(0);
161
- await expectStoredFailure(root);
162
- expect(child.stdout).toContain('"p:unstarted": null');
163
- expect(child.stdout).toContain('"p:hashed-unstarted": null');
164
- expect(child.stdout).toContain('"p:unhashed-started": 25');
165
- expect(child.stdout).toContain('"p:supplied": 125');
166
- });
167
- });
168
-
169
- it('completes Store plus profiling without inventing an executed interval', async () => {
170
- await fixture(async (root, env) => {
171
- const child = run(
172
- root,
173
- env,
174
- `
175
- const { TaskProfilingLifeCycle } = nx('tasks-runner/life-cycles/task-profiling-life-cycle.js');
176
- complete(new TaskProfilingLifeCycle('profile.json'));
177
- `,
178
- );
179
- expect(child.status, child.stdout + child.stderr).toBe(0);
180
- await expectStoredFailure(root);
181
- const profile: unknown = JSON.parse(await readFile(join(root, 'profile.json'), 'utf8'));
182
- expect(profile).toEqual([
183
- expect.objectContaining({ ph: 'M', name: 'thread_name' }),
184
- expect.objectContaining({ ph: 'X', name: 'p:unhashed-started', ts: 100000, dur: 25000 }),
185
- expect.objectContaining({ ph: 'X', name: 'p:supplied', ts: 0, dur: 125000 }),
186
- expect.objectContaining({ ph: 'X', name: 'p:notified', dur: expect.any(Number) }),
187
- ]);
188
- });
189
- });
190
-
191
- it('does not suppress a genuine history database failure for a hashed started task', async () => {
192
- await fixture(async (root, env) => {
193
- const child = run(
194
- root,
195
- env,
196
- `
197
- const { getTasksHistoryLifeCycle } = nx('tasks-runner/life-cycles/task-history-life-cycle.js');
198
- const history = getTasksHistoryLifeCycle();
199
- history.endTasks([{ task: supplied, status: 'success', code: 0 }])
200
- .then(() => history.endCommand());
201
- `,
202
- );
203
- expect(child.status).toBe(1);
204
- expect(child.stderr).toContain('FOREIGN KEY');
205
- expect(child.stderr).not.toContain('Missing field');
206
- });
207
- });
@@ -1,97 +0,0 @@
1
- import { expect, it } from 'bun:test';
2
- import { mkdir, readFile, symlink, utimes, writeFile } from 'node:fs/promises';
3
- import { dirname, join } from 'node:path';
4
- import { fileURLToPath } from 'node:url';
5
- import { fixtureNxEnv, withNxFixture } from './__tests__/fixture-nx-env.js';
6
-
7
- /**
8
- * Guards the racy-archive hunk of `patches/nx@23.2.1.patch`. Every Nx 23.2.1
9
- * context (each daemonless run, and the daemon at its start) hashes the
10
- * workspace's files through `<workspace-data>/nx_files.nxt`, which on Unix
11
- * keeps each file's hash beside its mtime in whole seconds, and reuses an
12
- * archived hash while that second is unchanged (`selective_files_hash`; size
13
- * and nanoseconds are not compared). A file written again in the second it
14
- * was hashed in keeps its mtime, so the next run hashes it as the bytes it
15
- * replaced: a revert replays the cache entry of the edit it reverts, and a
16
- * new edit hits the old entry. The patch applies Git's racy-index rule: an
17
- * archive holding an mtime from the seconds its own hashing pass ran in, or
18
- * later, is not trusted, and every file is hashed again.
19
- *
20
- * The case writes each input with a fixed mtime second and gives the archive
21
- * the same second, as if the input had been written and hashed in the second
22
- * the archive was written: the race, without depending on the clock. Last,
23
- * an input dated a minute ahead of the archive, as under a clock that runs
24
- * ahead, is rewritten under that date.
25
- */
26
-
27
- const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)));
28
- const repoRoot = dirname(dirname(packageRoot));
29
- const nxEntry = join(repoRoot, 'node_modules', '.bin', 'nx');
30
-
31
- it('hashes an input rewritten in the second its archived hash was taken', async () => {
32
- await withNxFixture('nx-files-archive-racy-', async ({ workspace, socketDirectory }) => {
33
- await mkdir(join(workspace, 'app'), { recursive: true });
34
- const git = Bun.spawnSync(['git', 'init', '--quiet', workspace]);
35
- expect(git.exitCode, git.stderr.toString()).toBe(0);
36
- // The repository's own node_modules: the Nx under test.
37
- await symlink(join(repoRoot, 'node_modules'), join(workspace, 'node_modules'), 'dir');
38
- await writeFile(join(workspace, 'nx.json'), JSON.stringify({ cacheDirectory: '.nx/cache' }));
39
- await writeFile(
40
- join(workspace, 'app', 'project.json'),
41
- JSON.stringify({
42
- name: 'app',
43
- targets: {
44
- build: {
45
- executor: 'nx:run-commands',
46
- cache: true,
47
- inputs: ['{projectRoot}/source.txt'],
48
- outputs: ['{projectRoot}/result.txt'],
49
- options: { cwd: 'app', command: 'cp source.txt result.txt' },
50
- },
51
- },
52
- }),
53
- );
54
- // The output stays out of the file hashes and every other file is dated an hour back, so only
55
- // the input's dates come near an archive's write.
56
- await writeFile(join(workspace, '.gitignore'), 'app/result.txt\n');
57
- const anHourAgo = Math.floor(Date.now() / 1000) - 3600;
58
- for (const file of ['.gitignore', 'nx.json', 'app/project.json']) {
59
- await utimes(join(workspace, file), anHourAgo, anHourAgo);
60
- }
61
- const env = fixtureNxEnv(workspace, socketDirectory);
62
- const source = join(workspace, 'app', 'source.txt');
63
- const archive = join(env.NX_WORKSPACE_DATA_DIRECTORY, 'nx_files.nxt');
64
- // Writes the input dated `second`, builds, and reports the log and the output.
65
- const build = async (text: string, second: number) => {
66
- await writeFile(source, text);
67
- await utimes(source, second, second);
68
- const ran = Bun.spawnSync(['bun', nxEntry, 'run', 'app:build', '--outputStyle=static'], { cwd: workspace, env });
69
- const log = `${ran.stdout}${ran.stderr}`;
70
- expect(ran.exitCode, log).toBe(0);
71
- return { log, result: await readFile(join(workspace, 'app', 'result.txt'), 'utf8') };
72
- };
73
-
74
- const first = Math.floor(Date.now() / 1000) - 60;
75
- expect((await build('A', first)).result).toBe('A');
76
- const second = first + 1;
77
- expect((await build('B', second)).result).toBe('B');
78
-
79
- // The archive written in B's second, then a revert to A within that second: A's entry, never B's.
80
- await utimes(archive, second, second);
81
- const reverted = await build('A', second);
82
- expect(reverted.result).toBe('A');
83
-
84
- // Again, and a new edit within that second: no entry at all.
85
- await utimes(archive, second, second);
86
- const edited = await build('C', second);
87
- expect(edited.log).not.toContain('[local cache]');
88
- expect(edited.result).toBe('C');
89
-
90
- // An input dated ahead of the archive's write, rewritten under that date: no entry either.
91
- const ahead = Math.floor(Date.now() / 1000) + 60;
92
- expect((await build('D', ahead)).result).toBe('D');
93
- const skewed = await build('E', ahead);
94
- expect(skewed.log).not.toContain('[local cache]');
95
- expect(skewed.result).toBe('E');
96
- });
97
- });