@smoothbricks/nx-plugin 0.4.26 → 0.4.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +994 -117
- package/dist/bin/smoo-nx-bound-failures.d.ts +3 -0
- package/dist/bin/smoo-nx-bound-failures.d.ts.map +1 -0
- package/dist/bin/smoo-nx-bound-failures.js +31 -0
- package/dist/bin/smoo-nx-cargo-hash.js +28 -3
- package/dist/bin/smoo-nx-exec.js +15 -73
- package/dist/bin/smoo-nx-failures.d.ts +3 -0
- package/dist/bin/smoo-nx-failures.d.ts.map +1 -0
- package/dist/bin/smoo-nx-failures.js +3 -0
- package/dist/bin/smoo-nx-nextest-extract.js +3 -2
- package/dist/bin/smoo-nx-test-walks.d.ts +3 -0
- package/dist/bin/smoo-nx-test-walks.d.ts.map +1 -0
- package/dist/bin/smoo-nx-test-walks.js +34 -0
- package/dist/bounded-test-policy.d.ts +7 -1
- package/dist/bounded-test-policy.d.ts.map +1 -1
- package/dist/bounded-test-policy.js +101 -40
- package/dist/build-state-output-policy.d.ts +25 -0
- package/dist/build-state-output-policy.d.ts.map +1 -0
- package/dist/build-state-output-policy.js +64 -0
- package/dist/cargo-closure-input.d.ts +3 -2
- package/dist/cargo-closure-input.d.ts.map +1 -1
- package/dist/cargo-closure-input.js +16 -15
- package/dist/cargo-dev-profile.d.ts +37 -0
- package/dist/cargo-dev-profile.d.ts.map +1 -0
- package/dist/cargo-dev-profile.js +108 -0
- package/dist/cargo-source-hash.d.ts +43 -6
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +309 -73
- package/dist/cargo-toolchain-policy.d.ts +4 -0
- package/dist/cargo-toolchain-policy.d.ts.map +1 -1
- package/dist/cargo-toolchain-policy.js +5 -0
- package/dist/cargo-workspace.d.ts +101 -5
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +291 -10
- package/dist/cross-check-policy.d.ts +21 -3
- package/dist/cross-check-policy.d.ts.map +1 -1
- package/dist/cross-check-policy.js +24 -6
- package/dist/disk-command-policy.d.ts +7 -0
- package/dist/disk-command-policy.d.ts.map +1 -0
- package/dist/disk-command-policy.js +98 -0
- package/dist/ensure-built-receipt.d.ts +25 -0
- package/dist/ensure-built-receipt.d.ts.map +1 -0
- package/dist/ensure-built-receipt.js +261 -0
- package/dist/ensure-built-witness.d.ts +57 -0
- package/dist/ensure-built-witness.d.ts.map +1 -0
- package/dist/ensure-built-witness.js +412 -0
- package/dist/ensure-built.d.ts +207 -12
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +576 -202
- package/dist/eslint-file-set.d.ts +7 -0
- package/dist/eslint-file-set.d.ts.map +1 -0
- package/dist/eslint-file-set.js +12 -0
- package/dist/executors/bounded-exec/cpu-pool.d.ts +63 -0
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -0
- package/dist/executors/bounded-exec/cpu-pool.js +379 -0
- package/dist/executors/bounded-exec/cpu-tokens.d.ts +82 -0
- package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +1 -0
- package/dist/executors/bounded-exec/cpu-tokens.js +114 -0
- package/dist/executors/bounded-exec/disk-lease.d.ts +61 -0
- package/dist/executors/bounded-exec/disk-lease.d.ts.map +1 -0
- package/dist/executors/bounded-exec/disk-lease.js +91 -0
- package/dist/executors/bounded-exec/executor.d.ts +45 -2
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +447 -52
- package/dist/executors/bounded-exec/gateway-lease.d.ts +52 -0
- package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -0
- package/dist/executors/bounded-exec/gateway-lease.js +143 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts +35 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -0
- package/dist/executors/bounded-exec/hang-diagnostics.js +231 -0
- package/dist/executors/bounded-exec/progress.d.ts +35 -0
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -0
- package/dist/executors/bounded-exec/progress.js +79 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +3 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.js +12 -0
- package/dist/executors/bounded-exec/ram-temp-held.d.ts +91 -0
- package/dist/executors/bounded-exec/ram-temp-held.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-temp-held.js +152 -0
- package/dist/executors/bounded-exec/ram-temp.d.ts +223 -0
- package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-temp.js +1528 -0
- package/dist/executors/bounded-exec/schema.d.ts +29 -11
- package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.d.ts +162 -0
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -0
- package/dist/executors/bounded-exec/verdict.js +318 -0
- package/dist/executors/shard-timings/executor.d.ts +14 -0
- package/dist/executors/shard-timings/executor.d.ts.map +1 -0
- package/dist/executors/shard-timings/executor.js +25 -0
- package/dist/executors/shard-timings/schema.d.ts +4 -0
- package/dist/executors/shard-timings/schema.d.ts.map +1 -0
- package/dist/executors/shard-timings/schema.js +1 -0
- package/dist/failure-summary.d.ts +5 -0
- package/dist/failure-summary.d.ts.map +1 -0
- package/dist/failure-summary.js +118 -0
- package/dist/generators/create-package/generator.d.ts.map +1 -1
- package/dist/generators/create-package/generator.js +6 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +370 -138
- package/dist/managed-files/ci-workflow.d.ts +13 -0
- package/dist/managed-files/ci-workflow.d.ts.map +1 -1
- package/dist/managed-files/ci-workflow.js +44 -13
- package/dist/managed-files/files.d.ts +7 -1
- package/dist/managed-files/files.d.ts.map +1 -1
- package/dist/managed-files/files.js +62 -8
- package/dist/managed-files/json-edit.d.ts +21 -0
- package/dist/managed-files/json-edit.d.ts.map +1 -0
- package/dist/managed-files/json-edit.js +295 -0
- package/dist/managed-files/managed-format.d.ts +33 -1
- package/dist/managed-files/managed-format.d.ts.map +1 -1
- package/dist/managed-files/managed-format.js +82 -2
- package/dist/managed-files/pr-preview-cleanup-workflow.d.ts +7 -0
- package/dist/managed-files/pr-preview-cleanup-workflow.d.ts.map +1 -1
- package/dist/managed-files/pr-preview-cleanup-workflow.js +68 -4
- package/dist/managed-files/publish-workflow.d.ts.map +1 -1
- package/dist/managed-files/publish-workflow.js +231 -48
- package/dist/managed-files/tree.d.ts +5 -0
- package/dist/managed-files/tree.d.ts.map +1 -1
- package/dist/managed-files/tree.js +5 -3
- package/dist/manifest-hash.d.ts.map +1 -1
- package/dist/manifest-hash.js +2 -5
- package/dist/nextest-code-bound.d.ts +62 -0
- package/dist/nextest-code-bound.d.ts.map +1 -0
- package/dist/nextest-code-bound.js +154 -0
- package/dist/nextest-extraction.d.ts +24 -8
- package/dist/nextest-extraction.d.ts.map +1 -1
- package/dist/nextest-extraction.js +42 -7
- package/dist/package-target-policy.d.ts.map +1 -1
- package/dist/package-target-policy.js +3 -5
- package/dist/release-config-policy.d.ts.map +1 -1
- package/dist/release-config-policy.js +3 -5
- package/dist/runtime-input.d.ts +14 -0
- package/dist/runtime-input.d.ts.map +1 -0
- package/dist/runtime-input.js +15 -0
- package/dist/rust-tokens.d.ts +11 -0
- package/dist/rust-tokens.d.ts.map +1 -0
- package/dist/rust-tokens.js +81 -0
- package/dist/task-results.d.ts +6 -0
- package/dist/task-results.d.ts.map +1 -0
- package/dist/task-results.js +61 -0
- package/dist/test-program.d.ts +54 -0
- package/dist/test-program.d.ts.map +1 -0
- package/dist/test-program.js +292 -0
- package/dist/test-timings.d.ts +71 -0
- package/dist/test-timings.d.ts.map +1 -0
- package/dist/test-timings.js +393 -0
- package/dist/test-walk-policy.d.ts +103 -0
- package/dist/test-walk-policy.d.ts.map +1 -0
- package/dist/test-walk-policy.js +657 -0
- package/dist/testing.d.ts +177 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +824 -0
- package/dist/type-guards.d.ts +3 -0
- package/dist/type-guards.d.ts.map +1 -0
- package/dist/type-guards.js +4 -0
- package/dist/typecheck-test-policy.d.ts +8 -5
- package/dist/typecheck-test-policy.d.ts.map +1 -1
- package/dist/typecheck-test-policy.js +113 -100
- package/dist/workspace-config-policy.d.ts +8 -0
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +175 -63
- package/dist/workspace-index.d.ts +12 -0
- package/dist/workspace-index.d.ts.map +1 -0
- package/dist/workspace-index.js +17 -0
- package/dist/workspace-manifest.d.ts +37 -0
- package/dist/workspace-manifest.d.ts.map +1 -1
- package/executors.json +5 -0
- package/loader.js +13 -11
- package/managed/raw/envrc +33 -67
- package/managed/raw/git-format-staged.yml +30 -35
- package/managed/raw/patches/nx@23.2.1.patch +3484 -0
- package/managed/raw/tooling/direnv/apple-developer.sh +83 -0
- package/managed/raw/tooling/direnv/developer-links.ts +569 -11
- package/managed/raw/tooling/direnv/devenv.smoo.nix +314 -93
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -11
- package/managed/raw/tooling/direnv/linked-snapshots.ts +845 -0
- package/managed/raw/tooling/direnv/nx-socket-dir.sh +82 -0
- package/managed/raw/tooling/direnv/repo-path +14 -2
- package/managed/raw/tooling/direnv/setup-environment.ts +962 -148
- package/managed/raw/tooling/direnv/toolchain-stamp.ts +45 -3
- package/managed/raw/tooling/direnv/ttsc-env.sh +39 -0
- package/managed/raw/tooling/git-hooks/commit-msg.sh +5 -6
- package/managed/raw/tooling/git-hooks/pre-commit.sh +7 -6
- package/managed/raw/tooling/git-hooks/pre-push.sh +20 -15
- package/managed/templates/github/actions/cache-nix-devenv/action.yml +6 -6
- package/managed/templates/github/actions/cache-node-modules/action.yml +6 -4
- package/managed/templates/github/actions/cache-nx/action.yml +1 -1
- package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +1 -1
- package/managed/templates/github/actions/forgejo-artifact.cjs +99 -0
- package/managed/templates/github/actions/forgejo-download-artifact/action.yml +49 -0
- package/managed/templates/github/actions/forgejo-download-artifact/index.cjs +7 -0
- package/managed/templates/github/actions/forgejo-upload-artifact/action.yml +65 -0
- package/managed/templates/github/actions/forgejo-upload-artifact/index.cjs +7 -0
- package/managed/templates/github/actions/setup-devenv/action.yml +21 -3
- package/managed/templates/github/workflows/managed-files.yml +1 -2
- package/nextest.toml +8 -41
- package/package.json +74 -12
- package/runtime-input.sh +81 -0
- package/src/__tests__/counted-cargo.ts +33 -14
- package/src/__tests__/fixture-nx-env.ts +111 -46
- package/src/__tests__/progress-clock.ts +43 -0
- package/src/__tests__/runtime-input.ts +23 -0
- package/src/bin/smoo-nx-bound-failures.test.ts +127 -0
- package/src/bin/smoo-nx-bound-failures.ts +33 -0
- package/src/bin/smoo-nx-cargo-hash.ts +28 -3
- package/src/bin/smoo-nx-exec.ts +16 -74
- package/src/bin/smoo-nx-failures.ts +4 -0
- package/src/bin/smoo-nx-nextest-extract.ts +3 -2
- package/src/bin/smoo-nx-test-walks.ts +42 -0
- package/src/bounded-test-policy.test.ts +268 -21
- package/src/bounded-test-policy.ts +114 -42
- package/src/build-state-output-policy.test.ts +115 -0
- package/src/build-state-output-policy.ts +90 -0
- package/src/bun-bootstrap.test.ts +57 -3
- package/src/bun-file-packages.test.ts +47 -0
- package/src/cargo-closure-input.test.ts +138 -66
- package/src/cargo-closure-input.ts +17 -15
- package/src/cargo-dev-profile.ts +137 -0
- package/src/cargo-resolve-cache.test.ts +70 -1
- package/src/cargo-source-hash.test.ts +193 -97
- package/src/cargo-source-hash.ts +345 -68
- package/src/cargo-toolchain-policy.ts +6 -0
- package/src/cargo-workspace.test.ts +320 -0
- package/src/cargo-workspace.ts +336 -10
- package/src/cross-check-policy.test.ts +59 -1
- package/src/cross-check-policy.ts +25 -6
- package/src/disk-command-policy.test.ts +61 -0
- package/src/disk-command-policy.ts +107 -0
- package/src/ensure-built-receipt.test.ts +184 -0
- package/src/ensure-built-receipt.ts +263 -0
- package/src/ensure-built-witness.test.ts +344 -0
- package/src/ensure-built-witness.ts +252 -0
- package/src/ensure-built.test.ts +1036 -578
- package/src/ensure-built.ts +820 -224
- package/src/eslint-file-set.ts +9 -0
- package/src/executors/bounded-exec/cpu-pool.test.ts +454 -0
- package/src/executors/bounded-exec/cpu-pool.ts +417 -0
- package/src/executors/bounded-exec/cpu-tokens.test.ts +269 -0
- package/src/executors/bounded-exec/cpu-tokens.ts +177 -0
- package/src/executors/bounded-exec/disk-lease.test.ts +185 -0
- package/src/executors/bounded-exec/disk-lease.ts +139 -0
- package/src/executors/bounded-exec/executor-host.test.ts +778 -0
- package/src/executors/bounded-exec/executor.test.ts +1116 -63
- package/src/executors/bounded-exec/executor.ts +565 -67
- package/src/executors/bounded-exec/gateway-lease.ts +176 -0
- package/src/executors/bounded-exec/hang-diagnostics.test.ts +285 -0
- package/src/executors/bounded-exec/hang-diagnostics.ts +283 -0
- package/src/executors/bounded-exec/progress.test.ts +79 -0
- package/src/executors/bounded-exec/progress.ts +118 -0
- package/src/executors/bounded-exec/ram-temp-fixtures.ts +12 -0
- package/src/executors/bounded-exec/ram-temp-held.test.ts +264 -0
- package/src/executors/bounded-exec/ram-temp-held.ts +242 -0
- package/src/executors/bounded-exec/ram-temp-host.test.ts +605 -0
- package/src/executors/bounded-exec/ram-temp.test.ts +674 -0
- package/src/executors/bounded-exec/ram-temp.ts +1918 -0
- package/src/executors/bounded-exec/schema.json +11 -5
- package/src/executors/bounded-exec/schema.ts +27 -11
- package/src/executors/bounded-exec/verdict.test.ts +440 -0
- package/src/executors/bounded-exec/verdict.ts +433 -0
- package/src/executors/shard-timings/executor.ts +36 -0
- package/src/executors/shard-timings/schema.json +21 -0
- package/src/executors/shard-timings/schema.ts +4 -0
- package/src/failure-summary.ts +119 -0
- package/src/generators/bounded-test-targets/generator.test.ts +4 -4
- package/src/generators/bun-test-tracing/generator.test.ts +2 -2
- package/src/generators/create-package/generator.test.ts +6 -0
- package/src/generators/create-package/generator.ts +6 -2
- package/src/host-controller-wiring.test.ts +31 -0
- package/src/index.test.ts +909 -295
- package/src/index.ts +441 -143
- package/src/linked-snapshots.nx.test.ts +172 -0
- package/src/managed-files/ci-workflow.ts +54 -13
- package/src/managed-files/files.ts +65 -9
- package/src/managed-files/forgejo-artifact.test.ts +395 -0
- package/src/managed-files/generator.test.ts +60 -1
- package/src/managed-files/json-edit.test.ts +216 -0
- package/src/managed-files/json-edit.ts +290 -0
- package/src/managed-files/managed-format-json.test.ts +308 -0
- package/src/managed-files/managed-format.ts +90 -2
- package/src/managed-files/pr-preview-cleanup-workflow.ts +69 -3
- package/src/managed-files/publish-workflow.ts +285 -67
- package/src/managed-files/repo-path.test.ts +129 -0
- package/src/managed-files/trace-db-artifact.test.ts +7 -0
- package/src/managed-files/tree.ts +11 -3
- package/src/manifest-hash.ts +2 -6
- package/src/nextest-code-bound.test.ts +155 -0
- package/src/nextest-code-bound.ts +195 -0
- package/src/nextest-extraction.test.ts +37 -5
- package/src/nextest-extraction.ts +51 -9
- package/src/nextest-partitions.test.ts +427 -82
- package/src/nx-cache-bound.test.ts +5 -10
- package/src/nx-cache-restore-mtime.test.ts +170 -0
- package/src/nx-daemon-claim.test.ts +277 -0
- package/src/nx-daemon-idle-cpu.test.ts +81 -0
- package/src/nx-daemon-idle-policy.test.ts +51 -0
- package/src/nx-daemon-ignore-files.test.ts +210 -0
- package/src/nx-daemon-root-normalization.test.ts +105 -0
- package/src/nx-daemon-validity.test.ts +925 -0
- package/src/nx-dot-input-policy.test.ts +353 -0
- package/src/nx-failure-life-cycles.test.ts +207 -0
- package/src/nx-files-archive-racy.test.ts +97 -0
- package/src/nx-foreign-workspace-env.test.ts +329 -0
- package/src/nx-incomplete-run-summary.test.ts +70 -0
- package/src/nx-plugin-load-errors.test.ts +120 -0
- package/src/nx-project-resolution-cache.test.ts +176 -0
- package/src/nx-raw-inputs.test.ts +166 -0
- package/src/nx-resident-graph-workers.test.ts +7 -16
- package/src/nx-run-information.test.ts +118 -0
- package/src/nx-skipped-task-exit.test.ts +180 -0
- package/src/nx-state-location.test.ts +63 -0
- package/src/nx-store-resolution.test.ts +26 -25
- package/src/nx-task-graph-cycles.test.ts +148 -0
- package/src/nx-task-output-lease.test.ts +414 -0
- package/src/nx-use-local.test.ts +103 -0
- package/src/package-target-policy.ts +3 -6
- package/src/release-config-policy.ts +3 -6
- package/src/runtime-input.test.ts +215 -0
- package/src/runtime-input.ts +17 -0
- package/src/rust-tokens.ts +78 -0
- package/src/serial-group-wiring.test.ts +326 -0
- package/src/task-history-namespace.test.ts +87 -89
- package/src/task-results.test.ts +226 -0
- package/src/task-results.ts +75 -0
- package/src/test-program.test.ts +303 -0
- package/src/test-program.ts +341 -0
- package/src/test-timings.test.ts +240 -0
- package/src/test-timings.ts +311 -0
- package/src/test-walk-policy.test.ts +585 -0
- package/src/test-walk-policy.ts +731 -0
- package/src/testing.test.ts +509 -0
- package/src/testing.ts +922 -0
- package/src/type-guards.ts +4 -0
- package/src/typecheck-test-policy.test.ts +496 -11
- package/src/typecheck-test-policy.ts +137 -103
- package/src/workspace-config-policy.test.ts +212 -13
- package/src/workspace-config-policy.ts +101 -73
- package/src/workspace-index.ts +18 -0
- package/src/workspace-manifest.ts +41 -0
- package/test-timings.json +85 -30
- package/managed/raw/tooling/direnv/inherited-devenv.ts +0 -665
- package/managed/raw/tooling/direnv/shared-caches.sh +0 -53
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/* biome-ignore-all lint/suspicious/noTemplateCurlyInString: GitHub Actions expressions are emitted literally. */
|
|
2
2
|
|
|
3
|
+
import { isMap, isScalar, parseDocument } from 'yaml';
|
|
4
|
+
|
|
3
5
|
import {
|
|
4
6
|
LINUX_PLATFORM_TARGET_GLOBS,
|
|
5
7
|
MACOS_PLATFORM_TARGET_GLOBS,
|
|
@@ -20,8 +22,10 @@ import {
|
|
|
20
22
|
cargoCredentialStepLines,
|
|
21
23
|
type DeployStepSecretConfig,
|
|
22
24
|
deployStepSecretEnvLines,
|
|
25
|
+
githubActionPins,
|
|
23
26
|
remoteCacheJobEnvLines,
|
|
24
27
|
sourceCheckoutsStepLines,
|
|
28
|
+
TRACE_DB_ARTIFACT_GLOB,
|
|
25
29
|
} from './ci-workflow.js';
|
|
26
30
|
import { GITHUB_HOSTED_LINUX_RUNNER, renderRunsOnLine, type WorkflowRunsOn } from './github-runs-on.js';
|
|
27
31
|
|
|
@@ -424,7 +428,12 @@ function shouldRunStep(
|
|
|
424
428
|
*/
|
|
425
429
|
export function renderPublishWorkflowYaml(options: PublishWorkflowDefinitionOptions = {}): string {
|
|
426
430
|
if (options.release === false) {
|
|
427
|
-
|
|
431
|
+
const steps = definePublishWorkflow(options).steps;
|
|
432
|
+
const rendered =
|
|
433
|
+
skipsPublishHandoff(options) && options.platformProducer !== undefined
|
|
434
|
+
? renderSingleJobPublishWorkflowSteps(steps, options)
|
|
435
|
+
: renderPublishWorkflowSteps(steps, options);
|
|
436
|
+
return `${renderPublishWorkflowHeader(options)}${rendered}`;
|
|
428
437
|
}
|
|
429
438
|
if (hasMacosPlatformTargets(options) && !skipsPublishHandoff(options)) {
|
|
430
439
|
return renderPlatformPublishWorkflowYaml(options);
|
|
@@ -433,7 +442,11 @@ export function renderPublishWorkflowYaml(options: PublishWorkflowDefinitionOpti
|
|
|
433
442
|
// runner. Splitting jobs then buys nothing and costs a real transfer: the
|
|
434
443
|
// outputs get tarred, uploaded, downloaded into a second checkout, and two
|
|
435
444
|
// more devenv setups pay for themselves twice. One job, no artifacts.
|
|
436
|
-
if (
|
|
445
|
+
if (
|
|
446
|
+
hasMacosPlatformTargets(options) ||
|
|
447
|
+
hasLinuxPlatformTargets(options) ||
|
|
448
|
+
(skipsPublishHandoff(options) && options.platformProducer !== undefined)
|
|
449
|
+
) {
|
|
437
450
|
return `${renderPublishWorkflowHeader(options)}${renderSingleJobPublishWorkflowSteps(
|
|
438
451
|
definePublishWorkflow(options).steps,
|
|
439
452
|
options,
|
|
@@ -498,8 +511,10 @@ defaults:
|
|
|
498
511
|
jobs:
|
|
499
512
|
publish:
|
|
500
513
|
${options.release === false ? renderRunsOnLine(options.runsOn) : publishJobRunsOnLine(options)}
|
|
514
|
+
timeout-minutes: ${options.platformTargetGlobs?.length ? 90 : 45}
|
|
501
515
|
env:
|
|
502
|
-
|
|
516
|
+
LMAO_GIT_REVISION: ${githubExpression('github.sha')}
|
|
517
|
+
GH_TOKEN: ${githubExpression('github.token')}${remoteCacheJobEnv(options)}${cargoCredentialsJobEnv(options)}${privateNpmInstallJobEnv(options)}
|
|
503
518
|
steps:
|
|
504
519
|
`;
|
|
505
520
|
}
|
|
@@ -557,10 +572,15 @@ function yamlLinesForStep(step: PublishWorkflowStep, options: PublishWorkflowDef
|
|
|
557
572
|
case PublishWorkflowStepKind.Checkout:
|
|
558
573
|
return [
|
|
559
574
|
` - name: ${step.name}`,
|
|
560
|
-
|
|
575
|
+
` uses: ${githubActionPins.checkout.ref} # ${githubActionPins.checkout.version}`,
|
|
561
576
|
' with:',
|
|
562
|
-
' filter: blob:none',
|
|
563
577
|
' fetch-depth: 0',
|
|
578
|
+
...(options.release === false
|
|
579
|
+
? [' persist-credentials: false']
|
|
580
|
+
: [
|
|
581
|
+
' # smoo publish and pending-release repair push release refs.',
|
|
582
|
+
' persist-credentials: true',
|
|
583
|
+
]),
|
|
564
584
|
];
|
|
565
585
|
case PublishWorkflowStepKind.SourceCheckouts:
|
|
566
586
|
return siblingSourceCheckoutStepLines(options);
|
|
@@ -602,16 +622,20 @@ function yamlLinesForStep(step: PublishWorkflowStep, options: PublishWorkflowDef
|
|
|
602
622
|
return [
|
|
603
623
|
` - name: ${step.name}`,
|
|
604
624
|
' id: plan',
|
|
625
|
+
' env:',
|
|
626
|
+
` SMOO_RELEASE_PROJECTS: ${githubExpression('inputs.projects')}`,
|
|
605
627
|
' run:',
|
|
606
|
-
` smoo release version --bump "${githubExpression('inputs.bump')}" --projects "$
|
|
628
|
+
` smoo release version --bump "${githubExpression('inputs.bump')}" --projects "$SMOO_RELEASE_PROJECTS" --dry-run "true" --github-output`,
|
|
607
629
|
' "$GITHUB_OUTPUT"',
|
|
608
630
|
];
|
|
609
631
|
case PublishWorkflowStepKind.VersionRelease:
|
|
610
632
|
return [
|
|
611
633
|
` - name: ${step.name}`,
|
|
612
634
|
' id: version',
|
|
635
|
+
' env:',
|
|
636
|
+
` SMOO_RELEASE_PROJECTS: ${githubExpression('inputs.projects')}`,
|
|
613
637
|
' run:',
|
|
614
|
-
` smoo release version --bump "${githubExpression('inputs.bump')}" --projects "$
|
|
638
|
+
` smoo release version --bump "${githubExpression('inputs.bump')}" --projects "$SMOO_RELEASE_PROJECTS" --dry-run "${githubExpression('inputs.dry_run')}" --github-output`,
|
|
615
639
|
' "$GITHUB_OUTPUT"',
|
|
616
640
|
];
|
|
617
641
|
case PublishWorkflowStepKind.CheckManagedMonorepoFiles:
|
|
@@ -640,7 +664,7 @@ function yamlLinesForStep(step: PublishWorkflowStep, options: PublishWorkflowDef
|
|
|
640
664
|
'upload',
|
|
641
665
|
[
|
|
642
666
|
`name: trace-results-${githubExpression('github.run_id')}`,
|
|
643
|
-
|
|
667
|
+
`path: ${TRACE_DB_ARTIFACT_GLOB}`,
|
|
644
668
|
'if-no-files-found: ignore',
|
|
645
669
|
'retention-days: 14',
|
|
646
670
|
'include-hidden-files: true',
|
|
@@ -786,47 +810,57 @@ function renderSingleJobPublishWorkflowSteps(
|
|
|
786
810
|
options: PublishWorkflowDefinitionOptions,
|
|
787
811
|
): string {
|
|
788
812
|
const lines: string[] = [];
|
|
789
|
-
const
|
|
790
|
-
|
|
813
|
+
const handoffSkipped = skipsPublishHandoff(options);
|
|
814
|
+
// The declared producer runs only in a job that skips the publish handoff; any other
|
|
815
|
+
// single job renders without it, and so without its environment.
|
|
816
|
+
const producer = handoffSkipped ? options.platformProducer : undefined;
|
|
817
|
+
const crossOnThisRunner = handoffSkipped && hasMacosPlatformTargets(options);
|
|
818
|
+
let stepNumber = 2;
|
|
791
819
|
for (const step of steps) {
|
|
792
|
-
|
|
793
|
-
lines.push(...
|
|
794
|
-
lines.push(...
|
|
820
|
+
const numberedStep = { ...step, number: stepNumber++ };
|
|
821
|
+
lines.push(...sectionLinesBefore(numberedStep));
|
|
822
|
+
lines.push(...commentLinesForStep(numberedStep));
|
|
823
|
+
lines.push(...yamlLinesForStep(numberedStep, options));
|
|
795
824
|
lines.push('');
|
|
796
|
-
if (
|
|
797
|
-
//
|
|
798
|
-
|
|
799
|
-
lines.push(
|
|
800
|
-
' - name: Check cross-platform toolchain prerequisites',
|
|
801
|
-
' working-directory: .',
|
|
802
|
-
' run: |',
|
|
803
|
-
' set -euo pipefail',
|
|
804
|
-
...producer.preflight.split('\n').map((line) => ` ${line}`),
|
|
805
|
-
'',
|
|
806
|
-
);
|
|
825
|
+
if (producer && step.kind === PublishWorkflowStepKind.Checkout) {
|
|
826
|
+
// A declared producer always runs, even when the graph selects no platform family.
|
|
827
|
+
lines.push(' # Step ' + stepNumber++, ...platformProducerPreflightStepLines(producer), '');
|
|
807
828
|
}
|
|
808
|
-
if (
|
|
829
|
+
if (
|
|
830
|
+
step.kind === PublishWorkflowStepKind.Build &&
|
|
831
|
+
(hasMacosPlatformTargets(options) || hasLinuxPlatformTargets(options))
|
|
832
|
+
) {
|
|
809
833
|
lines.push(
|
|
834
|
+
' # Step ' + stepNumber++,
|
|
810
835
|
' - name: 🐧 Build supplemental Linux targets',
|
|
811
836
|
" if: steps.version.outputs.mode != 'none'",
|
|
812
|
-
|
|
813
|
-
'
|
|
814
|
-
|
|
837
|
+
' run:',
|
|
838
|
+
' smoo github-ci nx-run-many --targets "' +
|
|
839
|
+
LINUX_PLATFORM_TARGET_GLOBS.join(',') +
|
|
840
|
+
'" --projects "' +
|
|
841
|
+
githubExpression('steps.version.outputs.projects') +
|
|
842
|
+
'" ' +
|
|
843
|
+
RELEASE_BUILD_ARGUMENT,
|
|
815
844
|
'',
|
|
816
845
|
);
|
|
817
846
|
if (crossOnThisRunner) {
|
|
818
847
|
lines.push(
|
|
848
|
+
' # Step ' + stepNumber++,
|
|
819
849
|
' - name: 🍎 Build selected macOS and iOS release outputs',
|
|
820
850
|
" if: steps.version.outputs.mode != 'none'",
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
851
|
+
' run:',
|
|
852
|
+
' smoo github-ci nx-run-many --targets "' +
|
|
853
|
+
macosPlatformFamilies(options).join(',') +
|
|
854
|
+
'" --projects "' +
|
|
855
|
+
githubExpression('steps.version.outputs.projects') +
|
|
856
|
+
'" ' +
|
|
857
|
+
RELEASE_BUILD_ARGUMENT,
|
|
824
858
|
'',
|
|
825
859
|
);
|
|
826
860
|
}
|
|
827
861
|
}
|
|
828
862
|
}
|
|
829
|
-
return
|
|
863
|
+
return mergeProducerStepEnvironment(lines, producer).join('\n').trimEnd() + '\n';
|
|
830
864
|
}
|
|
831
865
|
|
|
832
866
|
function renderPlatformPublishWorkflowYaml(options: PublishWorkflowDefinitionOptions): string {
|
|
@@ -877,6 +911,7 @@ defaults:
|
|
|
877
911
|
jobs:
|
|
878
912
|
linux-release-candidate:
|
|
879
913
|
${renderRunsOnLine(options.runsOn)}
|
|
914
|
+
timeout-minutes: 45
|
|
880
915
|
permissions:
|
|
881
916
|
contents: write
|
|
882
917
|
id-token: none
|
|
@@ -884,30 +919,32 @@ ${renderRunsOnLine(options.runsOn)}
|
|
|
884
919
|
mode: ${githubExpression('steps.version.outputs.mode')}
|
|
885
920
|
release-sha: ${githubExpression('steps.release-state.outputs.sha')}
|
|
886
921
|
env:
|
|
922
|
+
LMAO_GIT_REVISION: ${githubExpression('github.sha')}
|
|
887
923
|
GH_TOKEN: ${githubExpression('github.token')}${remoteCacheJobEnv(options)}${cargoCredentialsJobEnv(options)}${privateNpmInstallJobEnv(options)}
|
|
888
924
|
steps:
|
|
889
925
|
${renderLinuxReleaseCandidateSteps(steps, options)}
|
|
890
926
|
|
|
891
927
|
${options.platformProducer?.kind === 'linux-cross' ? 'cross-platform' : 'macos-platform'}:
|
|
892
928
|
${renderMacosJobHeaderLines(options)}
|
|
929
|
+
timeout-minutes: 90
|
|
893
930
|
permissions:
|
|
894
931
|
contents: read
|
|
895
932
|
id-token: none
|
|
896
933
|
env:
|
|
934
|
+
LMAO_GIT_REVISION: ${githubExpression('github.sha')}
|
|
897
935
|
GH_TOKEN: ${githubExpression('github.token')}${remoteCacheJobEnv(options)}${cargoCredentialsJobEnv(options)}${privateNpmInstallJobEnv(options)}
|
|
898
|
-
${Object.entries(options.platformProducer?.env ?? {})
|
|
899
|
-
.map(([name, value]) => ` ${name}: ${JSON.stringify(value)}`)
|
|
900
|
-
.join('\n')}
|
|
901
936
|
steps:
|
|
902
937
|
${renderMacosPlatformSteps(options)}
|
|
903
938
|
|
|
904
939
|
publish-on-linux:
|
|
905
940
|
needs: [linux-release-candidate, ${options.platformProducer?.kind === 'linux-cross' ? 'cross-platform' : 'macos-platform'}]
|
|
906
941
|
${publishJobRunsOnLine(options)}
|
|
942
|
+
timeout-minutes: 45
|
|
907
943
|
permissions:
|
|
908
944
|
contents: write
|
|
909
945
|
id-token: write
|
|
910
946
|
env:
|
|
947
|
+
LMAO_GIT_REVISION: ${githubExpression('github.sha')}
|
|
911
948
|
TTSC_TSGO_BINARY: ${githubExpression('github.workspace')}/node_modules/@typescript/native/bin/tsc
|
|
912
949
|
GH_TOKEN: ${githubExpression('github.token')}${remoteCacheJobEnv(options)}${cargoCredentialsJobEnv(options)}${privateNpmInstallJobEnv(options)}
|
|
913
950
|
steps:
|
|
@@ -945,11 +982,13 @@ function renderLinuxReleaseCandidateSteps(
|
|
|
945
982
|
if (step.kind === PublishWorkflowStepKind.Checkout) {
|
|
946
983
|
lines.push(
|
|
947
984
|
` - name: ${step.name}`,
|
|
948
|
-
|
|
985
|
+
` uses: ${githubActionPins.checkout.ref} # ${githubActionPins.checkout.version}`,
|
|
949
986
|
' with:',
|
|
950
987
|
` ref: ${githubExpression('github.sha')}`,
|
|
951
|
-
' filter: blob:none',
|
|
952
988
|
' fetch-depth: 0',
|
|
989
|
+
' # No remote is read or written from this job: the clone is complete and the',
|
|
990
|
+
' # candidate commit leaves only as the transferred bundle.',
|
|
991
|
+
' persist-credentials: false',
|
|
953
992
|
);
|
|
954
993
|
} else if (step.kind === PublishWorkflowStepKind.Build) {
|
|
955
994
|
lines.push(
|
|
@@ -1066,25 +1105,17 @@ function renderMacosPlatformSteps(options: PublishWorkflowDefinitionOptions): st
|
|
|
1066
1105
|
' # Step 1: GitHub adds "Set up job" automatically',
|
|
1067
1106
|
' # Step 2',
|
|
1068
1107
|
' - name: 📥 Checkout dispatch commit',
|
|
1069
|
-
|
|
1108
|
+
` uses: ${githubActionPins.checkout.ref} # ${githubActionPins.checkout.version}`,
|
|
1070
1109
|
' with:',
|
|
1071
1110
|
` ref: ${githubExpression('github.sha')}`,
|
|
1072
|
-
' filter: blob:none',
|
|
1073
1111
|
' fetch-depth: 0',
|
|
1112
|
+
' # build-platform-outputs fetches the release branch and tags from origin',
|
|
1113
|
+
' # (packages/cli/src/release/index.ts:335). This job pushes nothing, but a private origin refuses',
|
|
1114
|
+
' # that fetch without the checkout credential, so it stays persisted.',
|
|
1115
|
+
' persist-credentials: true',
|
|
1074
1116
|
];
|
|
1075
1117
|
if (options.platformProducer) {
|
|
1076
|
-
|
|
1077
|
-
throw new Error('Linux cross-platform production requires a nonempty toolchain preflight command.');
|
|
1078
|
-
}
|
|
1079
|
-
lines.push(
|
|
1080
|
-
'',
|
|
1081
|
-
` # Step ${stepNumber++}`,
|
|
1082
|
-
' - name: Check cross-platform toolchain prerequisites',
|
|
1083
|
-
' working-directory: .',
|
|
1084
|
-
' run: |',
|
|
1085
|
-
' set -euo pipefail',
|
|
1086
|
-
...options.platformProducer.preflight.split('\n').map((line) => ` ${line}`),
|
|
1087
|
-
);
|
|
1118
|
+
lines.push('', ` # Step ${stepNumber++}`, ...platformProducerPreflightStepLines(options.platformProducer));
|
|
1088
1119
|
}
|
|
1089
1120
|
const macosCargoCredentials = cargoCredentialsStepLines(options);
|
|
1090
1121
|
if (macosCargoCredentials.length > 0) {
|
|
@@ -1131,8 +1162,10 @@ function renderMacosPlatformSteps(options: PublishWorkflowDefinitionOptions): st
|
|
|
1131
1162
|
` # Step ${stepNumber++}`,
|
|
1132
1163
|
' - name: 🔢 Version release',
|
|
1133
1164
|
' id: version',
|
|
1165
|
+
' env:',
|
|
1166
|
+
` SMOO_RELEASE_PROJECTS: ${githubExpression('inputs.projects')}`,
|
|
1134
1167
|
' run:',
|
|
1135
|
-
` smoo release version --bump "${githubExpression('inputs.bump')}" --projects "$
|
|
1168
|
+
` smoo release version --bump "${githubExpression('inputs.bump')}" --projects "$SMOO_RELEASE_PROJECTS" --dry-run "${githubExpression('inputs.dry_run')}" --github-output`,
|
|
1136
1169
|
' "$GITHUB_OUTPUT"',
|
|
1137
1170
|
);
|
|
1138
1171
|
const architectures = macosPlatformArchitectures(options);
|
|
@@ -1148,10 +1181,12 @@ function renderMacosPlatformSteps(options: PublishWorkflowDefinitionOptions): st
|
|
|
1148
1181
|
` # Step ${stepNumber++}`,
|
|
1149
1182
|
` - name: 🍎 Build selected macOS and iOS release outputs${legLabel}`,
|
|
1150
1183
|
' id: platform-outputs',
|
|
1184
|
+
' env:',
|
|
1185
|
+
` SMOO_RELEASE_PROJECTS: ${githubExpression('inputs.projects')}`,
|
|
1151
1186
|
' run:',
|
|
1152
1187
|
` smoo release build-platform-outputs --bump "${githubExpression(
|
|
1153
1188
|
'inputs.bump',
|
|
1154
|
-
)}" --projects "$
|
|
1189
|
+
)}" --projects "$SMOO_RELEASE_PROJECTS" --ref "${githubExpression('github.sha')}" --targets "${macosPlatformTargetSelector(options)}" --output`,
|
|
1155
1190
|
` "${githubExpression('runner.temp')}/macos-platform-outputs" --github-output "$GITHUB_OUTPUT"`,
|
|
1156
1191
|
);
|
|
1157
1192
|
if (options.platformProducer?.kind !== 'linux-cross') {
|
|
@@ -1194,7 +1229,7 @@ function renderMacosPlatformSteps(options: PublishWorkflowDefinitionOptions): st
|
|
|
1194
1229
|
' with:',
|
|
1195
1230
|
` devenv-cache-hit: ${githubExpression('steps.setup.outputs.devenv-cache-hit')}`,
|
|
1196
1231
|
);
|
|
1197
|
-
return lines.join('\n').trimEnd();
|
|
1232
|
+
return mergeProducerStepEnvironment(lines, options.platformProducer).join('\n').trimEnd();
|
|
1198
1233
|
}
|
|
1199
1234
|
|
|
1200
1235
|
function renderFinalLinuxPublishSteps(options: PublishWorkflowDefinitionOptions): string {
|
|
@@ -1206,11 +1241,12 @@ function renderFinalLinuxPublishSteps(options: PublishWorkflowDefinitionOptions)
|
|
|
1206
1241
|
' # Step 1: GitHub adds "Set up job" automatically',
|
|
1207
1242
|
` # Step ${stepNumber++}`,
|
|
1208
1243
|
' - name: 📥 Checkout dispatch commit',
|
|
1209
|
-
|
|
1244
|
+
` uses: ${githubActionPins.checkout.ref} # ${githubActionPins.checkout.version}`,
|
|
1210
1245
|
' with:',
|
|
1211
1246
|
` ref: ${githubExpression('github.sha')}`,
|
|
1212
|
-
' filter: blob:none',
|
|
1213
1247
|
' fetch-depth: 0',
|
|
1248
|
+
' # smoo publish and pending-release repair push release refs.',
|
|
1249
|
+
' persist-credentials: true',
|
|
1214
1250
|
];
|
|
1215
1251
|
const publishCargoCredentials = cargoCredentialsStepLines(options);
|
|
1216
1252
|
if (publishCargoCredentials.length > 0) {
|
|
@@ -1503,20 +1539,202 @@ function skipsPublishHandoff(options: PublishWorkflowDefinitionOptions): boolean
|
|
|
1503
1539
|
return !hasMacosPlatformTargets(options) || options.platformProducer?.kind === 'linux-cross';
|
|
1504
1540
|
}
|
|
1505
1541
|
|
|
1542
|
+
type PlatformProducer = NonNullable<PublishWorkflowDefinitionOptions['platformProducer']>;
|
|
1543
|
+
|
|
1544
|
+
/** Names become YAML keys of every step's `env:`, so only portable identifiers are admissible. */
|
|
1545
|
+
const PLATFORM_PRODUCER_ENV_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
1546
|
+
|
|
1506
1547
|
/**
|
|
1507
|
-
*
|
|
1508
|
-
*
|
|
1509
|
-
*
|
|
1510
|
-
*
|
|
1548
|
+
* The producer's toolchain preflight, shared by the dedicated producer job and
|
|
1549
|
+
* the flattened single job. It is an ordinary step of that job: the declared
|
|
1550
|
+
* environment reaches it through `mergeProducerStepEnvironment` exactly as it
|
|
1551
|
+
* reaches every other step, so the preflight checks the toolchain the build sees.
|
|
1511
1552
|
*/
|
|
1512
|
-
function
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
return '';
|
|
1553
|
+
function platformProducerPreflightStepLines(producer: PlatformProducer): string[] {
|
|
1554
|
+
if (!producer.preflight.trim()) {
|
|
1555
|
+
throw new Error('Linux cross-platform production requires a nonempty toolchain preflight command.');
|
|
1516
1556
|
}
|
|
1517
|
-
return
|
|
1518
|
-
|
|
1519
|
-
.
|
|
1557
|
+
return [
|
|
1558
|
+
' - name: Check cross-platform toolchain prerequisites',
|
|
1559
|
+
' working-directory: .',
|
|
1560
|
+
' run: |',
|
|
1561
|
+
' set -euo pipefail',
|
|
1562
|
+
...producer.preflight.split('\n').map((line) => ` ${line}`),
|
|
1563
|
+
];
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
/** One declared producer variable. */
|
|
1567
|
+
type ProducerEnvEntry = readonly [name: string, value: string];
|
|
1568
|
+
|
|
1569
|
+
/**
|
|
1570
|
+
* The declared variables, each proved a valid key of a step `env:`. GitHub
|
|
1571
|
+
* rejects mapping keys that differ only by case as duplicates, so such a pair
|
|
1572
|
+
* cannot share one env mapping: it fails here, naming both, not in CI.
|
|
1573
|
+
*/
|
|
1574
|
+
function platformProducerEnvEntries(producer: PlatformProducer | undefined): ProducerEnvEntry[] {
|
|
1575
|
+
const entries = Object.entries(producer?.env ?? {});
|
|
1576
|
+
const byUpperCase = new Map<string, string>();
|
|
1577
|
+
for (const [name] of entries) {
|
|
1578
|
+
if (!PLATFORM_PRODUCER_ENV_NAME.test(name)) {
|
|
1579
|
+
throw new Error(
|
|
1580
|
+
`smoo.github.platformProducer.env name ${JSON.stringify(name)} is not a valid environment variable name.`,
|
|
1581
|
+
);
|
|
1582
|
+
}
|
|
1583
|
+
const upper = name.toUpperCase();
|
|
1584
|
+
const twin = byUpperCase.get(upper);
|
|
1585
|
+
if (twin !== undefined) {
|
|
1586
|
+
throw new Error(
|
|
1587
|
+
`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.`,
|
|
1588
|
+
);
|
|
1589
|
+
}
|
|
1590
|
+
byUpperCase.set(upper, name);
|
|
1591
|
+
}
|
|
1592
|
+
return entries;
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
/** A top-level step opens with exactly this prefix, and its own env mapping with exactly this header. */
|
|
1596
|
+
const RENDERED_STEP_OPENER = ' - name:';
|
|
1597
|
+
const RENDERED_STEP_ENV_HEADER = ' env:';
|
|
1598
|
+
|
|
1599
|
+
/**
|
|
1600
|
+
* The producer's declared environment, carried by every step of its job as that
|
|
1601
|
+
* step's own `env:`.
|
|
1602
|
+
*
|
|
1603
|
+
* Step env is the one transport that carries every declarable name: GitHub
|
|
1604
|
+
* forbids `NODE_OPTIONS` in `GITHUB_ENV`, and a job-level `env` cannot evaluate
|
|
1605
|
+
* the `runner` context an SDK path under `runner.temp` needs. A step's own fields
|
|
1606
|
+
* win: a variable the step already scopes (release inputs, the publisher
|
|
1607
|
+
* credential, Cargo and source-checkout secrets) keeps its value and only the
|
|
1608
|
+
* producer's copy is omitted from that step, so no step carries a key twice.
|
|
1609
|
+
* What cannot be carried fails generation naming the declared variables and the
|
|
1610
|
+
* step: a step-local key equal to a declared name ignoring case (GitHub rejects
|
|
1611
|
+
* such duplicates), or an `env:` this function cannot read.
|
|
1612
|
+
*
|
|
1613
|
+
* `lines` are the renderer's own fragments, not arbitrary YAML: every top-level
|
|
1614
|
+
* step opens with exactly ` - name:` and its own env is exactly
|
|
1615
|
+
* ` env:` with entries nested deeper. Only that block is parsed, and only
|
|
1616
|
+
* for its keys; every existing line and comment is kept as written.
|
|
1617
|
+
*/
|
|
1618
|
+
function mergeProducerStepEnvironment(lines: string[], producer: PlatformProducer | undefined): string[] {
|
|
1619
|
+
const entries = platformProducerEnvEntries(producer);
|
|
1620
|
+
if (entries.length === 0) {
|
|
1621
|
+
return lines;
|
|
1622
|
+
}
|
|
1623
|
+
const merged: string[] = [];
|
|
1624
|
+
let steps = 0;
|
|
1625
|
+
let index = 0;
|
|
1626
|
+
while (index < lines.length) {
|
|
1627
|
+
const line = lines[index];
|
|
1628
|
+
if (!line.startsWith(RENDERED_STEP_OPENER)) {
|
|
1629
|
+
if (/^ {6}- /.test(line)) {
|
|
1630
|
+
throw producerEnvMergeError(
|
|
1631
|
+
entries,
|
|
1632
|
+
`generated step ${JSON.stringify(line.trim())}`,
|
|
1633
|
+
'a top-level step must open with "- name:"',
|
|
1634
|
+
);
|
|
1635
|
+
}
|
|
1636
|
+
merged.push(line);
|
|
1637
|
+
index += 1;
|
|
1638
|
+
continue;
|
|
1639
|
+
}
|
|
1640
|
+
// A step runs until the next non-blank line indented no deeper than its opener:
|
|
1641
|
+
// the next step, or the anchor comment above it.
|
|
1642
|
+
let end = index + 1;
|
|
1643
|
+
while (end < lines.length && (lines[end].trim() === '' || /^ {7}/.test(lines[end]))) {
|
|
1644
|
+
end += 1;
|
|
1645
|
+
}
|
|
1646
|
+
merged.push(...mergeStepEnvironment(lines.slice(index, end), entries));
|
|
1647
|
+
steps += 1;
|
|
1648
|
+
index = end;
|
|
1649
|
+
}
|
|
1650
|
+
if (steps === 0) {
|
|
1651
|
+
throw producerEnvMergeError(entries, 'the rendered job', 'it has no step to carry the environment');
|
|
1652
|
+
}
|
|
1653
|
+
return merged;
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
/**
|
|
1657
|
+
* One step's lines with the producer's variables added to its own `env:`. A step
|
|
1658
|
+
* without one gets an empty header under its opener, so both shapes merge the
|
|
1659
|
+
* same way; the step's own keys win.
|
|
1660
|
+
*/
|
|
1661
|
+
function mergeStepEnvironment(step: readonly string[], entries: readonly ProducerEnvEntry[]): string[] {
|
|
1662
|
+
const where = `generated step ${JSON.stringify(step[0].slice(RENDERED_STEP_OPENER.length).trim())}`;
|
|
1663
|
+
const envFields = step.flatMap((line, index) => (/^ {8}env:/.test(line) ? [index] : []));
|
|
1664
|
+
if (envFields.length > 1) {
|
|
1665
|
+
throw producerEnvMergeError(entries, where, 'it declares env more than once');
|
|
1666
|
+
}
|
|
1667
|
+
const lines = envFields.length === 0 ? [step[0], RENDERED_STEP_ENV_HEADER, ...step.slice(1)] : step;
|
|
1668
|
+
const header = envFields.length === 0 ? 1 : envFields[0];
|
|
1669
|
+
if (lines[header] !== RENDERED_STEP_ENV_HEADER) {
|
|
1670
|
+
throw producerEnvMergeError(
|
|
1671
|
+
entries,
|
|
1672
|
+
where,
|
|
1673
|
+
`its env field ${JSON.stringify(lines[header])} is not a block mapping header`,
|
|
1674
|
+
);
|
|
1675
|
+
}
|
|
1676
|
+
// Entries are indented deeper than the header; the block ends at the next field or step comment.
|
|
1677
|
+
let end = header + 1;
|
|
1678
|
+
while (end < lines.length && /^ {9}/.test(lines[end])) {
|
|
1679
|
+
end += 1;
|
|
1680
|
+
}
|
|
1681
|
+
const ownKeys =
|
|
1682
|
+
envFields.length === 0
|
|
1683
|
+
? []
|
|
1684
|
+
: stepEnvKeys(lines.slice(header, end), (reason, cause) => producerEnvMergeError(entries, where, reason, cause));
|
|
1685
|
+
const stamped: string[] = [];
|
|
1686
|
+
for (const entry of entries) {
|
|
1687
|
+
const [name, value] = entry;
|
|
1688
|
+
const ownKey = ownKeys.find((key) => key.toUpperCase() === name.toUpperCase());
|
|
1689
|
+
if (ownKey === undefined) {
|
|
1690
|
+
stamped.push(` ${JSON.stringify(name)}: ${JSON.stringify(value)}`);
|
|
1691
|
+
} else if (ownKey !== name) {
|
|
1692
|
+
throw producerEnvMergeError(
|
|
1693
|
+
[entry],
|
|
1694
|
+
where,
|
|
1695
|
+
`its own env key ${JSON.stringify(ownKey)} differs from the declared name only by case, which GitHub Actions rejects as a duplicate key`,
|
|
1696
|
+
);
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
return [...lines.slice(0, header + 1), ...stamped, ...lines.slice(header + 1)];
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
/** The keys of one step's own `env:` block, read by the YAML parser; the block's lines stay as written. */
|
|
1703
|
+
function stepEnvKeys(block: readonly string[], fail: (reason: string, cause?: unknown) => Error): string[] {
|
|
1704
|
+
const document = parseDocument(block.join('\n'), { prettyErrors: false });
|
|
1705
|
+
if (document.errors.length > 0) {
|
|
1706
|
+
const reasons = document.errors.map((error) => `${error.message} (${error.code})`).join('; ');
|
|
1707
|
+
throw fail(`its env block is not valid YAML: ${reasons}`, document.errors[0]);
|
|
1708
|
+
}
|
|
1709
|
+
const root = document.contents;
|
|
1710
|
+
const field = isMap(root) ? root.items.find((item) => isScalar(item.key) && item.key.value === 'env') : undefined;
|
|
1711
|
+
const env = field?.value;
|
|
1712
|
+
if (env === null || (isScalar(env) && env.value === null)) {
|
|
1713
|
+
return [];
|
|
1714
|
+
}
|
|
1715
|
+
if (!isMap(env)) {
|
|
1716
|
+
throw fail('its env block is not a mapping');
|
|
1717
|
+
}
|
|
1718
|
+
return env.items.map((pair) => {
|
|
1719
|
+
const key = pair.key;
|
|
1720
|
+
if (!isScalar(key) || typeof key.value !== 'string') {
|
|
1721
|
+
throw fail('its env block has a key that is not a string', pair);
|
|
1722
|
+
}
|
|
1723
|
+
return key.value;
|
|
1724
|
+
});
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
function producerEnvMergeError(
|
|
1728
|
+
entries: readonly ProducerEnvEntry[],
|
|
1729
|
+
where: string,
|
|
1730
|
+
reason: string,
|
|
1731
|
+
cause?: unknown,
|
|
1732
|
+
): Error {
|
|
1733
|
+
const names = entries.map(([name]) => JSON.stringify(name)).join(', ');
|
|
1734
|
+
return new Error(
|
|
1735
|
+
`smoo.github.platformProducer.env ${names} cannot be merged into ${where}: ${reason}.`,
|
|
1736
|
+
cause === undefined ? undefined : { cause },
|
|
1737
|
+
);
|
|
1520
1738
|
}
|
|
1521
1739
|
|
|
1522
1740
|
function privateNpmInstallJobEnv(options: PublishWorkflowDefinitionOptions): string {
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test';
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import { mkdir, mkdtemp, readFile, rm, symlink, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { dirname, join } from 'node:path';
|
|
6
|
+
import { managedAssetsRoot } from '../managed-assets.js';
|
|
7
|
+
|
|
8
|
+
interface RepoPathFixture {
|
|
9
|
+
readonly root: string;
|
|
10
|
+
readonly helper: string;
|
|
11
|
+
readonly home: string;
|
|
12
|
+
readonly venv: string;
|
|
13
|
+
readonly installed: string;
|
|
14
|
+
readonly tools: string;
|
|
15
|
+
readonly entries: string[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async function executable(path: string, marker: string): Promise<void> {
|
|
19
|
+
await mkdir(dirname(path), { recursive: true });
|
|
20
|
+
await writeFile(path, `#!/bin/sh\nprintf '%s\\n' '${marker}'\n`, { mode: 0o755 });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function withRepoPath(run: (fixture: RepoPathFixture) => Promise<void>): Promise<void> {
|
|
24
|
+
const root = await mkdtemp(join(tmpdir(), 'smoo-repo-path-'));
|
|
25
|
+
try {
|
|
26
|
+
const helper = join(root, 'tooling/direnv/repo-path');
|
|
27
|
+
await mkdir(dirname(helper), { recursive: true });
|
|
28
|
+
await writeFile(helper, await readFile(join(managedAssetsRoot, 'raw/tooling/direnv/repo-path')), { mode: 0o755 });
|
|
29
|
+
const tools = join(root, 'system-bin');
|
|
30
|
+
await mkdir(tools);
|
|
31
|
+
// Resolve the script's tools before scrubbing PATH; /usr/bin:/bin is not
|
|
32
|
+
// a coreutils installation on NixOS.
|
|
33
|
+
for (const tool of ['bash', 'dirname']) {
|
|
34
|
+
const resolved = Bun.which(tool);
|
|
35
|
+
if (resolved === null) throw new Error(`${tool} must be on PATH`);
|
|
36
|
+
await symlink(resolved, join(tools, tool));
|
|
37
|
+
}
|
|
38
|
+
const home = join(root, 'private home');
|
|
39
|
+
const venv = join(root, 'active venv');
|
|
40
|
+
const installed = join(home, 'Library/Application Support/dev.cowshed/bin');
|
|
41
|
+
const entries = [
|
|
42
|
+
join(root, 'tooling/direnv/.devenv/profile/bin'),
|
|
43
|
+
join(root, 'tooling/git-hooks'),
|
|
44
|
+
join(root, 'tooling'),
|
|
45
|
+
join(root, 'tooling/node_modules/.bin'),
|
|
46
|
+
join(root, 'node_modules/.bin'),
|
|
47
|
+
];
|
|
48
|
+
await executable(join(entries[0], 'python3'), 'profile-python');
|
|
49
|
+
await executable(join(entries[0], 'cargo'), 'profile-cargo');
|
|
50
|
+
await executable(join(venv, 'bin/python3'), 'venv-python');
|
|
51
|
+
await executable(join(venv, 'bin/cargo'), 'venv-cargo');
|
|
52
|
+
await executable(join(installed, 'cargo'), 'installed-cargo');
|
|
53
|
+
await run({ root, helper, home, venv, installed, tools, entries });
|
|
54
|
+
} finally {
|
|
55
|
+
await rm(root, { recursive: true, force: true });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function helper(fixture: RepoPathFixture, args: readonly string[], virtualEnv?: string, path = fixture.tools) {
|
|
60
|
+
const result = spawnSync(join(fixture.tools, 'bash'), [fixture.helper, ...args], {
|
|
61
|
+
encoding: 'utf8',
|
|
62
|
+
env: { HOME: fixture.home, PATH: path, ...(virtualEnv === undefined ? {} : { VIRTUAL_ENV: virtualEnv }) },
|
|
63
|
+
});
|
|
64
|
+
expect(result.status).toBe(0);
|
|
65
|
+
expect(result.stderr).toBe('');
|
|
66
|
+
return result.stdout;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function expectModes(fixture: RepoPathFixture, entries: string[], virtualEnv?: string): Promise<void> {
|
|
70
|
+
expect(helper(fixture, ['--print'], virtualEnv)).toBe(`${entries.join('\n')}\n`);
|
|
71
|
+
const githubPath = join(fixture.root, 'github-path');
|
|
72
|
+
await writeFile(githubPath, 'existing-entry\n');
|
|
73
|
+
const result = spawnSync(join(fixture.tools, 'bash'), [fixture.helper, '--github-path'], {
|
|
74
|
+
encoding: 'utf8',
|
|
75
|
+
env: {
|
|
76
|
+
HOME: fixture.home,
|
|
77
|
+
PATH: fixture.tools,
|
|
78
|
+
GITHUB_PATH: githubPath,
|
|
79
|
+
...(virtualEnv === undefined ? {} : { VIRTUAL_ENV: virtualEnv }),
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
expect(result.status).toBe(0);
|
|
83
|
+
expect(result.stderr).toBe('');
|
|
84
|
+
expect(await readFile(githubPath, 'utf8')).toBe(`existing-entry\n${[...entries].reverse().join('\n')}\n`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
describe('managed repo-path', () => {
|
|
88
|
+
it.each([undefined, ''])('preserves the exact legacy ordering without an active venv (%p)', async (virtualEnv) => {
|
|
89
|
+
await withRepoPath(async (fixture) => {
|
|
90
|
+
await expectModes(fixture, fixture.entries, virtualEnv);
|
|
91
|
+
expect(helper(fixture, [], virtualEnv)).toBe(
|
|
92
|
+
`${[fixture.installed, ...fixture.entries].join(':')}:${fixture.tools}\n`,
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it.each([false, true])(
|
|
98
|
+
'keeps active Python ahead of the profile and installed Cargo first (served=%p)',
|
|
99
|
+
async (served) => {
|
|
100
|
+
await withRepoPath(async (fixture) => {
|
|
101
|
+
if (served) {
|
|
102
|
+
await mkdir(join(fixture.root, '.cowshed'), { recursive: true });
|
|
103
|
+
await writeFile(
|
|
104
|
+
join(fixture.root, '.cowshed/env'),
|
|
105
|
+
`export COWSHED_RUNTIME_LINK=fixture\nexport PATH=${JSON.stringify(fixture.installed)}:$PATH\n`,
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
const entries = [join(fixture.venv, 'bin'), ...fixture.entries];
|
|
109
|
+
await expectModes(fixture, entries, fixture.venv);
|
|
110
|
+
const incoming = `${join(fixture.venv, 'bin')}:${fixture.tools}`;
|
|
111
|
+
const path = helper(fixture, [], fixture.venv, incoming).trimEnd();
|
|
112
|
+
expect(path).toBe(`${[fixture.installed, ...entries].join(':')}:${incoming}`);
|
|
113
|
+
const selected = spawnSync(
|
|
114
|
+
join(fixture.tools, 'bash'),
|
|
115
|
+
['-c', 'command -v python3; python3; command -v cargo; cargo'],
|
|
116
|
+
{
|
|
117
|
+
encoding: 'utf8',
|
|
118
|
+
env: { HOME: fixture.home, PATH: path },
|
|
119
|
+
},
|
|
120
|
+
);
|
|
121
|
+
expect(selected.status).toBe(0);
|
|
122
|
+
expect(selected.stderr).toBe('');
|
|
123
|
+
expect(selected.stdout).toBe(
|
|
124
|
+
`${join(fixture.venv, 'bin/python3')}\nvenv-python\n${join(fixture.installed, 'cargo')}\ninstalled-cargo\n`,
|
|
125
|
+
);
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
);
|
|
129
|
+
});
|