From 6dd93d17fd04df3bcc2984682a2aa6b383c9a445 Mon Sep 17 00:00:00 2001 From: Kamil Sobol Date: Thu, 19 Dec 2024 12:24:58 -0800 Subject: [PATCH] Test on Node 22. (#2347) * Node 22 * this * this * this * this * this * Revert "this" This reverts commit 476231dcb0ff2374dcee49d05718feece5fbde76. * Revert "this" This reverts commit b909e6a78a3766f6900de86f9234523dddd3e04e. * Revert "this" This reverts commit c68ed7c67f0a672a3c638614f4e3b1d67ffce0fa. * Revert "this" This reverts commit 1206b3777f75f29a672ad0569af303a1134d091d. * Revert "this" This reverts commit 486b8b1802a0482e743ae2938b04bf82f0a60c12. * try this * try this * boop * boop * try this --- .github/workflows/health_checks.yml | 12 ++++++++---- package.json | 2 +- scripts/get_unit_test_dir_list.ts | 1 + scripts/run_tests.ts | 21 +++++++++++++++++++++ 4 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 scripts/run_tests.ts diff --git a/.github/workflows/health_checks.yml b/.github/workflows/health_checks.yml index 22bc67ab86..f734026747 100644 --- a/.github/workflows/health_checks.yml +++ b/.github/workflows/health_checks.yml @@ -47,7 +47,7 @@ on: description: 'Node versions list (as JSON array).' required: false type: string - default: '["18", "20"]' + default: '["18", "20", "22"]' workflow_call: inputs: desired-cdk-version: @@ -78,7 +78,7 @@ on: description: 'Node versions list (as JSON array).' required: false type: string - default: '["18", "20"]' + default: '["18", "20", "22"]' env: # Health checks can run on un-released code. Often work in progress. @@ -121,7 +121,7 @@ jobs: echo "os=$os" >> "$GITHUB_OUTPUT" echo "os_for_e2e=$os_for_e2e" >> "$GITHUB_OUTPUT" if [ -z "${{ inputs.node }}" ]; then - echo 'node=["18", "20"]' >> "$GITHUB_OUTPUT" + echo 'node=["18", "20", "22"]' >> "$GITHUB_OUTPUT" else echo 'node=${{ inputs.node }}' >> "$GITHUB_OUTPUT" fi @@ -512,6 +512,10 @@ jobs: node-version: 20 - os: windows-latest node-version: 20 + - os: macos-14 + node-version: 22 + - os: windows-latest + node-version: 22 runs-on: ${{ matrix.os }} timeout-minutes: ${{ matrix.os == 'windows-latest' && 35 || 25 }} needs: @@ -538,7 +542,7 @@ jobs: matrix: os: ${{ fromJSON(needs.resolve_inputs.outputs.os) }} pkg-manager: [npm, yarn-classic, yarn-modern, pnpm] - node-version: ['20'] + node-version: ['22'] env: PACKAGE_MANAGER: ${{ matrix.pkg-manager }} runs-on: ${{ matrix.os }} diff --git a/package.json b/package.json index 56f0ad37f5..064c496cf6 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "test": "npm run test:dir $(tsx scripts/get_unit_test_dir_list.ts)", "test:coverage:generate": "NODE_V8_COVERAGE=coverage/ npm run test", "test:coverage:threshold": "c8 npm run test", - "test:dir": "tsx --test --test-reporter spec", + "test:dir": "tsx scripts/run_tests.ts", "test:scripts": "npm run test:dir $(glob --cwd=scripts --absolute **/*.test.ts)", "update:api": "tsx scripts/concurrent_workspace_script.ts update:api --if-present", "update:tsconfig-refs": "tsx scripts/update_tsconfig_refs.ts", diff --git a/scripts/get_unit_test_dir_list.ts b/scripts/get_unit_test_dir_list.ts index 50b4def5f1..0c962d47d1 100644 --- a/scripts/get_unit_test_dir_list.ts +++ b/scripts/get_unit_test_dir_list.ts @@ -6,4 +6,5 @@ result = result.filter((result) => !result.includes('integration-tests')); result.push( path.join('packages', 'integration-tests', 'lib', 'test-in-memory') ); + console.log(result.join(' ')); diff --git a/scripts/run_tests.ts b/scripts/run_tests.ts new file mode 100644 index 0000000000..47f0c02fdf --- /dev/null +++ b/scripts/run_tests.ts @@ -0,0 +1,21 @@ +import { execa } from 'execa'; +import fs from 'fs'; +import semver from 'semver'; + +let testPaths = process.argv.slice(2); + +const nodeVersion = semver.parse(process.versions.node); +if (nodeVersion && nodeVersion.major >= 21) { + // Starting from version 21. Node test runner's cli changed how inputs to test CLI work. + // See https://github.com/nodejs/node/issues/50219. + testPaths = testPaths.map((path) => { + if (fs.existsSync(path) && fs.statSync(path).isDirectory()) { + return `${path}/**/*.test.?(c|m)js`; + } + return path; + }); +} + +await execa('tsx', ['--test', '--test-reporter', 'spec'].concat(testPaths), { + stdio: 'inherit', +});