@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.
- 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 +1146 -159
- 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
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
|
|
2
|
+
import { mkdirSync, mkdtempSync, readdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { basename, dirname, join } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The managed Forgejo artifact actions run the pinned original clients through a real child Node. These tests drive the
|
|
9
|
+
* real shared bootstrap against a local git repository standing in for code.forgejo.org (file:// transport, never the
|
|
10
|
+
* network) and observe what the original entry actually received.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const actions = fileURLToPath(new URL('../../managed/templates/github/actions/', import.meta.url));
|
|
14
|
+
const helper = join(actions, 'forgejo-artifact.cjs');
|
|
15
|
+
|
|
16
|
+
const node = Bun.which('node');
|
|
17
|
+
const realGit = Bun.which('git');
|
|
18
|
+
if (node === null || realGit === null) throw new Error('These tests need node and git on PATH');
|
|
19
|
+
|
|
20
|
+
const hermeticGit = {
|
|
21
|
+
GIT_CONFIG_NOSYSTEM: '1',
|
|
22
|
+
GIT_CONFIG_GLOBAL: '/dev/null',
|
|
23
|
+
GIT_AUTHOR_NAME: 'fixture',
|
|
24
|
+
GIT_AUTHOR_EMAIL: 'fixture@example.invalid',
|
|
25
|
+
GIT_COMMITTER_NAME: 'fixture',
|
|
26
|
+
GIT_COMMITTER_EMAIL: 'fixture@example.invalid',
|
|
27
|
+
// The pin is deliberately not a branch tip, so the fixture must serve any reachable commit by SHA.
|
|
28
|
+
GIT_CONFIG_COUNT: '1',
|
|
29
|
+
GIT_CONFIG_KEY_0: 'uploadpack.allowAnySHA1InWant',
|
|
30
|
+
GIT_CONFIG_VALUE_0: 'true',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** The original action's stand-in: records exactly what it received, then behaves as FIXTURE_MODE says. */
|
|
34
|
+
const originalEntry = `
|
|
35
|
+
const fs = require('node:fs');
|
|
36
|
+
const path = require('node:path');
|
|
37
|
+
const { spawnSync } = require('node:child_process');
|
|
38
|
+
const root = path.resolve(__dirname, '..');
|
|
39
|
+
const git = (args) => spawnSync('git', ['-C', root, ...args], { encoding: 'utf8' }).stdout.trim();
|
|
40
|
+
const inputs = Object.keys(process.env)
|
|
41
|
+
.filter((name) => name.startsWith('INPUT_'))
|
|
42
|
+
.sort()
|
|
43
|
+
.map((name) => name + '=' + process.env[name]);
|
|
44
|
+
fs.writeFileSync(process.env.FIXTURE_RECORD, JSON.stringify({
|
|
45
|
+
argv: process.argv.slice(2),
|
|
46
|
+
execPath: process.execPath,
|
|
47
|
+
cwd: process.cwd(),
|
|
48
|
+
root,
|
|
49
|
+
head: git(['rev-parse', 'HEAD']),
|
|
50
|
+
commits: git(['rev-list', '--count', 'HEAD']),
|
|
51
|
+
gitConfig: fs.readFileSync(path.join(root, '.git', 'config'), 'utf8'),
|
|
52
|
+
inputs,
|
|
53
|
+
marker: process.env.FIXTURE_MARKER,
|
|
54
|
+
}));
|
|
55
|
+
fs.appendFileSync(process.env.GITHUB_OUTPUT, 'artifact-id=42\\n');
|
|
56
|
+
process.stdout.write('fixture stdout\\n');
|
|
57
|
+
process.stderr.write('fixture stderr\\n');
|
|
58
|
+
const mode = process.env.FIXTURE_MODE;
|
|
59
|
+
if (mode === 'exit') process.exit(7);
|
|
60
|
+
if (mode === 'kill') process.kill(process.pid, 'SIGKILL');
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
const siblingTipEntry = `
|
|
64
|
+
process.stderr.write('the branch tip ran instead of the pin\\n');
|
|
65
|
+
process.exit(99);
|
|
66
|
+
`;
|
|
67
|
+
|
|
68
|
+
const driver = `
|
|
69
|
+
const [helperPath, pin] = process.argv.slice(2);
|
|
70
|
+
if (process.env.FIXTURE_MODE === 'cleanup-error') {
|
|
71
|
+
require('node:fs').rmSync = () => { throw new Error('fixture cleanup failure'); };
|
|
72
|
+
}
|
|
73
|
+
require(helperPath).run(JSON.parse(pin));
|
|
74
|
+
`;
|
|
75
|
+
|
|
76
|
+
interface ReceivedRecord {
|
|
77
|
+
argv: string[];
|
|
78
|
+
execPath: string;
|
|
79
|
+
cwd: string;
|
|
80
|
+
root: string;
|
|
81
|
+
head: string;
|
|
82
|
+
commits: string;
|
|
83
|
+
gitConfig: string;
|
|
84
|
+
inputs: string[];
|
|
85
|
+
marker: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface Pin {
|
|
89
|
+
repository: string;
|
|
90
|
+
commit: string;
|
|
91
|
+
entry: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
interface Outcome {
|
|
95
|
+
status: number | null;
|
|
96
|
+
stdout: string;
|
|
97
|
+
stderr: string;
|
|
98
|
+
runnerTemp: string;
|
|
99
|
+
workspace: string;
|
|
100
|
+
output: string;
|
|
101
|
+
record: ReceivedRecord | undefined;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let scratch = '';
|
|
105
|
+
let upstream = '';
|
|
106
|
+
let pinnedCommit = '';
|
|
107
|
+
let nodeExecPath = '';
|
|
108
|
+
let caseNumber = 0;
|
|
109
|
+
|
|
110
|
+
function git(directory: string, args: string[]): string {
|
|
111
|
+
const result = Bun.spawnSync([realGit ?? 'git', '-C', directory, ...args], {
|
|
112
|
+
env: { ...process.env, ...hermeticGit },
|
|
113
|
+
});
|
|
114
|
+
if (result.exitCode !== 0) throw new Error('git ' + args.join(' ') + ': ' + result.stderr.toString());
|
|
115
|
+
return result.stdout.toString().trim();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function inheritedEnvironment(): Record<string, string> {
|
|
119
|
+
const environment: Record<string, string> = {};
|
|
120
|
+
for (const [name, value] of Object.entries(process.env)) {
|
|
121
|
+
if (value !== undefined && !name.startsWith('INPUT_')) environment[name] = value;
|
|
122
|
+
}
|
|
123
|
+
return environment;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
beforeAll(() => {
|
|
127
|
+
scratch = realpathSync(mkdtempSync(join(tmpdir(), 'forgejo-artifact-test-')));
|
|
128
|
+
upstream = join(scratch, 'upstream');
|
|
129
|
+
mkdirSync(join(upstream, 'dist'), { recursive: true });
|
|
130
|
+
git(upstream, ['init', '--quiet', '--initial-branch=main']);
|
|
131
|
+
writeFileSync(join(upstream, 'dist', 'index.js'), originalEntry);
|
|
132
|
+
git(upstream, ['add', '.']);
|
|
133
|
+
git(upstream, ['commit', '--quiet', '-m', 'pinned']);
|
|
134
|
+
pinnedCommit = git(upstream, ['rev-parse', 'HEAD']);
|
|
135
|
+
writeFileSync(join(upstream, 'dist', 'index.js'), siblingTipEntry);
|
|
136
|
+
git(upstream, ['commit', '--quiet', '-am', 'tip']);
|
|
137
|
+
writeFileSync(join(scratch, 'driver.cjs'), driver);
|
|
138
|
+
const execPath = Bun.spawnSync([node ?? 'node', '-p', 'process.execPath']);
|
|
139
|
+
nodeExecPath = execPath.stdout.toString().trim();
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
afterAll(() => {
|
|
143
|
+
rmSync(scratch, { recursive: true, force: true });
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
interface RunOptions {
|
|
147
|
+
/** What to run: the shared bootstrap with this pin, or a managed entry file used as-is. */
|
|
148
|
+
pin?: Partial<Pin>;
|
|
149
|
+
entryFile?: string;
|
|
150
|
+
environment?: Record<string, string>;
|
|
151
|
+
withoutRunnerTemp?: boolean;
|
|
152
|
+
path?: string;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function run(options: RunOptions = {}): Outcome {
|
|
156
|
+
caseNumber += 1;
|
|
157
|
+
const directory = join(scratch, 'case-' + caseNumber);
|
|
158
|
+
const runnerTemp = join(directory, 'runner-temp');
|
|
159
|
+
const workspace = join(directory, 'workspace');
|
|
160
|
+
const output = join(directory, 'github-output');
|
|
161
|
+
const recordPath = join(directory, 'record.json');
|
|
162
|
+
mkdirSync(runnerTemp, { recursive: true });
|
|
163
|
+
mkdirSync(workspace);
|
|
164
|
+
writeFileSync(output, '');
|
|
165
|
+
const environment: Record<string, string> = {
|
|
166
|
+
...inheritedEnvironment(),
|
|
167
|
+
...hermeticGit,
|
|
168
|
+
RUNNER_TEMP: runnerTemp,
|
|
169
|
+
GITHUB_OUTPUT: output,
|
|
170
|
+
FIXTURE_RECORD: recordPath,
|
|
171
|
+
...(options.path === undefined ? {} : { PATH: options.path }),
|
|
172
|
+
...options.environment,
|
|
173
|
+
};
|
|
174
|
+
if (options.withoutRunnerTemp) delete environment.RUNNER_TEMP;
|
|
175
|
+
const pin: Pin = { repository: 'file://' + upstream, commit: pinnedCommit, entry: 'dist/index.js', ...options.pin };
|
|
176
|
+
const command =
|
|
177
|
+
options.entryFile === undefined
|
|
178
|
+
? [node ?? 'node', join(scratch, 'driver.cjs'), helper, JSON.stringify(pin)]
|
|
179
|
+
: [node ?? 'node', options.entryFile];
|
|
180
|
+
const result = Bun.spawnSync(command, { cwd: workspace, env: environment });
|
|
181
|
+
let record: ReceivedRecord | undefined;
|
|
182
|
+
try {
|
|
183
|
+
record = JSON.parse(readFileSync(recordPath, 'utf8'));
|
|
184
|
+
} catch {
|
|
185
|
+
record = undefined;
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
status: result.exitCode,
|
|
189
|
+
stdout: result.stdout.toString(),
|
|
190
|
+
stderr: result.stderr.toString(),
|
|
191
|
+
runnerTemp,
|
|
192
|
+
workspace,
|
|
193
|
+
output: readFileSync(output, 'utf8'),
|
|
194
|
+
record,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
describe('forgejo artifact bootstrap', () => {
|
|
199
|
+
test('fetches the exact pinned client, preserves its outputs, and removes the credential-free checkout', () => {
|
|
200
|
+
const outcome = run();
|
|
201
|
+
expect(outcome.stderr).not.toContain('the branch tip ran');
|
|
202
|
+
expect(outcome.status).toBe(0);
|
|
203
|
+
expect(outcome.record?.head).toBe(pinnedCommit);
|
|
204
|
+
expect(outcome.record?.commits).toBe('1');
|
|
205
|
+
expect(basename(outcome.record?.root ?? '')).toStartWith('forgejo-artifact-');
|
|
206
|
+
expect(dirname(outcome.record?.root ?? '')).toBe(realpathSync(outcome.runnerTemp));
|
|
207
|
+
expect(outcome.record?.gitConfig ?? '').not.toMatch(/credential|extraheader|\[remote|\[url|token/i);
|
|
208
|
+
expect(outcome.output).toBe('artifact-id=42\n');
|
|
209
|
+
expect(outcome.stdout).toBe('fixture stdout\n');
|
|
210
|
+
expect(outcome.stderr).toBe('fixture stderr\n');
|
|
211
|
+
expect(readdirSync(outcome.runnerTemp)).toEqual([]);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
test('passes inputs, environment, working directory and the runtime through to the original entry', () => {
|
|
215
|
+
const inputs = {
|
|
216
|
+
INPUT_NAME: 'trace db',
|
|
217
|
+
'INPUT_IF-NO-FILES-FOUND': 'error',
|
|
218
|
+
INPUT_PATH: 'packages/*/.cache/lmao/trace-results.db*\nother/dir',
|
|
219
|
+
'INPUT_RETENTION-DAYS': '',
|
|
220
|
+
};
|
|
221
|
+
const outcome = run({ environment: { ...inputs, FIXTURE_MARKER: 'passed through' } });
|
|
222
|
+
expect(outcome.status).toBe(0);
|
|
223
|
+
expect(outcome.record?.inputs).toEqual(
|
|
224
|
+
Object.entries(inputs)
|
|
225
|
+
.map(([name, value]) => name + '=' + value)
|
|
226
|
+
.sort(),
|
|
227
|
+
);
|
|
228
|
+
expect(outcome.record?.marker).toBe('passed through');
|
|
229
|
+
expect(outcome.record?.argv).toEqual([]);
|
|
230
|
+
expect(outcome.record?.execPath).toBe(nodeExecPath);
|
|
231
|
+
expect(realpathSync(outcome.record?.cwd ?? '')).toBe(realpathSync(outcome.workspace));
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
test('propagates the original action exit status with a diagnostic and still cleans up', () => {
|
|
235
|
+
const outcome = run({ environment: { FIXTURE_MODE: 'exit' } });
|
|
236
|
+
expect(outcome.status).toBe(7);
|
|
237
|
+
expect(outcome.stderr).toContain(
|
|
238
|
+
'forgejo-artifact: file://' + upstream + '@' + pinnedCommit + ' dist/index.js exited with status 7',
|
|
239
|
+
);
|
|
240
|
+
expect(readdirSync(outcome.runnerTemp)).toEqual([]);
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
test('fails with a diagnostic when the original action is killed by a signal, and cleans up', () => {
|
|
244
|
+
const outcome = run({ environment: { FIXTURE_MODE: 'kill' } });
|
|
245
|
+
expect(outcome.status).toBe(1);
|
|
246
|
+
expect(outcome.stderr).toContain('was killed by signal SIGKILL');
|
|
247
|
+
expect(readdirSync(outcome.runnerTemp)).toEqual([]);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
test('fails before running anything when the pin cannot be fetched, and cleans up', () => {
|
|
251
|
+
const missing = 'a'.repeat(40);
|
|
252
|
+
const outcome = run({ pin: { commit: missing } });
|
|
253
|
+
expect(outcome.status).toBe(1);
|
|
254
|
+
expect(outcome.stderr).toContain(
|
|
255
|
+
'forgejo-artifact: git fetch --quiet --depth=1 --no-tags file://' + upstream + ' ' + missing,
|
|
256
|
+
);
|
|
257
|
+
expect(outcome.record).toBeUndefined();
|
|
258
|
+
expect(readdirSync(outcome.runnerTemp)).toEqual([]);
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
test('refuses a checkout whose HEAD is not the pin before running the original entry', () => {
|
|
262
|
+
const bin = join(scratch, 'lying-git');
|
|
263
|
+
mkdirSync(bin, { recursive: true });
|
|
264
|
+
writeFileSync(
|
|
265
|
+
join(bin, 'git'),
|
|
266
|
+
'#!/bin/sh\nfor arg in "$@"; do\n if [ "$arg" = rev-parse ]; then echo ' +
|
|
267
|
+
'0'.repeat(40) +
|
|
268
|
+
'; exit 0; fi\ndone\nexec "' +
|
|
269
|
+
realGit +
|
|
270
|
+
'" "$@"\n',
|
|
271
|
+
{ mode: 0o755 },
|
|
272
|
+
);
|
|
273
|
+
const outcome = run({ path: bin + ':' + (process.env.PATH ?? '') });
|
|
274
|
+
expect(outcome.status).toBe(1);
|
|
275
|
+
expect(outcome.stderr).toContain(
|
|
276
|
+
'checked out HEAD ' + '0'.repeat(40) + ' is not the pinned commit ' + pinnedCommit,
|
|
277
|
+
);
|
|
278
|
+
expect(outcome.record).toBeUndefined();
|
|
279
|
+
expect(readdirSync(outcome.runnerTemp)).toEqual([]);
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
test('refuses to run without RUNNER_TEMP', () => {
|
|
283
|
+
const outcome = run({ withoutRunnerTemp: true });
|
|
284
|
+
expect(outcome.status).toBe(1);
|
|
285
|
+
expect(outcome.stderr).toContain('forgejo-artifact: RUNNER_TEMP is not set');
|
|
286
|
+
expect(outcome.record).toBeUndefined();
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
test('reports a cleanup failure instead of swallowing it', () => {
|
|
290
|
+
const outcome = run({ environment: { FIXTURE_MODE: 'cleanup-error' } });
|
|
291
|
+
expect(outcome.status).toBe(1);
|
|
292
|
+
expect(outcome.stderr).toContain('forgejo-artifact: could not remove ' + outcome.record?.root);
|
|
293
|
+
expect(outcome.stderr).toContain('fixture cleanup failure');
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
describe('managed Forgejo artifact actions', () => {
|
|
298
|
+
const wrappers: Array<
|
|
299
|
+
Pin & { directory: string; inputs: Record<string, { default?: string; required?: boolean }>; outputs: string[] }
|
|
300
|
+
> = [
|
|
301
|
+
{
|
|
302
|
+
directory: 'forgejo-upload-artifact',
|
|
303
|
+
repository: 'https://code.forgejo.org/forgejo/upload-artifact',
|
|
304
|
+
commit: 'cb8afe72b42edc798abfb8fcb556cf660d894245',
|
|
305
|
+
entry: 'dist/upload/index.js',
|
|
306
|
+
inputs: {
|
|
307
|
+
name: { default: 'artifact' },
|
|
308
|
+
path: { required: true },
|
|
309
|
+
'if-no-files-found': { default: 'warn' },
|
|
310
|
+
'retention-days': {},
|
|
311
|
+
'compression-level': { default: '6' },
|
|
312
|
+
overwrite: { default: 'false' },
|
|
313
|
+
'include-hidden-files': { default: 'false' },
|
|
314
|
+
},
|
|
315
|
+
outputs: ['artifact-id', 'artifact-url', 'artifact-digest'],
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
directory: 'forgejo-download-artifact',
|
|
319
|
+
repository: 'https://code.forgejo.org/forgejo/download-artifact',
|
|
320
|
+
commit: '769f970437aa3291b13f35dc23fc87967d7fb19f',
|
|
321
|
+
entry: 'dist/index.js',
|
|
322
|
+
inputs: {
|
|
323
|
+
name: { required: false },
|
|
324
|
+
'artifact-ids': { required: false },
|
|
325
|
+
path: { required: false },
|
|
326
|
+
pattern: { required: false },
|
|
327
|
+
'merge-multiple': { required: false, default: 'false' },
|
|
328
|
+
'github-token': { required: false },
|
|
329
|
+
repository: { required: false, default: '${{ github.repository }}' },
|
|
330
|
+
'run-id': { required: false, default: '${{ github.run_id }}' },
|
|
331
|
+
},
|
|
332
|
+
outputs: ['download-path'],
|
|
333
|
+
},
|
|
334
|
+
];
|
|
335
|
+
|
|
336
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
337
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function section(manifest: unknown, key: string): Record<string, unknown> {
|
|
341
|
+
if (!isRecord(manifest)) throw new Error('The action manifest must be a mapping');
|
|
342
|
+
const value = manifest[key];
|
|
343
|
+
if (!isRecord(value)) throw new Error('The action manifest must have a ' + key + ' mapping');
|
|
344
|
+
return value;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
for (const wrapper of wrappers) {
|
|
348
|
+
describe(wrapper.directory, () => {
|
|
349
|
+
const manifest: unknown = Bun.YAML.parse(readFileSync(join(actions, wrapper.directory, 'action.yml'), 'utf8'));
|
|
350
|
+
|
|
351
|
+
test('forwards every upstream input default and requirement and every output, on the node24 runtime', () => {
|
|
352
|
+
const inputs = Object.fromEntries(
|
|
353
|
+
Object.entries(section(manifest, 'inputs')).map(([name, input]) => {
|
|
354
|
+
if (!isRecord(input) || typeof input.description !== 'string' || input.description === '') {
|
|
355
|
+
throw new Error('Input ' + name + ' must keep its description');
|
|
356
|
+
}
|
|
357
|
+
return [name, Object.fromEntries(Object.entries(input).filter(([key]) => key !== 'description'))];
|
|
358
|
+
}),
|
|
359
|
+
);
|
|
360
|
+
expect(inputs).toEqual(wrapper.inputs);
|
|
361
|
+
expect(Object.keys(section(manifest, 'outputs'))).toEqual(wrapper.outputs);
|
|
362
|
+
expect(section(manifest, 'runs')).toEqual({ using: 'node24', main: 'index.cjs' });
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
test('declares no output value, because the original action writes GITHUB_OUTPUT itself', () => {
|
|
366
|
+
for (const output of Object.values(section(manifest, 'outputs'))) {
|
|
367
|
+
expect(isRecord(output) && 'value' in output).toBe(false);
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
test('calls the shared bootstrap with only its exact pinned repository, commit and entry', () => {
|
|
372
|
+
const entry = readFileSync(join(actions, wrapper.directory, 'index.cjs'), 'utf8');
|
|
373
|
+
expect(entry).toContain("require('../forgejo-artifact.cjs').run({");
|
|
374
|
+
expect(entry).toContain("repository: '" + wrapper.repository + "'");
|
|
375
|
+
expect(entry).toContain("commit: '" + wrapper.commit + "'");
|
|
376
|
+
expect(entry).toContain("entry: '" + wrapper.entry + "'");
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
test('fails closed naming its pin when the upstream cannot serve that commit', () => {
|
|
380
|
+
const outcome = run({
|
|
381
|
+
entryFile: join(actions, wrapper.directory, 'index.cjs'),
|
|
382
|
+
environment: {
|
|
383
|
+
GIT_CONFIG_COUNT: '2',
|
|
384
|
+
GIT_CONFIG_KEY_1: 'url.file://' + upstream + '.insteadOf',
|
|
385
|
+
GIT_CONFIG_VALUE_1: wrapper.repository,
|
|
386
|
+
},
|
|
387
|
+
});
|
|
388
|
+
expect(outcome.status).toBe(1);
|
|
389
|
+
expect(outcome.stderr).toContain(wrapper.repository + ' ' + wrapper.commit);
|
|
390
|
+
expect(outcome.record).toBeUndefined();
|
|
391
|
+
expect(readdirSync(outcome.runnerTemp)).toEqual([]);
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
});
|
|
@@ -10,6 +10,7 @@ import type { PackageJson } from '../workspace-manifest.js';
|
|
|
10
10
|
import type { WorkspaceProjects } from './context.js';
|
|
11
11
|
import { generateManagedFiles } from './generator.js';
|
|
12
12
|
import { INLINE_LOCAL_BEGIN, INLINE_LOCAL_END, LOCAL_SECTION_MARKER } from './managed-content.js';
|
|
13
|
+
import { renderPublishWorkflowYaml } from './publish-workflow.js';
|
|
13
14
|
import { assertNoManagedConflicts } from './tree.js';
|
|
14
15
|
|
|
15
16
|
const repository = 'https://github.com/example/workspace.git';
|
|
@@ -65,6 +66,60 @@ describe('managed-files generator', () => {
|
|
|
65
66
|
expect(tree.listChanges().find((change) => change.path === 'tooling/devenv')?.options?.mode).toBe(0o755);
|
|
66
67
|
});
|
|
67
68
|
|
|
69
|
+
it('passes the real workflow validator for both artifact providers without rule exceptions', async () => {
|
|
70
|
+
for (const actionsProvider of ['github', 'forgejo'] as const) {
|
|
71
|
+
const root = mkdtempSync(join(tmpdir(), 'smoo-workflow-lint-'));
|
|
72
|
+
expect(Bun.spawnSync(['git', 'init', '--quiet', root]).exitCode).toBe(0);
|
|
73
|
+
temporaryRoots.push(root);
|
|
74
|
+
const tree = workspace();
|
|
75
|
+
updateJson<PackageJson>(tree, 'package.json', (pkg) => ({
|
|
76
|
+
...pkg,
|
|
77
|
+
smoo: { github: { actionsProvider } },
|
|
78
|
+
}));
|
|
79
|
+
flushChanges(root, tree.listChanges());
|
|
80
|
+
const generated = new FsTree(root, false);
|
|
81
|
+
await generate(generated);
|
|
82
|
+
const producer = renderPublishWorkflowYaml({
|
|
83
|
+
repoName: 'example/workspace',
|
|
84
|
+
actionsProvider,
|
|
85
|
+
platformTargetGlobs: ['*-macos'],
|
|
86
|
+
privateNpm: { scope: '@example', readTokenEnv: 'READ_TOKEN', publishTokenEnv: 'PUBLISH_TOKEN' },
|
|
87
|
+
platformProducer: {
|
|
88
|
+
kind: 'linux-cross',
|
|
89
|
+
preflight: 'test -n "$name$delimiter$SDKROOT"',
|
|
90
|
+
env: {
|
|
91
|
+
name: 'first value',
|
|
92
|
+
delimiter: 'second value',
|
|
93
|
+
__SMOO_ENV_DELIMITER: 'former scratch name',
|
|
94
|
+
SDKROOT: '${{ runner.temp }}/sdk',
|
|
95
|
+
// GitHub refuses NODE_OPTIONS through GITHUB_ENV, so only a step's own env carries it, beside the others.
|
|
96
|
+
NODE_OPTIONS: '--require ${{ runner.temp }}/preload.cjs --max-old-space-size=4096',
|
|
97
|
+
TRUE: 'upper true identifier',
|
|
98
|
+
FALSE: 'upper false identifier',
|
|
99
|
+
NULL: 'upper null identifier',
|
|
100
|
+
// Names generated steps also declare keep the step's own value: the validator rejects a repeated key.
|
|
101
|
+
SMOO_RELEASE_PROJECTS: 'producer-chosen projects',
|
|
102
|
+
PUBLISH_TOKEN: 'producer-chosen credential',
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
// The validator must judge the direct env on more than one step, not a workflow that dropped it.
|
|
107
|
+
const carriers = workflowSteps(producer).filter((step) => {
|
|
108
|
+
const env = step.get('env');
|
|
109
|
+
return typeof env === 'object' && env !== null && 'NODE_OPTIONS' in env;
|
|
110
|
+
});
|
|
111
|
+
expect(carriers.length).toBeGreaterThan(1);
|
|
112
|
+
generated.write('.github/workflows/producer.yml', producer);
|
|
113
|
+
flushChanges(root, generated.listChanges());
|
|
114
|
+
const result = Bun.spawnSync(['jactionlint', '--no-online', '--config-file', '/dev/null', '--strict-exit'], {
|
|
115
|
+
cwd: root,
|
|
116
|
+
env: process.env,
|
|
117
|
+
});
|
|
118
|
+
expect(result.stderr.toString() + result.stdout.toString()).toBe('');
|
|
119
|
+
expect(result.exitCode).toBe(0);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
68
123
|
it('uses manifest edits from Tree, not the checkout that runs the tests', async () => {
|
|
69
124
|
const tree = workspace();
|
|
70
125
|
updateJson<PackageJson>(tree, 'package.json', (pkg) => ({
|
|
@@ -172,11 +227,15 @@ describe('managed-files generator', () => {
|
|
|
172
227
|
// inside a workspace with inherited Prettier settings.
|
|
173
228
|
flushChanges(root, workspace().listChanges());
|
|
174
229
|
const first = new FsTree(root, false);
|
|
175
|
-
await
|
|
230
|
+
const initialResults = await generateManagedFiles(first, projects, new Map());
|
|
231
|
+
assertNoManagedConflicts(initialResults);
|
|
232
|
+
const initialTargets = initialResults.map((result) => result.target).sort();
|
|
233
|
+
expect(initialTargets).toContain('tooling/devenv');
|
|
176
234
|
flushChanges(root, first.listChanges());
|
|
177
235
|
const second = new FsTree(root, false);
|
|
178
236
|
const results = await generateManagedFiles(second, projects);
|
|
179
237
|
assertNoManagedConflicts(results);
|
|
238
|
+
expect(results.map((result) => result.target).sort()).toEqual(initialTargets);
|
|
180
239
|
expect(second.listChanges()).toEqual([]);
|
|
181
240
|
expect(results.every((result) => result.action === 'unchanged' || result.action === 'skipped')).toBe(true);
|
|
182
241
|
expect(readFileSync(join(root, 'tooling/devenv'), 'utf8')).toBe(first.read('tooling/devenv', 'utf8') ?? '');
|