@smoothbricks/nx-plugin 0.4.26 → 0.4.28

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 (343) hide show
  1. package/README.md +994 -117
  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 +15 -73
  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 +3 -2
  21. package/dist/cargo-closure-input.d.ts.map +1 -1
  22. package/dist/cargo-closure-input.js +16 -15
  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 +43 -6
  27. package/dist/cargo-source-hash.d.ts.map +1 -1
  28. package/dist/cargo-source-hash.js +309 -73
  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 +101 -5
  33. package/dist/cargo-workspace.d.ts.map +1 -1
  34. package/dist/cargo-workspace.js +291 -10
  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 +207 -12
  48. package/dist/ensure-built.d.ts.map +1 -1
  49. package/dist/ensure-built.js +576 -202
  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 +370 -138
  102. package/dist/managed-files/ci-workflow.d.ts +13 -0
  103. package/dist/managed-files/ci-workflow.d.ts.map +1 -1
  104. package/dist/managed-files/ci-workflow.js +44 -13
  105. package/dist/managed-files/files.d.ts +7 -1
  106. package/dist/managed-files/files.d.ts.map +1 -1
  107. package/dist/managed-files/files.js +62 -8
  108. package/dist/managed-files/json-edit.d.ts +21 -0
  109. package/dist/managed-files/json-edit.d.ts.map +1 -0
  110. package/dist/managed-files/json-edit.js +295 -0
  111. package/dist/managed-files/managed-format.d.ts +33 -1
  112. package/dist/managed-files/managed-format.d.ts.map +1 -1
  113. package/dist/managed-files/managed-format.js +82 -2
  114. package/dist/managed-files/pr-preview-cleanup-workflow.d.ts +7 -0
  115. package/dist/managed-files/pr-preview-cleanup-workflow.d.ts.map +1 -1
  116. package/dist/managed-files/pr-preview-cleanup-workflow.js +68 -4
  117. package/dist/managed-files/publish-workflow.d.ts.map +1 -1
  118. package/dist/managed-files/publish-workflow.js +231 -48
  119. package/dist/managed-files/tree.d.ts +5 -0
  120. package/dist/managed-files/tree.d.ts.map +1 -1
  121. package/dist/managed-files/tree.js +5 -3
  122. package/dist/manifest-hash.d.ts.map +1 -1
  123. package/dist/manifest-hash.js +2 -5
  124. package/dist/nextest-code-bound.d.ts +62 -0
  125. package/dist/nextest-code-bound.d.ts.map +1 -0
  126. package/dist/nextest-code-bound.js +154 -0
  127. package/dist/nextest-extraction.d.ts +24 -8
  128. package/dist/nextest-extraction.d.ts.map +1 -1
  129. package/dist/nextest-extraction.js +42 -7
  130. package/dist/package-target-policy.d.ts.map +1 -1
  131. package/dist/package-target-policy.js +3 -5
  132. package/dist/release-config-policy.d.ts.map +1 -1
  133. package/dist/release-config-policy.js +3 -5
  134. package/dist/runtime-input.d.ts +14 -0
  135. package/dist/runtime-input.d.ts.map +1 -0
  136. package/dist/runtime-input.js +15 -0
  137. package/dist/rust-tokens.d.ts +11 -0
  138. package/dist/rust-tokens.d.ts.map +1 -0
  139. package/dist/rust-tokens.js +81 -0
  140. package/dist/task-results.d.ts +6 -0
  141. package/dist/task-results.d.ts.map +1 -0
  142. package/dist/task-results.js +61 -0
  143. package/dist/test-program.d.ts +54 -0
  144. package/dist/test-program.d.ts.map +1 -0
  145. package/dist/test-program.js +292 -0
  146. package/dist/test-timings.d.ts +71 -0
  147. package/dist/test-timings.d.ts.map +1 -0
  148. package/dist/test-timings.js +393 -0
  149. package/dist/test-walk-policy.d.ts +103 -0
  150. package/dist/test-walk-policy.d.ts.map +1 -0
  151. package/dist/test-walk-policy.js +657 -0
  152. package/dist/testing.d.ts +177 -0
  153. package/dist/testing.d.ts.map +1 -0
  154. package/dist/testing.js +824 -0
  155. package/dist/type-guards.d.ts +3 -0
  156. package/dist/type-guards.d.ts.map +1 -0
  157. package/dist/type-guards.js +4 -0
  158. package/dist/typecheck-test-policy.d.ts +8 -5
  159. package/dist/typecheck-test-policy.d.ts.map +1 -1
  160. package/dist/typecheck-test-policy.js +113 -100
  161. package/dist/workspace-config-policy.d.ts +8 -0
  162. package/dist/workspace-config-policy.d.ts.map +1 -1
  163. package/dist/workspace-config-policy.js +175 -63
  164. package/dist/workspace-index.d.ts +12 -0
  165. package/dist/workspace-index.d.ts.map +1 -0
  166. package/dist/workspace-index.js +17 -0
  167. package/dist/workspace-manifest.d.ts +37 -0
  168. package/dist/workspace-manifest.d.ts.map +1 -1
  169. package/executors.json +5 -0
  170. package/loader.js +13 -11
  171. package/managed/raw/envrc +33 -67
  172. package/managed/raw/git-format-staged.yml +30 -35
  173. package/managed/raw/patches/nx@23.2.1.patch +3484 -0
  174. package/managed/raw/tooling/direnv/apple-developer.sh +83 -0
  175. package/managed/raw/tooling/direnv/developer-links.ts +569 -11
  176. package/managed/raw/tooling/direnv/devenv.smoo.nix +314 -93
  177. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -11
  178. package/managed/raw/tooling/direnv/linked-snapshots.ts +845 -0
  179. package/managed/raw/tooling/direnv/nx-socket-dir.sh +82 -0
  180. package/managed/raw/tooling/direnv/repo-path +14 -2
  181. package/managed/raw/tooling/direnv/setup-environment.ts +1146 -159
  182. package/managed/raw/tooling/direnv/toolchain-stamp.ts +45 -3
  183. package/managed/raw/tooling/direnv/ttsc-env.sh +39 -0
  184. package/managed/raw/tooling/git-hooks/commit-msg.sh +5 -6
  185. package/managed/raw/tooling/git-hooks/pre-commit.sh +7 -6
  186. package/managed/raw/tooling/git-hooks/pre-push.sh +20 -15
  187. package/managed/templates/github/actions/cache-nix-devenv/action.yml +6 -6
  188. package/managed/templates/github/actions/cache-node-modules/action.yml +6 -4
  189. package/managed/templates/github/actions/cache-nx/action.yml +1 -1
  190. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +1 -1
  191. package/managed/templates/github/actions/forgejo-artifact.cjs +99 -0
  192. package/managed/templates/github/actions/forgejo-download-artifact/action.yml +49 -0
  193. package/managed/templates/github/actions/forgejo-download-artifact/index.cjs +7 -0
  194. package/managed/templates/github/actions/forgejo-upload-artifact/action.yml +65 -0
  195. package/managed/templates/github/actions/forgejo-upload-artifact/index.cjs +7 -0
  196. package/managed/templates/github/actions/setup-devenv/action.yml +21 -3
  197. package/managed/templates/github/workflows/managed-files.yml +1 -2
  198. package/nextest.toml +8 -41
  199. package/package.json +74 -12
  200. package/runtime-input.sh +81 -0
  201. package/src/__tests__/counted-cargo.ts +33 -14
  202. package/src/__tests__/fixture-nx-env.ts +111 -46
  203. package/src/__tests__/progress-clock.ts +43 -0
  204. package/src/__tests__/runtime-input.ts +23 -0
  205. package/src/bin/smoo-nx-bound-failures.test.ts +127 -0
  206. package/src/bin/smoo-nx-bound-failures.ts +33 -0
  207. package/src/bin/smoo-nx-cargo-hash.ts +28 -3
  208. package/src/bin/smoo-nx-exec.ts +16 -74
  209. package/src/bin/smoo-nx-failures.ts +4 -0
  210. package/src/bin/smoo-nx-nextest-extract.ts +3 -2
  211. package/src/bin/smoo-nx-test-walks.ts +42 -0
  212. package/src/bounded-test-policy.test.ts +268 -21
  213. package/src/bounded-test-policy.ts +114 -42
  214. package/src/build-state-output-policy.test.ts +115 -0
  215. package/src/build-state-output-policy.ts +90 -0
  216. package/src/bun-bootstrap.test.ts +57 -3
  217. package/src/bun-file-packages.test.ts +47 -0
  218. package/src/cargo-closure-input.test.ts +138 -66
  219. package/src/cargo-closure-input.ts +17 -15
  220. package/src/cargo-dev-profile.ts +137 -0
  221. package/src/cargo-resolve-cache.test.ts +70 -1
  222. package/src/cargo-source-hash.test.ts +193 -97
  223. package/src/cargo-source-hash.ts +345 -68
  224. package/src/cargo-toolchain-policy.ts +6 -0
  225. package/src/cargo-workspace.test.ts +320 -0
  226. package/src/cargo-workspace.ts +336 -10
  227. package/src/cross-check-policy.test.ts +59 -1
  228. package/src/cross-check-policy.ts +25 -6
  229. package/src/disk-command-policy.test.ts +61 -0
  230. package/src/disk-command-policy.ts +107 -0
  231. package/src/ensure-built-receipt.test.ts +184 -0
  232. package/src/ensure-built-receipt.ts +263 -0
  233. package/src/ensure-built-witness.test.ts +344 -0
  234. package/src/ensure-built-witness.ts +252 -0
  235. package/src/ensure-built.test.ts +1036 -578
  236. package/src/ensure-built.ts +820 -224
  237. package/src/eslint-file-set.ts +9 -0
  238. package/src/executors/bounded-exec/cpu-pool.test.ts +454 -0
  239. package/src/executors/bounded-exec/cpu-pool.ts +417 -0
  240. package/src/executors/bounded-exec/cpu-tokens.test.ts +269 -0
  241. package/src/executors/bounded-exec/cpu-tokens.ts +177 -0
  242. package/src/executors/bounded-exec/disk-lease.test.ts +185 -0
  243. package/src/executors/bounded-exec/disk-lease.ts +139 -0
  244. package/src/executors/bounded-exec/executor-host.test.ts +778 -0
  245. package/src/executors/bounded-exec/executor.test.ts +1116 -63
  246. package/src/executors/bounded-exec/executor.ts +565 -67
  247. package/src/executors/bounded-exec/gateway-lease.ts +176 -0
  248. package/src/executors/bounded-exec/hang-diagnostics.test.ts +285 -0
  249. package/src/executors/bounded-exec/hang-diagnostics.ts +283 -0
  250. package/src/executors/bounded-exec/progress.test.ts +79 -0
  251. package/src/executors/bounded-exec/progress.ts +118 -0
  252. package/src/executors/bounded-exec/ram-temp-fixtures.ts +12 -0
  253. package/src/executors/bounded-exec/ram-temp-held.test.ts +264 -0
  254. package/src/executors/bounded-exec/ram-temp-held.ts +242 -0
  255. package/src/executors/bounded-exec/ram-temp-host.test.ts +605 -0
  256. package/src/executors/bounded-exec/ram-temp.test.ts +674 -0
  257. package/src/executors/bounded-exec/ram-temp.ts +1918 -0
  258. package/src/executors/bounded-exec/schema.json +11 -5
  259. package/src/executors/bounded-exec/schema.ts +27 -11
  260. package/src/executors/bounded-exec/verdict.test.ts +440 -0
  261. package/src/executors/bounded-exec/verdict.ts +433 -0
  262. package/src/executors/shard-timings/executor.ts +36 -0
  263. package/src/executors/shard-timings/schema.json +21 -0
  264. package/src/executors/shard-timings/schema.ts +4 -0
  265. package/src/failure-summary.ts +119 -0
  266. package/src/generators/bounded-test-targets/generator.test.ts +4 -4
  267. package/src/generators/bun-test-tracing/generator.test.ts +2 -2
  268. package/src/generators/create-package/generator.test.ts +6 -0
  269. package/src/generators/create-package/generator.ts +6 -2
  270. package/src/host-controller-wiring.test.ts +31 -0
  271. package/src/index.test.ts +909 -295
  272. package/src/index.ts +441 -143
  273. package/src/linked-snapshots.nx.test.ts +172 -0
  274. package/src/managed-files/ci-workflow.ts +54 -13
  275. package/src/managed-files/files.ts +65 -9
  276. package/src/managed-files/forgejo-artifact.test.ts +395 -0
  277. package/src/managed-files/generator.test.ts +60 -1
  278. package/src/managed-files/json-edit.test.ts +216 -0
  279. package/src/managed-files/json-edit.ts +290 -0
  280. package/src/managed-files/managed-format-json.test.ts +308 -0
  281. package/src/managed-files/managed-format.ts +90 -2
  282. package/src/managed-files/pr-preview-cleanup-workflow.ts +69 -3
  283. package/src/managed-files/publish-workflow.ts +285 -67
  284. package/src/managed-files/repo-path.test.ts +129 -0
  285. package/src/managed-files/trace-db-artifact.test.ts +7 -0
  286. package/src/managed-files/tree.ts +11 -3
  287. package/src/manifest-hash.ts +2 -6
  288. package/src/nextest-code-bound.test.ts +155 -0
  289. package/src/nextest-code-bound.ts +195 -0
  290. package/src/nextest-extraction.test.ts +37 -5
  291. package/src/nextest-extraction.ts +51 -9
  292. package/src/nextest-partitions.test.ts +427 -82
  293. package/src/nx-cache-bound.test.ts +5 -10
  294. package/src/nx-cache-restore-mtime.test.ts +170 -0
  295. package/src/nx-daemon-claim.test.ts +277 -0
  296. package/src/nx-daemon-idle-cpu.test.ts +81 -0
  297. package/src/nx-daemon-idle-policy.test.ts +51 -0
  298. package/src/nx-daemon-ignore-files.test.ts +210 -0
  299. package/src/nx-daemon-root-normalization.test.ts +105 -0
  300. package/src/nx-daemon-validity.test.ts +925 -0
  301. package/src/nx-dot-input-policy.test.ts +353 -0
  302. package/src/nx-failure-life-cycles.test.ts +207 -0
  303. package/src/nx-files-archive-racy.test.ts +97 -0
  304. package/src/nx-foreign-workspace-env.test.ts +329 -0
  305. package/src/nx-incomplete-run-summary.test.ts +70 -0
  306. package/src/nx-plugin-load-errors.test.ts +120 -0
  307. package/src/nx-project-resolution-cache.test.ts +176 -0
  308. package/src/nx-raw-inputs.test.ts +166 -0
  309. package/src/nx-resident-graph-workers.test.ts +7 -16
  310. package/src/nx-run-information.test.ts +118 -0
  311. package/src/nx-skipped-task-exit.test.ts +180 -0
  312. package/src/nx-state-location.test.ts +63 -0
  313. package/src/nx-store-resolution.test.ts +26 -25
  314. package/src/nx-task-graph-cycles.test.ts +148 -0
  315. package/src/nx-task-output-lease.test.ts +414 -0
  316. package/src/nx-use-local.test.ts +103 -0
  317. package/src/package-target-policy.ts +3 -6
  318. package/src/release-config-policy.ts +3 -6
  319. package/src/runtime-input.test.ts +215 -0
  320. package/src/runtime-input.ts +17 -0
  321. package/src/rust-tokens.ts +78 -0
  322. package/src/serial-group-wiring.test.ts +326 -0
  323. package/src/task-history-namespace.test.ts +87 -89
  324. package/src/task-results.test.ts +226 -0
  325. package/src/task-results.ts +75 -0
  326. package/src/test-program.test.ts +303 -0
  327. package/src/test-program.ts +341 -0
  328. package/src/test-timings.test.ts +240 -0
  329. package/src/test-timings.ts +311 -0
  330. package/src/test-walk-policy.test.ts +585 -0
  331. package/src/test-walk-policy.ts +731 -0
  332. package/src/testing.test.ts +509 -0
  333. package/src/testing.ts +922 -0
  334. package/src/type-guards.ts +4 -0
  335. package/src/typecheck-test-policy.test.ts +496 -11
  336. package/src/typecheck-test-policy.ts +137 -103
  337. package/src/workspace-config-policy.test.ts +212 -13
  338. package/src/workspace-config-policy.ts +101 -73
  339. package/src/workspace-index.ts +18 -0
  340. package/src/workspace-manifest.ts +41 -0
  341. package/test-timings.json +85 -30
  342. package/managed/raw/tooling/direnv/inherited-devenv.ts +0 -665
  343. package/managed/raw/tooling/direnv/shared-caches.sh +0 -53
