Skip to content

Commit 1a49d91

Browse files
authored
Develop and test with Node.js 26 (#9059)
The Temporal bindings (#9044) need the `Temporal` global, which Node.js 22 lacks and Node.js 26 provides, so their tests and doc examples can run in CI only on Node.js 26. `.nvmrc` now names 26. The build, coverage and publish jobs read it through the setup-node action and pkg-pr-new reads it directly; the changelog check now reads it too instead of naming 22. The dev container and CONTRIBUTING.md move to 26 as well. The installation tests keep Node.js 22, the oldest version the packages support (`engines` `>=22`). build-compiler no longer runs the stdlib tests on 22, so both installation jobs now run them there. They copy the compiled tests in `tests/tests/src/stdlib` next to the installed packages, install `@babel/code-frame`, which `Test.mjs` imports, at the version `tests/tests` declares, and run `Stdlib_TestSuite.mjs` and `Stdlib_TempTests.mjs` against the runtime from pkg.pr.new. Node.js 25 stopped bundling corepack. The dev container's Node feature enables corepack where Node.js bundles it and installs yarn with npm otherwise, so `postCreate.sh` no longer runs `corepack enable`, which would fail on 26. Review: Do any tests behave differently on 26? The runtime doc examples for `RegExp.escape` and `DataView.getFloat16`/`setFloat16`, which `DocTest.res` skips below Node.js 24, now run in CI. They pass on 26.12.1, as does the rest of `make test`. Review: Do the copied stdlib tests need anything else from the repository? No. Apart from `@babel/code-frame` they import only each other, `./Test.mjs`, `@rescript/runtime/lib/es6` and Node.js built-ins. `Test.mjs` reads the `.res` source next to it only to print a failure, and the copy includes the sources. Review: Where do tests of APIs that Node.js 22 lacks go? Not into `Stdlib_TestSuite` or `Stdlib_TempTests`, which now also run on 22. Comments on the workflow step and in `Stdlib_TestSuite.res` say so. The Temporal tests will need an entry point that only `scripts/test.js` runs. Review: Does the new step work on Windows? It copies with the same Git Bash `cp` as the existing `installation_test` copy, and the tests find the runtime through `node_modules`. `Test.mjs` takes its directory from the pathname of `import.meta.url`, which starts with `/C:/` on Windows, so a failing assertion there reports a missing `.res` file instead of a code frame. The step still fails, just as the stdlib tests in the Windows build-compiler job do today. Review: Does anything else rely on corepack? No. Only `postCreate.sh` ran it; the workflows never do. Signed-off-by: mununki <woonki.moon@gmail.com>
1 parent d19dccd commit 1a49d91

8 files changed

Lines changed: 43 additions & 7 deletions

File tree

‎.devcontainer/devcontainer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"version": "latest"
1515
},
1616
"ghcr.io/devcontainers/features/node:1": {
17-
"version": "22",
17+
"version": "26",
1818
"installYarnUsingApt": false
1919
}
2020
},

‎.devcontainer/postCreate.sh‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
# Install dev dependencies from OPAM
44
opam install . --with-test --with-dev-setup -y
55

6-
corepack enable
6+
# The Node feature provides yarn: it enables corepack where Node still bundles
7+
# it (Node 24 and older) and installs yarn with npm otherwise.
78
printf "\n" | yarn

‎.github/workflows/changelog.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- uses: actions/setup-node@v7
2929
with:
3030
cache: yarn
31-
node-version: 22
31+
node-version-file: .nvmrc
3232
# The scripts import semver. Package builds aren't needed for them.
3333
- run: yarn install --immutable --mode=skip-build
3434
- run: node --test scripts/changelog.test.js scripts/magicNumbers.test.js

