diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b7af5fb853..8132a68eac 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -14,7 +14,7 @@ "version": "latest" }, "ghcr.io/devcontainers/features/node:1": { - "version": "22", + "version": "26", "installYarnUsingApt": false } }, diff --git a/.devcontainer/postCreate.sh b/.devcontainer/postCreate.sh index 7ac369d71f..e19e78154f 100755 --- a/.devcontainer/postCreate.sh +++ b/.devcontainer/postCreate.sh @@ -3,5 +3,6 @@ # Install dev dependencies from OPAM opam install . --with-test --with-dev-setup -y -corepack enable +# The Node feature provides yarn: it enables corepack where Node still bundles +# it (Node 24 and older) and installs yarn with npm otherwise. printf "\n" | yarn diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 3795eee28f..23f4b9c35b 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -28,7 +28,7 @@ jobs: - uses: actions/setup-node@v7 with: cache: yarn - node-version: 22 + node-version-file: .nvmrc # The scripts import semver. Package builds aren't needed for them. - run: yarn install --immutable --mode=skip-build - run: node --test scripts/changelog.test.js scripts/magicNumbers.test.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ed0c281ef..75cac6dedc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -587,6 +587,10 @@ jobs: fi echo "path=$dir" >> "$GITHUB_OUTPUT" cp -r tests/package_tests/installation_test/* "$dir" + # The compiled stdlib tests run against the installed runtime. Their + # Test.mjs imports @babel/code-frame, which tests/tests depends on. + cp -r tests/tests/src/stdlib "$dir/stdlib" + echo "code-frame=$(node -p 'require("./tests/tests/package.json").dependencies["@babel/code-frame"]')" >> "$GITHUB_OUTPUT" - name: Install ReScript package run: | @@ -594,7 +598,8 @@ jobs: npm i --no-audit \ "https://pkg.pr.new/rescript-lang/rescript@${COMMIT_SHA}" \ "https://pkg.pr.new/rescript-lang/rescript/@rescript/runtime@${COMMIT_SHA}" \ - "https://pkg.pr.new/rescript-lang/rescript/@rescript/belt@${COMMIT_SHA}" + "https://pkg.pr.new/rescript-lang/rescript/@rescript/belt@${COMMIT_SHA}" \ + "@babel/code-frame@${{ steps.tmp-dir.outputs.code-frame }}" shell: bash working-directory: ${{ steps.tmp-dir.outputs.path }} @@ -618,6 +623,16 @@ jobs: shell: bash working-directory: ${{ steps.tmp-dir.outputs.path }} + # build-compiler runs the stdlib tests on the Node.js version in .nvmrc, + # this job on the oldest supported one, so tests of APIs missing there + # must stay out of Stdlib_TestSuite and Stdlib_TempTests. + - name: Run stdlib tests + run: | + node stdlib/Stdlib_TestSuite.mjs + node stdlib/Stdlib_TempTests.mjs + shell: bash + working-directory: ${{ steps.tmp-dir.outputs.path }} + test-installation-pnpm: needs: - pkg-pr-new @@ -657,6 +672,10 @@ jobs: fi echo "path=$dir" >> "$GITHUB_OUTPUT" cp -r tests/package_tests/installation_test/* "$dir" + # The compiled stdlib tests run against the installed runtime. Their + # Test.mjs imports @babel/code-frame, which tests/tests depends on. + cp -r tests/tests/src/stdlib "$dir/stdlib" + echo "code-frame=$(node -p 'require("./tests/tests/package.json").dependencies["@babel/code-frame"]')" >> "$GITHUB_OUTPUT" - name: Install ReScript package run: | @@ -665,7 +684,8 @@ jobs: pnpm --config.block-exotic-subdeps=false i \ "https://pkg.pr.new/rescript-lang/rescript@${COMMIT_SHA}" \ "https://pkg.pr.new/rescript-lang/rescript/@rescript/runtime@${COMMIT_SHA}" \ - "https://pkg.pr.new/rescript-lang/rescript/@rescript/belt@${COMMIT_SHA}" + "https://pkg.pr.new/rescript-lang/rescript/@rescript/belt@${COMMIT_SHA}" \ + "@babel/code-frame@${{ steps.tmp-dir.outputs.code-frame }}" shell: bash working-directory: ${{ steps.tmp-dir.outputs.path }} @@ -684,6 +704,16 @@ jobs: shell: bash working-directory: ${{ steps.tmp-dir.outputs.path }} + # build-compiler runs the stdlib tests on the Node.js version in .nvmrc, + # this job on the oldest supported one, so tests of APIs missing there + # must stay out of Stdlib_TestSuite and Stdlib_TempTests. + - name: Run stdlib tests + run: | + node stdlib/Stdlib_TestSuite.mjs + node stdlib/Stdlib_TempTests.mjs + shell: bash + working-directory: ${{ steps.tmp-dir.outputs.path }} + # The single CI check that the master ruleset requires. Matrix job names # contain runner labels, so requiring this job instead keeps the ruleset # unchanged when runners or jobs change. It runs even when a needed job fails diff --git a/.nvmrc b/.nvmrc index 2bd5a0a98a..6f4247a625 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -22 +26 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0f23e285e0..a9d8eaf89a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,7 +32,7 @@ algorithm and representation invariants belong beside their implementation. > Most of our contributors are working on Apple machines, so all our instructions are currently macOS / Linux centric. Contributions for Windows development welcome! -- [Node.js](https://nodejs.org/) v22.x or newer +- [Node.js](https://nodejs.org/) v26.x or newer (the version in `.nvmrc`) - [Yarn CLI](https://yarnpkg.com/getting-started/install) (can be installed with `corepack`, Homebrew, etc) - C compiler toolchain (usually installed with `xcode` on Mac) - Rust toolchain (required to build rewatch; follow the instructions at https://www.rust-lang.org/tools/install and install the version listed as `rust-version` in `rewatch/Cargo.toml`) diff --git a/changes/node-26-dev.internal.md b/changes/node-26-dev.internal.md new file mode 100644 index 0000000000..59aca83c9b --- /dev/null +++ b/changes/node-26-dev.internal.md @@ -0,0 +1 @@ +- Develop and test with Node.js 26, and run the stdlib tests in the installation tests on Node.js 22, the oldest supported version. diff --git a/tests/tests/src/stdlib/Stdlib_TestSuite.res b/tests/tests/src/stdlib/Stdlib_TestSuite.res index e39543615a..ae074330a4 100644 --- a/tests/tests/src/stdlib/Stdlib_TestSuite.res +++ b/tests/tests/src/stdlib/Stdlib_TestSuite.res @@ -1,3 +1,7 @@ +// The installation tests in .github/workflows/ci.yml also run this suite on +// the oldest supported Node.js version, 22. Tests of APIs that Node.js 22 +// lacks belong in a separate entry point that only scripts/test.js runs. + include Stdlib_TestTests include Stdlib_PromiseTest include Stdlib_ErrorTests