@@ -1,7 +1,8 @@
1
1
  /* biome-ignore-all lint/suspicious/noTemplateCurlyInString: GitHub Actions expressions are emitted literally. */
2
+ import { isMap, isScalar, parseDocument } from 'yaml';
2
3
  import { LINUX_PLATFORM_TARGET_GLOBS, MACOS_PLATFORM_TARGET_GLOBS, RELEASE_CONFIGURATION, } from '../platform-targets.js';
3
4
  import { isSmoothBricksCodebasePackageName } from '../workspace-package-policy.js';
4
- import { artifactStepLines, CiWorkflowStepKind, cargoCredentialJobEnvLines, cargoCredentialStepLines, deployStepSecretEnvLines, remoteCacheJobEnvLines, sourceCheckoutsStepLines, } from './ci-workflow.js';
5
+ import { artifactStepLines, CiWorkflowStepKind, cargoCredentialJobEnvLines, cargoCredentialStepLines, deployStepSecretEnvLines, githubActionPins, remoteCacheJobEnvLines, sourceCheckoutsStepLines, TRACE_DB_ARTIFACT_GLOB, } from './ci-workflow.js';
5
6
  import { GITHUB_HOSTED_LINUX_RUNNER, renderRunsOnLine } from './github-runs-on.js';