‎.github/workflows/ci.yml‎

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,14 +587,19 @@ jobs:
587587
fi
588588
echo "path=$dir" >> "$GITHUB_OUTPUT"
589589
cp -r tests/package_tests/installation_test/* "$dir"
590+
# The compiled stdlib tests run against the installed runtime. Their
591+
# Test.mjs imports @babel/code-frame, which tests/tests depends on.
592+
cp -r tests/tests/src/stdlib "$dir/stdlib"
593+
echo "code-frame=$(node -p 'require("./tests/tests/package.json").dependencies["@babel/code-frame"]')" >> "$GITHUB_OUTPUT"
590594
591595
- name: Install ReScript package
592596
run: |
593597
COMMIT_SHA="${{ needs.pkg-pr-new.outputs.commit_sha }}"
594598
npm i --no-audit \
595599
"https://pkg.pr.new/rescript-lang/rescript@${COMMIT_SHA}" \
596600
"https://pkg.pr.new/rescript-lang/rescript/@rescript/runtime@${COMMIT_SHA}" \
597-
"https://pkg.pr.new/rescript-lang/rescript/@rescript/belt@${COMMIT_SHA}"
601+
"https://pkg.pr.new/rescript-lang/rescript/@rescript/belt@${COMMIT_SHA}" \
602+
"@babel/code-frame@${{ steps.tmp-dir.outputs.code-frame }}"
598603
shell: bash
599604
working-directory: ${{ steps.tmp-dir.outputs.path }}
600605

@@ -618,6 +623,16 @@ jobs:
618623
shell: bash
619624
working-directory: ${{ steps.tmp-dir.outputs.path }}
620625

626+
# build-compiler runs the stdlib tests on the Node.js version in .nvmrc,
627+
# this job on the oldest supported one, so tests of APIs missing there
628+
# must stay out of Stdlib_TestSuite and Stdlib_TempTests.
629+
- name: Run stdlib tests
630+
run: |
631+
node stdlib/Stdlib_TestSuite.mjs
632+
node stdlib/Stdlib_TempTests.mjs
633+
shell: bash
634+
working-directory: ${{ steps.tmp-dir.outputs.path }}
635+
621636
test-installation-pnpm:
622637
needs:
623638
- pkg-pr-new
@@ -657,6 +672,10 @@ jobs:
657672
fi
658673
echo "path=$dir" >> "$GITHUB_OUTPUT"
659674
cp -r tests/package_tests/installation_test/* "$dir"
675+
# The compiled stdlib tests run against the installed runtime. Their
676+
# Test.mjs imports @babel/code-frame, which tests/tests depends on.
677+
cp -r tests/tests/src/stdlib "$dir/stdlib"
678+
echo "code-frame=$(node -p 'require("./tests/tests/package.json").dependencies["@babel/code-frame"]')" >> "$GITHUB_OUTPUT"
660679
661680
- name: Install ReScript package
662681
run: |
@@ -665,7 +684,8 @@ jobs:
665684
pnpm --config.block-exotic-subdeps=false i \
666685
"https://pkg.pr.new/rescript-lang/rescript@${COMMIT_SHA}" \
667686
"https://pkg.pr.new/rescript-lang/rescript/@rescript/runtime@${COMMIT_SHA}" \
668-
"https://pkg.pr.new/rescript-lang/rescript/@rescript/belt@${COMMIT_SHA}"
687+
"https://pkg.pr.new/rescript-lang/rescript/@rescript/belt@${COMMIT_SHA}" \
688+
"@babel/code-frame@${{ steps.tmp-dir.outputs.code-frame }}"
669689
shell: bash
670690
working-directory: ${{ steps.tmp-dir.outputs.path }}
671691

@@ -684,6 +704,16 @@ jobs:
684704
shell: bash
685705
working-directory: ${{ steps.tmp-dir.outputs.path }}
686706

707+
# build-compiler runs the stdlib tests on the Node.js version in .nvmrc,
708+
# this job on the oldest supported one, so tests of APIs missing there
709+
# must stay out of Stdlib_TestSuite and Stdlib_TempTests.
710+
- name: Run stdlib tests
711+
run: |
712+
node stdlib/Stdlib_TestSuite.mjs
713+
node stdlib/Stdlib_TempTests.mjs
714+
shell: bash
715+
working-directory: ${{ steps.tmp-dir.outputs.path }}
716+
687717
# The single CI check that the master ruleset requires. Matrix job names
688718
# contain runner labels, so requiring this job instead keeps the ruleset
689719
# unchanged when runners or jobs change. It runs even when a needed job fails

‎.nvmrc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
22
1+
26

‎CONTRIBUTING.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ algorithm and representation invariants belong beside their implementation.
3232

3333
> Most of our contributors are working on Apple machines, so all our instructions are currently macOS / Linux centric. Contributions for Windows development welcome!
3434
35-
- [Node.js](https://nodejs.org/) v22.x or newer
35+
- [Node.js](https://nodejs.org/) v26.x or newer (the version in `.nvmrc`)
3636
- [Yarn CLI](https://yarnpkg.com/getting-started/install) (can be installed with `corepack`, Homebrew, etc)
3737
- C compiler toolchain (usually installed with `xcode` on Mac)
3838
- 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`)

‎changes/node-26-dev.internal.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.

‎tests/tests/src/stdlib/Stdlib_TestSuite.res‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// The installation tests in .github/workflows/ci.yml also run this suite on
2+
// the oldest supported Node.js version, 22. Tests of APIs that Node.js 22
3+
// lacks belong in a separate entry point that only scripts/test.js runs.
4+
15
include Stdlib_TestTests
26
include Stdlib_PromiseTest
37
include Stdlib_ErrorTests

0 commit comments

Comments
 (0)