diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f5f05d84..8559ff40 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -62,18 +62,12 @@ jobs: 'netlify/framework-adapters' }} run: echo "SKIP_LIVE_TESTS=true" >> "$GITHUB_ENV" - name: Tests - # angular-runtime requires Node 22+, so it's excluded on the Node 20 job - if: ${{ matrix.node-version != '20.19.0' }} + # A workspace that needs a newer Node than this matrix entry skips itself, so there is + # no list of workspaces to keep in sync here. See angular-runtime's + # `tools/skip-unsupported-node.js`. run: npm run test --workspaces=true env: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - - name: Tests (excludes angular-runtime, which requires Node 22+) - if: ${{ matrix.node-version == '20.19.0' }} - run: >- - npm run test --workspace=packages/nuxt-module --workspace=packages/vite-plugin - --workspace=packages/vite-plugin-tanstack-start - env: - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - name: Warn if live tests were skipped if: ${{ env.SKIP_LIVE_TESTS == 'true' }} run: | diff --git a/packages/angular-runtime/package.json b/packages/angular-runtime/package.json index fe13e54c..5b10a6f6 100644 --- a/packages/angular-runtime/package.json +++ b/packages/angular-runtime/package.json @@ -57,9 +57,9 @@ "pretest:fixtures:angular-22": "cd tests/fixtures/angular-22 && npm ci", "pretest:fixtures:nx-angular-19-common-engine": "cd tests/fixtures/nx-angular-19-common-engine && npm ci", "pretest:fixtures:nx-angular-19-app-engine": "cd tests/fixtures/nx-angular-19-app-engine && npm ci", - "pretest": "run-s pretest:*", + "pretest": "node tools/skip-unsupported-node.js || run-s pretest:*", "publint": "npx -y publint --strict", - "test": "node --test" + "test": "node tools/skip-unsupported-node.js || node --test" }, "repository": { "type": "git", diff --git a/packages/angular-runtime/tools/skip-unsupported-node.js b/packages/angular-runtime/tools/skip-unsupported-node.js new file mode 100644 index 00000000..5066e10e --- /dev/null +++ b/packages/angular-runtime/tools/skip-unsupported-node.js @@ -0,0 +1,25 @@ +import process from 'node:process' + +import { satisfies } from 'semver' + +import pkg from '../package.json' with { type: 'json' } + +/** + * Decides whether this package's tests should run on the Node version in use. + * + * Exits 0 when they should be *skipped* and non-zero when they should run, so a caller can + * short-circuit with `node tools/skip-unsupported-node.js || ` and still report + * success on a skip. The inverted-looking exit code is deliberate: `&&` would make a skip + * indistinguishable from a test failure, and `!` negation is not available in the cmd.exe + * shell npm uses on Windows. + * + * This package needs a newer Node than the rest of the monorepo, so it opts itself out of + * the older CI matrix entries here. That keeps the workflow free of a hand-maintained list + * of workspaces to run, which would silently go stale as packages are added or their + * supported Node ranges change. + */ +if (satisfies(process.version, pkg.engines.node)) { + process.exitCode = 1 +} else { + console.log(`Skipping tests: ${pkg.name} requires Node ${pkg.engines.node}, but ${process.version} is running.`) +}