6
7
  /**
7
8
  * Carried by every step that builds what ships: the build aggregate and each
@@ -268,7 +269,11 @@ function shouldRunStep(step, version, failed, inputs, plan = version) {
268
269
  */
269
270
  export function renderPublishWorkflowYaml(options = {}) {
270
271
  if (options.release === false) {
271
- return `${renderPublishWorkflowHeader(options)}${renderPublishWorkflowSteps(definePublishWorkflow(options).steps, options)}`;
272
+ const steps = definePublishWorkflow(options).steps;
273
+ const rendered = skipsPublishHandoff(options) && options.platformProducer !== undefined
274
+ ? renderSingleJobPublishWorkflowSteps(steps, options)
275
+ : renderPublishWorkflowSteps(steps, options);
276
+ return `${renderPublishWorkflowHeader(options)}${rendered}`;
272
277
  }
273
278
  if (hasMacosPlatformTargets(options) && !skipsPublishHandoff(options)) {
274
279
  return renderPlatformPublishWorkflowYaml(options);
@@ -277,7 +282,9 @@ export function renderPublishWorkflowYaml(options = {}) {
277
282
  // runner. Splitting jobs then buys nothing and costs a real transfer: the
278
283
  // outputs get tarred, uploaded, downloaded into a second checkout, and two
279
284
  // more devenv setups pay for themselves twice. One job, no artifacts.
280
- if (hasMacosPlatformTargets(options) || hasLinuxPlatformTargets(options)) {
285
+ if (hasMacosPlatformTargets(options) ||
286
+ hasLinuxPlatformTargets(options) ||
287
+ (skipsPublishHandoff(options) && options.platformProducer !== undefined)) {
281
288
  return `${renderPublishWorkflowHeader(options)}${renderSingleJobPublishWorkflowSteps(definePublishWorkflow(options).steps, options)}`;
282
289
  }
283
290
  return `${renderPublishWorkflowHeader(options)}${renderPublishWorkflowSteps(definePublishWorkflow(options).steps, options)}`;
@@ -335,8 +342,10 @@ defaults:
335
342
  jobs:
336
343
  publish:
337
344
  ${options.release === false ? renderRunsOnLine(options.runsOn) : publishJobRunsOnLine(options)}
345
+ timeout-minutes: ${options.platformTargetGlobs?.length ? 90 : 45}
338
346
  env:
339
- GH_TOKEN: ${githubExpression('github.token')}${remoteCacheJobEnv(options)}${cargoCredentialsJobEnv(options)}${privateNpmInstallJobEnv(options)}${platformProducerJobEnv(options)}
347
+ LMAO_GIT_REVISION: ${githubExpression('github.sha')}
348
+ GH_TOKEN: ${githubExpression('github.token')}${remoteCacheJobEnv(options)}${cargoCredentialsJobEnv(options)}${privateNpmInstallJobEnv(options)}
340
349
  steps:
341
350
  `;
342
351
  }
@@ -390,10 +399,15 @@ function yamlLinesForStep(step, options) {
390
399
  case PublishWorkflowStepKind.Checkout:
391
400
  return [
392
401
  ` - name: ${step.name}`,
393
- ' uses: actions/checkout@v6.0.2',
402
+ ` uses: ${githubActionPins.checkout.ref} # ${githubActionPins.checkout.version}`,
394
403
  ' with:',
395
- ' filter: blob:none',
396
404
  ' fetch-depth: 0',
405
+ ...(options.release === false
406
+ ? [' persist-credentials: false']
407
+ : [
408
+ ' # smoo publish and pending-release repair push release refs.',
409
+ ' persist-credentials: true',
410
+ ]),
397
411
  ];
398
412
  case PublishWorkflowStepKind.SourceCheckouts:
399
413
  return siblingSourceCheckoutStepLines(options);
@@ -435,16 +449,20 @@ function yamlLinesForStep(step, options) {
435
449
  return [
436
450
  ` - name: ${step.name}`,
437
451
  ' id: plan',
452
+ ' env:',
453
+ ` SMOO_RELEASE_PROJECTS: ${githubExpression('inputs.projects')}`,
438
454
  ' run:',
439
- ` smoo release version --bump "${githubExpression('inputs.bump')}" --projects "${githubExpression('inputs.projects')}" --dry-run "true" --github-output`,
455
+ ` smoo release version --bump "${githubExpression('inputs.bump')}" --projects "$SMOO_RELEASE_PROJECTS" --dry-run "true" --github-output`,
440
456
  ' "$GITHUB_OUTPUT"',
441
457
  ];
442
458
  case PublishWorkflowStepKind.VersionRelease:
443
459
  return [
444
460
  ` - name: ${step.name}`,
445
461
  ' id: version',
462
+ ' env:',
463
+ ` SMOO_RELEASE_PROJECTS: ${githubExpression('inputs.projects')}`,
446
464
  ' run:',
447
- ` smoo release version --bump "${githubExpression('inputs.bump')}" --projects "${githubExpression('inputs.projects')}" --dry-run "${githubExpression('inputs.dry_run')}" --github-output`,
465
+ ` smoo release version --bump "${githubExpression('inputs.bump')}" --projects "$SMOO_RELEASE_PROJECTS" --dry-run "${githubExpression('inputs.dry_run')}" --github-output`,
448
466
  ' "$GITHUB_OUTPUT"',
449
467
  ];
450
468
  case PublishWorkflowStepKind.CheckManagedMonorepoFiles:
@@ -460,7 +478,7 @@ function yamlLinesForStep(step, options) {
460
478
  case PublishWorkflowStepKind.UploadTraceDbs:
461
479
  return artifactStepLines(options.actionsProvider, step.name, 'upload', [
462
480
  `name: trace-results-${githubExpression('github.run_id')}`,
463
- 'path: packages/*/.cache/trace-results.db*',
481
+ `path: ${TRACE_DB_ARTIFACT_GLOB}`,
464
482
  'if-no-files-found: ignore',
465
483
  'retention-days: 14',
466
484
  'include-hidden-files: true',
@@ -582,26 +600,41 @@ function remoteCacheJobEnv(options) {
582
600
  }
583
601
  function renderSingleJobPublishWorkflowSteps(steps, options) {
584
602
  const lines = [];
585
- const producer = options.platformProducer;
586
- const crossOnThisRunner = skipsPublishHandoff(options) && hasMacosPlatformTargets(options);
603
+ const handoffSkipped = skipsPublishHandoff(options);
604
+ // The declared producer runs only in a job that skips the publish handoff; any other
605
+ // single job renders without it, and so without its environment.
606
+ const producer = handoffSkipped ? options.platformProducer : undefined;
607
+ const crossOnThisRunner = handoffSkipped && hasMacosPlatformTargets(options);
608
+ let stepNumber = 2;
587
609
  for (const step of steps) {
588
- lines.push(...sectionLinesBefore(step));
589
- lines.push(...commentLinesForStep(step));
590
- lines.push(...yamlLinesForStep(step, options));
610
+ const numberedStep = { ...step, number: stepNumber++ };
611
+ lines.push(...sectionLinesBefore(numberedStep));
612
+ lines.push(...commentLinesForStep(numberedStep));
613
+ lines.push(...yamlLinesForStep(numberedStep, options));
591
614
  lines.push('');
592
- if (crossOnThisRunner && producer && step.kind === PublishWorkflowStepKind.Checkout) {
593
- // Before any toolchain setup or build, exactly as the dedicated producer
594
- // job ordered it: the SDK has to be on disk before devenv resolves it.
595
- lines.push(' - name: Check cross-platform toolchain prerequisites', ' working-directory: .', ' run: |', ' set -euo pipefail', ...producer.preflight.split('\n').map((line) => ` ${line}`), '');
615
+ if (producer && step.kind === PublishWorkflowStepKind.Checkout) {
616
+ // A declared producer always runs, even when the graph selects no platform family.
617
+ lines.push(' # Step ' + stepNumber++, ...platformProducerPreflightStepLines(producer), '');
596
618
  }
597
- if (step.kind === PublishWorkflowStepKind.Build) {
598
- lines.push(' - name: 🐧 Build supplemental Linux targets', " if: steps.version.outputs.mode != 'none'", ` run: smoo github-ci nx-run-many --targets "${LINUX_PLATFORM_TARGET_GLOBS.join(',')}" --projects "${githubExpression('steps.version.outputs.projects')}" ${RELEASE_BUILD_ARGUMENT}`, '');
619
+ if (step.kind === PublishWorkflowStepKind.Build &&
620
+ (hasMacosPlatformTargets(options) || hasLinuxPlatformTargets(options))) {
621
+ lines.push(' # Step ' + stepNumber++, ' - name: 🐧 Build supplemental Linux targets', " if: steps.version.outputs.mode != 'none'", ' run:', ' smoo github-ci nx-run-many --targets "' +
622
+ LINUX_PLATFORM_TARGET_GLOBS.join(',') +
623
+ '" --projects "' +
624
+ githubExpression('steps.version.outputs.projects') +
625
+ '" ' +
626
+ RELEASE_BUILD_ARGUMENT, '');
599
627
  if (crossOnThisRunner) {
600
- lines.push(' - name: 🍎 Build selected macOS and iOS release outputs', " if: steps.version.outputs.mode != 'none'", ` run: smoo github-ci nx-run-many --targets "${macosPlatformFamilies(options).join(',')}" --projects "${githubExpression('steps.version.outputs.projects')}" ${RELEASE_BUILD_ARGUMENT}`, '');
628
+ lines.push(' # Step ' + stepNumber++, ' - name: 🍎 Build selected macOS and iOS release outputs', " if: steps.version.outputs.mode != 'none'", ' run:', ' smoo github-ci nx-run-many --targets "' +
629
+ macosPlatformFamilies(options).join(',') +
630
+ '" --projects "' +
631
+ githubExpression('steps.version.outputs.projects') +
632
+ '" ' +
633
+ RELEASE_BUILD_ARGUMENT, '');
601
634
  }
602
635
  }
603
636
  }
604
- return `${lines.join('\n').trimEnd()}\n`;
637
+ return mergeProducerStepEnvironment(lines, producer).join('\n').trimEnd() + '\n';
605
638
  }
606
639
  function renderPlatformPublishWorkflowYaml(options) {
607
640
  const deployInput = options.deploy === true
@@ -650,6 +683,7 @@ defaults:
650
683
  jobs:
651
684
  linux-release-candidate:
652
685
  ${renderRunsOnLine(options.runsOn)}
686
+ timeout-minutes: 45
653
687
  permissions:
654
688
  contents: write
655
689
  id-token: none
@@ -657,30 +691,32 @@ ${renderRunsOnLine(options.runsOn)}
657
691
  mode: ${githubExpression('steps.version.outputs.mode')}
658
692
  release-sha: ${githubExpression('steps.release-state.outputs.sha')}
659
693
  env:
694
+ LMAO_GIT_REVISION: ${githubExpression('github.sha')}
660
695
  GH_TOKEN: ${githubExpression('github.token')}${remoteCacheJobEnv(options)}${cargoCredentialsJobEnv(options)}${privateNpmInstallJobEnv(options)}
661
696
  steps:
662
697
  ${renderLinuxReleaseCandidateSteps(steps, options)}
663
698
 
664
699
  ${options.platformProducer?.kind === 'linux-cross' ? 'cross-platform' : 'macos-platform'}:
665
700
  ${renderMacosJobHeaderLines(options)}
701
+ timeout-minutes: 90
666
702
  permissions:
667
703
  contents: read
668
704
  id-token: none
669
705
  env:
706
+ LMAO_GIT_REVISION: ${githubExpression('github.sha')}
670
707
  GH_TOKEN: ${githubExpression('github.token')}${remoteCacheJobEnv(options)}${cargoCredentialsJobEnv(options)}${privateNpmInstallJobEnv(options)}
671
- ${Object.entries(options.platformProducer?.env ?? {})
672
- .map(([name, value]) => ` ${name}: ${JSON.stringify(value)}`)
673
- .join('\n')}
674
708
  steps:
675
709
  ${renderMacosPlatformSteps(options)}
676
710
 
677
711
  publish-on-linux:
678
712
  needs: [linux-release-candidate, ${options.platformProducer?.kind === 'linux-cross' ? 'cross-platform' : 'macos-platform'}]
679
713
  ${publishJobRunsOnLine(options)}
714
+ timeout-minutes: 45
680
715
  permissions:
681
716
  contents: write
682
717
  id-token: write
683
718
  env:
719
+ LMAO_GIT_REVISION: ${githubExpression('github.sha')}
684
720
  TTSC_TSGO_BINARY: ${githubExpression('github.workspace')}/node_modules/@typescript/native/bin/tsc
685
721
  GH_TOKEN: ${githubExpression('github.token')}${remoteCacheJobEnv(options)}${cargoCredentialsJobEnv(options)}${privateNpmInstallJobEnv(options)}
686
722
  steps:
@@ -709,7 +745,7 @@ function renderLinuxReleaseCandidateSteps(steps, options) {
709
745
  lines.push(` # Step ${stepNumber}`);
710
746
  }
711
747
  if (step.kind === PublishWorkflowStepKind.Checkout) {
712
- lines.push(` - name: ${step.name}`, ' uses: actions/checkout@v6.0.2', ' with:', ` ref: ${githubExpression('github.sha')}`, ' filter: blob:none', ' fetch-depth: 0');
748
+ lines.push(` - name: ${step.name}`, ` uses: ${githubActionPins.checkout.ref} # ${githubActionPins.checkout.version}`, ' with:', ` ref: ${githubExpression('github.sha')}`, ' fetch-depth: 0', ' # No remote is read or written from this job: the clone is complete and the', ' # candidate commit leaves only as the transferred bundle.', ' persist-credentials: false');
713
749
  }
714
750
  else if (step.kind === PublishWorkflowStepKind.Build) {
715
751
  lines.push(` - name: ${step.name}`, " if: steps.version.outputs.mode != 'none'", ' run:', ` smoo github-ci nx-run-many --targets build --projects "${githubExpression('steps.version.outputs.projects')}" ${RELEASE_BUILD_ARGUMENT} --collect-outputs "${githubExpression('runner.temp')}/release-build-outputs"`);
@@ -760,17 +796,17 @@ function renderMacosPlatformSteps(options) {
760
796
  ' # Step 1: GitHub adds "Set up job" automatically',
761
797
  ' # Step 2',
762
798
  ' - name: 📥 Checkout dispatch commit',
763
- ' uses: actions/checkout@v6.0.2',
799
+ ` uses: ${githubActionPins.checkout.ref} # ${githubActionPins.checkout.version}`,
764
800
  ' with:',
765
801
  ` ref: ${githubExpression('github.sha')}`,
766
- ' filter: blob:none',
767
802
  ' fetch-depth: 0',
803
+ ' # build-platform-outputs fetches the release branch and tags from origin',
804
+ ' # (packages/cli/src/release/index.ts:335). This job pushes nothing, but a private origin refuses',
805
+ ' # that fetch without the checkout credential, so it stays persisted.',
806
+ ' persist-credentials: true',
768
807
  ];
769
808
  if (options.platformProducer) {
770
- if (!options.platformProducer.preflight.trim()) {
771
- throw new Error('Linux cross-platform production requires a nonempty toolchain preflight command.');
772
- }
773
- lines.push('', ` # Step ${stepNumber++}`, ' - name: Check cross-platform toolchain prerequisites', ' working-directory: .', ' run: |', ' set -euo pipefail', ...options.platformProducer.preflight.split('\n').map((line) => ` ${line}`));
809
+ lines.push('', ` # Step ${stepNumber++}`, ...platformProducerPreflightStepLines(options.platformProducer));
774
810
  }
775
811
  const macosCargoCredentials = cargoCredentialsStepLines(options);
776
812
  if (macosCargoCredentials.length > 0) {
@@ -784,7 +820,7 @@ function renderMacosPlatformSteps(options) {
784
820
  if (isSmoothBricksCodebasePackageName(options.repoName)) {
785
821
  lines.push('', ` # Step ${stepNumber++}`, ' - name: 🏗️ Build smoo Nx version actions', ' # Nx Release loads @smoothbricks/nx-plugin/version-actions through the', ' # export map in its own node process, and versioning runs before the', ' # build phase, so the hook must exist in dist first. Downstream', ' # consumers install the published package and skip this bootstrap.', ' #', ' # `nx` cannot do it: the project graph loads this very plugin, so', ' # `nx build nx-plugin` deadlocks on the executor it is building.', ' # ttsc needs only the package tsconfig -- same bootstrap the devenv', ' # shell runs (tooling/direnv/enter-shell.ts).', ' working-directory: packages/nx-plugin', ' run: ttsc -p tsconfig.lib.json --emit');
786
822
  }
787
- lines.push('', ` # Step ${stepNumber++}`, ' - name: 🤖 Configure release author', ' run:', ' git config user.name "github-actions[bot]" && git config user.email', ' "41898282+github-actions[bot]@users.noreply.github.com"', '', ` # Step ${stepNumber++}`, ' - name: 🔢 Version release', ' id: version', ' run:', ` smoo release version --bump "${githubExpression('inputs.bump')}" --projects "${githubExpression('inputs.projects')}" --dry-run "${githubExpression('inputs.dry_run')}" --github-output`, ' "$GITHUB_OUTPUT"');
823
+ lines.push('', ` # Step ${stepNumber++}`, ' - name: 🤖 Configure release author', ' run:', ' git config user.name "github-actions[bot]" && git config user.email', ' "41898282+github-actions[bot]@users.noreply.github.com"', '', ` # Step ${stepNumber++}`, ' - name: 🔢 Version release', ' id: version', ' env:', ` SMOO_RELEASE_PROJECTS: ${githubExpression('inputs.projects')}`, ' run:', ` smoo release version --bump "${githubExpression('inputs.bump')}" --projects "$SMOO_RELEASE_PROJECTS" --dry-run "${githubExpression('inputs.dry_run')}" --github-output`, ' "$GITHUB_OUTPUT"');
788
824
  const architectures = macosPlatformArchitectures(options);
789
825
  const isMatrix = architectures.length >= 2;
790
826
  const testArchitecture = macosTestArchitecture(architectures);
@@ -792,7 +828,7 @@ function renderMacosPlatformSteps(options) {
792
828
  const testCondition = isMatrix && testArchitecture !== undefined
793
829
  ? `matrix.arch == '${testArchitecture}' && steps.platform-outputs.outputs.projects != ''`
794
830
  : `steps.platform-outputs.outputs.projects != ''`;
795
- lines.push('', ` # Step ${stepNumber++}`, ` - name: 🍎 Build selected macOS and iOS release outputs${legLabel}`, ' id: platform-outputs', ' run:', ` smoo release build-platform-outputs --bump "${githubExpression('inputs.bump')}" --projects "${githubExpression('inputs.projects')}" --ref "${githubExpression('github.sha')}" --targets "${macosPlatformTargetSelector(options)}" --output`, ` "${githubExpression('runner.temp')}/macos-platform-outputs" --github-output "$GITHUB_OUTPUT"`);
831
+ lines.push('', ` # Step ${stepNumber++}`, ` - name: 🍎 Build selected macOS and iOS release outputs${legLabel}`, ' id: platform-outputs', ' env:', ` SMOO_RELEASE_PROJECTS: ${githubExpression('inputs.projects')}`, ' run:', ` smoo release build-platform-outputs --bump "${githubExpression('inputs.bump')}" --projects "$SMOO_RELEASE_PROJECTS" --ref "${githubExpression('github.sha')}" --targets "${macosPlatformTargetSelector(options)}" --output`, ` "${githubExpression('runner.temp')}/macos-platform-outputs" --github-output "$GITHUB_OUTPUT"`);
796
832
  if (options.platformProducer?.kind !== 'linux-cross') {
797
833
  lines.push('', ` # Step ${stepNumber++}`, ' - name: 🧪 Unit test selected macOS and iOS packages');
798
834
  if (isMatrix) {
@@ -809,7 +845,7 @@ function renderMacosPlatformSteps(options) {
809
845
  'retention-days: 1',
810
846
  'include-hidden-files: true',
811
847
  ]), '', ' # --- Cleanup ------------------------------------------------------------', '', ` # Step ${stepNumber}`, ' - name: 🧹 Cleanup and cache Nix/devenv', ' # success() is default; always() still saves GH Nix cache after a red job.', ' if: always()', ' uses: ./.github/actions/save-nix-devenv', ' with:', ` devenv-cache-hit: ${githubExpression('steps.setup.outputs.devenv-cache-hit')}`);
812
- return lines.join('\n').trimEnd();
848
+ return mergeProducerStepEnvironment(lines, options.platformProducer).join('\n').trimEnd();
813
849
  }
814
850
  function renderFinalLinuxPublishSteps(options) {
815
851
  const mode = 'needs.linux-release-candidate.outputs.mode';
@@ -820,11 +856,12 @@ function renderFinalLinuxPublishSteps(options) {
820
856
  ' # Step 1: GitHub adds "Set up job" automatically',
821
857
  ` # Step ${stepNumber++}`,
822
858
  ' - name: 📥 Checkout dispatch commit',
823
- ' uses: actions/checkout@v6.0.2',
859
+ ` uses: ${githubActionPins.checkout.ref} # ${githubActionPins.checkout.version}`,
824
860
  ' with:',
825
861
  ` ref: ${githubExpression('github.sha')}`,
826
- ' filter: blob:none',
827
862
  ' fetch-depth: 0',
863
+ ' # smoo publish and pending-release repair push release refs.',
864
+ ' persist-credentials: true',
828
865
  ];
829
866
  const publishCargoCredentials = cargoCredentialsStepLines(options);
830
867
  if (publishCargoCredentials.length > 0) {
@@ -966,20 +1003,166 @@ function skipsPublishHandoff(options) {
966
1003
  }
967
1004
  return !hasMacosPlatformTargets(options) || options.platformProducer?.kind === 'linux-cross';
968
1005
  }
1006
+ /** Names become YAML keys of every step's `env:`, so only portable identifiers are admissible. */
1007
+ const PLATFORM_PRODUCER_ENV_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
969
1008
  /**
970
- * Toolchain environment for a foreign-platform producer, rendered onto whichever
971
- * job runs its builds. In the flattened single-job shape that is the publish job
972
- * itself, so the SDK path and cross flags have to reach it the same way the
973
- * dedicated producer job received them.
1009
+ * The producer's toolchain preflight, shared by the dedicated producer job and
1010
+ * the flattened single job. It is an ordinary step of that job: the declared
1011
+ * environment reaches it through `mergeProducerStepEnvironment` exactly as it
1012
+ * reaches every other step, so the preflight checks the toolchain the build sees.
974
1013
  */
975
- function platformProducerJobEnv(options) {
976
- const producer = options.platformProducer;
977
- if (!producer || !skipsPublishHandoff(options)) {
978
- return '';
1014
+ function platformProducerPreflightStepLines(producer) {
1015
+ if (!producer.preflight.trim()) {
1016
+ throw new Error('Linux cross-platform production requires a nonempty toolchain preflight command.');
1017
+ }
1018
+ return [
1019
+ ' - name: Check cross-platform toolchain prerequisites',
1020
+ ' working-directory: .',
1021
+ ' run: |',
1022
+ ' set -euo pipefail',
1023
+ ...producer.preflight.split('\n').map((line) => ` ${line}`),
1024
+ ];
1025
+ }
1026
+ /**
1027
+ * The declared variables, each proved a valid key of a step `env:`. GitHub
1028
+ * rejects mapping keys that differ only by case as duplicates, so such a pair
1029
+ * cannot share one env mapping: it fails here, naming both, not in CI.
1030
+ */
1031
+ function platformProducerEnvEntries(producer) {
1032
+ const entries = Object.entries(producer?.env ?? {});
1033
+ const byUpperCase = new Map();
1034
+ for (const [name] of entries) {
1035
+ if (!PLATFORM_PRODUCER_ENV_NAME.test(name)) {
1036
+ throw new Error(`smoo.github.platformProducer.env name ${JSON.stringify(name)} is not a valid environment variable name.`);
1037
+ }
1038
+ const upper = name.toUpperCase();
1039
+ const twin = byUpperCase.get(upper);
1040
+ if (twin !== undefined) {
1041
+ throw new Error(`smoo.github.platformProducer.env names ${JSON.stringify(twin)} and ${JSON.stringify(name)} differ only by case, which GitHub Actions rejects as a duplicate env key.`);
1042
+ }
1043
+ byUpperCase.set(upper, name);
979
1044
  }
980
- return Object.entries(producer.env ?? {})
981
- .map(([name, value]) => `\n ${name}: ${JSON.stringify(value)}`)
982
- .join('');
1045
+ return entries;
1046
+ }
1047
+ /** A top-level step opens with exactly this prefix, and its own env mapping with exactly this header. */
1048
+ const RENDERED_STEP_OPENER = ' - name:';
1049
+ const RENDERED_STEP_ENV_HEADER = ' env:';
1050
+ /**
1051
+ * The producer's declared environment, carried by every step of its job as that
1052
+ * step's own `env:`.
1053
+ *
1054
+ * Step env is the one transport that carries every declarable name: GitHub
1055
+ * forbids `NODE_OPTIONS` in `GITHUB_ENV`, and a job-level `env` cannot evaluate
1056
+ * the `runner` context an SDK path under `runner.temp` needs. A step's own fields
1057
+ * win: a variable the step already scopes (release inputs, the publisher
1058
+ * credential, Cargo and source-checkout secrets) keeps its value and only the
1059
+ * producer's copy is omitted from that step, so no step carries a key twice.
1060
+ * What cannot be carried fails generation naming the declared variables and the
1061
+ * step: a step-local key equal to a declared name ignoring case (GitHub rejects
1062
+ * such duplicates), or an `env:` this function cannot read.
1063
+ *
1064
+ * `lines` are the renderer's own fragments, not arbitrary YAML: every top-level
1065
+ * step opens with exactly ` - name:` and its own env is exactly
1066
+ * ` env:` with entries nested deeper. Only that block is parsed, and only
1067
+ * for its keys; every existing line and comment is kept as written.
1068
+ */
1069
+ function mergeProducerStepEnvironment(lines, producer) {
1070
+ const entries = platformProducerEnvEntries(producer);
1071
+ if (entries.length === 0) {
1072
+ return lines;
1073
+ }
1074
+ const merged = [];
1075
+ let steps = 0;
1076
+ let index = 0;
1077
+ while (index < lines.length) {
1078
+ const line = lines[index];
1079
+ if (!line.startsWith(RENDERED_STEP_OPENER)) {
1080
+ if (/^ {6}- /.test(line)) {
1081
+ throw producerEnvMergeError(entries, `generated step ${JSON.stringify(line.trim())}`, 'a top-level step must open with "- name:"');
1082
+ }
1083
+ merged.push(line);
1084
+ index += 1;
1085
+ continue;
1086
+ }
1087
+ // A step runs until the next non-blank line indented no deeper than its opener:
1088
+ // the next step, or the anchor comment above it.
1089
+ let end = index + 1;
1090
+ while (end < lines.length && (lines[end].trim() === '' || /^ {7}/.test(lines[end]))) {
1091
+ end += 1;
1092
+ }
1093
+ merged.push(...mergeStepEnvironment(lines.slice(index, end), entries));
1094
+ steps += 1;
1095
+ index = end;
1096
+ }
1097
+ if (steps === 0) {
1098
+ throw producerEnvMergeError(entries, 'the rendered job', 'it has no step to carry the environment');
1099
+ }
1100
+ return merged;
1101
+ }
1102
+ /**
1103
+ * One step's lines with the producer's variables added to its own `env:`. A step
1104
+ * without one gets an empty header under its opener, so both shapes merge the
1105
+ * same way; the step's own keys win.
1106
+ */
1107
+ function mergeStepEnvironment(step, entries) {
1108
+ const where = `generated step ${JSON.stringify(step[0].slice(RENDERED_STEP_OPENER.length).trim())}`;
1109
+ const envFields = step.flatMap((line, index) => (/^ {8}env:/.test(line) ? [index] : []));
1110
+ if (envFields.length > 1) {
1111
+ throw producerEnvMergeError(entries, where, 'it declares env more than once');
1112
+ }
1113
+ const lines = envFields.length === 0 ? [step[0], RENDERED_STEP_ENV_HEADER, ...step.slice(1)] : step;
1114
+ const header = envFields.length === 0 ? 1 : envFields[0];
1115
+ if (lines[header] !== RENDERED_STEP_ENV_HEADER) {
1116
+ throw producerEnvMergeError(entries, where, `its env field ${JSON.stringify(lines[header])} is not a block mapping header`);
1117
+ }
1118
+ // Entries are indented deeper than the header; the block ends at the next field or step comment.
1119
+ let end = header + 1;
1120
+ while (end < lines.length && /^ {9}/.test(lines[end])) {
1121
+ end += 1;
1122
+ }
1123
+ const ownKeys = envFields.length === 0
1124
+ ? []
1125
+ : stepEnvKeys(lines.slice(header, end), (reason, cause) => producerEnvMergeError(entries, where, reason, cause));
1126
+ const stamped = [];
1127
+ for (const entry of entries) {
1128
+ const [name, value] = entry;
1129
+ const ownKey = ownKeys.find((key) => key.toUpperCase() === name.toUpperCase());
1130
+ if (ownKey === undefined) {
1131
+ stamped.push(` ${JSON.stringify(name)}: ${JSON.stringify(value)}`);
1132
+ }
1133
+ else if (ownKey !== name) {
1134
+ throw producerEnvMergeError([entry], where, `its own env key ${JSON.stringify(ownKey)} differs from the declared name only by case, which GitHub Actions rejects as a duplicate key`);
1135
+ }
1136
+ }
1137
+ return [...lines.slice(0, header + 1), ...stamped, ...lines.slice(header + 1)];
1138
+ }
1139
+ /** The keys of one step's own `env:` block, read by the YAML parser; the block's lines stay as written. */
1140
+ function stepEnvKeys(block, fail) {
1141
+ const document = parseDocument(block.join('\n'), { prettyErrors: false });
1142
+ if (document.errors.length > 0) {
1143
+ const reasons = document.errors.map((error) => `${error.message} (${error.code})`).join('; ');
1144
+ throw fail(`its env block is not valid YAML: ${reasons}`, document.errors[0]);
1145
+ }
1146
+ const root = document.contents;
1147
+ const field = isMap(root) ? root.items.find((item) => isScalar(item.key) && item.key.value === 'env') : undefined;
1148
+ const env = field?.value;
1149
+ if (env === null || (isScalar(env) && env.value === null)) {
1150
+ return [];
1151
+ }
1152
+ if (!isMap(env)) {
1153
+ throw fail('its env block is not a mapping');
1154
+ }
1155
+ return env.items.map((pair) => {
1156
+ const key = pair.key;
1157
+ if (!isScalar(key) || typeof key.value !== 'string') {
1158
+ throw fail('its env block has a key that is not a string', pair);
1159
+ }
1160
+ return key.value;
1161
+ });
1162
+ }
1163
+ function producerEnvMergeError(entries, where, reason, cause) {
1164
+ const names = entries.map(([name]) => JSON.stringify(name)).join(', ');
1165
+ return new Error(`smoo.github.platformProducer.env ${names} cannot be merged into ${where}: ${reason}.`, cause === undefined ? undefined : { cause });
983
1166
  }
984
1167
  function privateNpmInstallJobEnv(options) {
985
1168
  const tokenEnv = options.privateNpm?.readTokenEnv;
@@ -4,6 +4,11 @@ export interface ManagedFile {
4
4
  target: string;
5
5
  content: string | null;
6
6
  executable?: boolean;
7
+ /**
8
+ * Why a `null` content is null, when the generator chose not to write a target
9
+ * it would otherwise own. Reported on the `skipped` result; it blocks nothing.
10
+ */
11
+ skipReason?: string;
7
12
  }
8
13
  /** Only facts Tree cannot expose. File contents always come from Tree. */
9
14
  export interface ManagedPathInfo {
@@ -1 +1 @@
1
- {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/managed-files/tree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAQjE,gFAAgF;AAChF,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,0EAA0E;AAC1E,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,mFAAmF;AACnF,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,iBAAiB,GAAG,SAAS,GAAG,YAAY,CAAC;IACvG,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAMvD;AAED,0FAA0F;AAC1F,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAM5E;AASD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,KAAK,GAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAa,GACtD,UAAU,EAAE,CA8Cd;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,GAAG,IAAI,CAO7E"}
1
+ {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/managed-files/tree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAQjE,gFAAgF;AAChF,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,0EAA0E;AAC1E,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,mFAAmF;AACnF,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,iBAAiB,GAAG,SAAS,GAAG,YAAY,CAAC;IACvG,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAMvD;AAED,0FAA0F;AAC1F,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAM5E;AASD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,KAAK,GAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAa,GACtD,UAAU,EAAE,CAiDd;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,GAAG,IAAI,CAO7E"}
@@ -29,7 +29,7 @@ export function stageManagedFiles(tree, files, paths = new Map()) {
29
29
  const seen = new Set();
30
30
  const pending = new Map(tree.listChanges().map((change) => [change.path, change]));
31
31
  const targets = new Set(files.map((file) => file.target));
32
- return files.map(({ target, content, executable = false }) => {
32
+ return files.map(({ target, content, executable = false, skipReason }) => {
33
33
  const conflict = (reason) => ({ target, action: 'drifted', reason });
34
34
  if (!isManagedTarget(target))
35
35
  return conflict('expected a canonical workspace-relative path');
@@ -41,7 +41,9 @@ export function stageManagedFiles(tree, files, paths = new Map()) {
41
41
  return conflict('a managed file is also declared as a parent directory');
42
42
  }
43
43
  if (content === null)
44
- return { target, action: 'skipped' };
44
+ return skipReason === undefined
45
+ ? { target, action: 'skipped' }
46
+ : { target, action: 'skipped', reason: skipReason };
45
47
  const path = paths.get(target);
46
48
  if (path?.error)
47
49
  return conflict(path.error);
@@ -84,7 +86,7 @@ export function stageManagedFiles(tree, files, paths = new Map()) {
84
86
  });
85
87
  }
86
88
  export function assertNoManagedConflicts(results) {
87
- const conflicts = results.filter((result) => result.reason !== undefined);
89
+ const conflicts = results.filter((result) => result.action === 'drifted' && result.reason !== undefined);
88
90
  if (conflicts.length > 0) {
89
91
  throw new ManagedContentConflict(`Managed-file update refused before writing:\n${conflicts.map(({ target, reason }) => `${target}: ${reason}`).join('\n')}`);
90
92
  }
@@ -1 +1 @@
1
- {"version":3,"file":"manifest-hash.d.ts","sourceRoot":"","sources":["../src/manifest-hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAqEpD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CA8CjF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,6BAA6B,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAiB/G"}
1
+ {"version":3,"file":"manifest-hash.d.ts","sourceRoot":"","sources":["../src/manifest-hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAoEpD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CA8CjF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,6BAA6B,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAiB/G"}
@@ -1,8 +1,7 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { readFile } from 'node:fs/promises';
3
3
  import { join, posix } from 'node:path';
4
- import { globWithWorkspaceContext, globWithWorkspaceContextSync } from 'nx/src/utils/workspace-context.js';
5
- import { workspaceRoot as daemonWorkspaceRoot } from 'nx/src/utils/workspace-root.js';
4
+ import { globIndexedFiles } from './workspace-index.js';
6
5
  /**
7
6
  * A release rewrites `version` in every manifest it publishes. Those manifests
8
7
  * are inputs of the validation targets, so a publish run misses the cache for
@@ -174,9 +173,7 @@ export async function hashVersionlessCrateManifests(projectRoot, workspaceRoot)
174
173
  async function listCrateManifests(projectRoot, workspaceRoot) {
175
174
  const prefix = projectRoot === '.' ? '' : `${posix.normalize(projectRoot)}/`;
176
175
  const pattern = [`${prefix}**/${CARGO_MANIFEST}`];
177
- const files = workspaceRoot === daemonWorkspaceRoot
178
- ? await globWithWorkspaceContext(workspaceRoot, pattern)
179
- : globWithWorkspaceContextSync(workspaceRoot, pattern);
176
+ const files = await globIndexedFiles(workspaceRoot, pattern);
180
177
  return files.map((file) => file.slice(prefix.length)).sort();
181
178
  }
182
179
  /** `from` is just past the `[`. */
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * A nextest run-wrapper that measures a test's code time rather than its wall time against its class
4
+ * (specs/cowshed/08_testing.md, "Integration tests (real substrate)").
5
+ *
6
+ * A real-APFS test spends part of its wall time queued for the host disk-lifecycle lease, behind
7
+ * every other cowshed process on the host (05_gateway.md, "Disk-lifecycle lease"). That queue is
8
+ * the host's, not the test's code. The wrapper names a fresh lease-wait record in
9
+ * `COWSHED_LEASE_WAIT_RECORD`, runs the test binary, which every disk-lease client of the test's
10
+ * process tree appends its waits to, and then measures the test's code time, its wall time less the
11
+ * union of those waits, against the class it was configured with. It says the split on stderr after
12
+ * the test body, and warns when the code time is over the class; the test keeps its own exit status.
13
+ * A class is a slow warning, never a kill or a failure: the run's no-progress bound ends a hang.
14
+ *
15
+ * Usage, as nextest invokes it: `nextest-code-bound.ts <class-seconds> <test-binary> [args…]`.
16
+ */
17
+ /** The variable naming the record; the same name every disk-lease client reads. */
18
+ export declare const LEASE_WAIT_RECORD_ENV = "COWSHED_LEASE_WAIT_RECORD";
19
+ /** One line of the record: a wait's start, before its client asks, or its end, however it ended. */
20
+ export type WaitEdge = {
21
+ readonly kind: 'start';
22
+ readonly pid: number;
23
+ readonly seq: number;
24
+ readonly atUs: number;
25
+ readonly diskClass: string;
26
+ } | {
27
+ readonly kind: 'end';
28
+ readonly pid: number;
29
+ readonly seq: number;
30
+ readonly atUs: number;
31
+ };
32
+ export type ParsedRecord = {
33
+ ok: true;
34
+ edges: WaitEdge[];
35
+ } | {
36
+ ok: false;
37
+ error: string;
38
+ };
39
+ /** Reads a record as its clients write it. Any line that is not one of the two shapes is refused. */
40
+ export declare function parseWaitRecord(text: string): ParsedRecord;
41
+ /** A wait whose end never reached the record: its process died while waiting, or still waits. */
42
+ export interface OpenWait {
43
+ readonly pid: number;
44
+ readonly seq: number;
45
+ readonly startedUs: number;
46
+ }
47
+ export interface CodeTime {
48
+ readonly wallUs: number;
49
+ /** The union of every wait, clipped to the test's run: concurrent waits count once. */
50
+ readonly waitUs: number;
51
+ readonly codeUs: number;
52
+ readonly waits: number;
53
+ /** Counted to the test's end: the record cannot say when they stopped. */
54
+ readonly open: readonly OpenWait[];
55
+ /** Ends with no start, which can only follow an unwritable start: counted as code time. */
56
+ readonly strayEnds: number;
57
+ }
58
+ /** The test's code time: its wall time from `startedUs` to `endedUs` less the union of its waits. */
59
+ export declare function codeTime(edges: readonly WaitEdge[], startedUs: number, endedUs: number): CodeTime;
60
+ /** The one line the wrapper prints after the test body. */
61
+ export declare function describeCodeTime(time: CodeTime, classUs: number): string;
62
+ //# sourceMappingURL=nextest-code-bound.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nextest-code-bound.d.ts","sourceRoot":"","sources":["../src/nextest-code-bound.ts"],"names":[],"mappings":";AAQA;;;;;;;;;;;;;;GAcG;AAEH,mFAAmF;AACnF,eAAO,MAAM,qBAAqB,8BAA8B,CAAC;AAEjE,oGAAoG;AACpG,MAAM,MAAM,QAAQ,GAChB;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhG,MAAM,MAAM,YAAY,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,QAAQ,EAAE,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAI1F,qGAAqG;AACrG,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAkB1D;AAED,iGAAiG;AACjG,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,uFAAuF;IACvF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,SAAS,QAAQ,EAAE,CAAC;IACnC,2FAA2F;IAC3F,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,qGAAqG;AACrG,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,QAAQ,CAsCjG;AAID,2DAA2D;AAC3D,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAaxE"}