Skip to content

Commit 3eb9bde

Browse files
kmruizaddaleax
andauthored
feat!: upgrade support to node 22 and 24 (#63)
* chore: Upgrade support to node 22 and 24 We are also upgrading the minimum engine to 22, and the dependencies we use for CodeQL to 24, as it's going to be our baseline from now on. * chore: use devtools toolchain on linux and upgrade macos deps * chore: add brotli as a dependency when compiling the test * chore: Remove unsupported flags for r/o heaps According to a v8 commit, v8 removed the ability to build without shared r/o heaps. More info: https://chromium-review.googlesource.com/c/v8/v8/+/6038531 * chore: use 22 until we have 24 * chore: create parent node folder, necessary for the symlink * chore: upgrade node-gyp to the latest * chore: upgrade test template to node 24 and std=c++20 * chore: remove assert(CanUseCustomSnapshotPerIsolate) We only use one EmbedderSnapshotData and one Isolate, so we are not hitting the corner case of having isolates with different snapshots. * chore: forgot to remove the test skip * chore: unregister isolate *after* disposing isolate Refs: nodejs/node@9aa1afb Refs: nodejs/node@5d3e1b5 * feat!: remove support code for older Node.js versions * chore: add evergreen task for testing dchecks * chore: use ubuntu instead of amazon for dcheck runs * fixup: use fixed version of weak-napi * chore: upgrade to vs2022 to test * chore: upgrade host so it has msvc 2022 * chore: typo in the evergreen distro * chore(ci): use llvm from homebrew on evergreen macOS * chore: Use python3.11 in windows host * chore: make sure python 3.11 is used everywhere, also when compiling * chore: make sure that the hash is updated so it uses the proper python version * chore: also setup python and python3 env vars for node-gyp * chore: use NODE_GYP_FORCE_PYTHON * chore: use windows path and simplify * chore: normalise to spaces * chore: untabify, use spaces always * chore: setup VC environment and upgrade command args for vcbuild * chore: stub APPDATA env var * chore: adapt it to use CMD properly * chore: fix order of parameters * chore: we still need to projgen * chore: do not use $TEMP because files there can be deleted * chore: typo :( * chore: upgrade to node 24 (the LTS) and increase timeout The build in Windows is slower, so we increase the timeout to avoid issues related to slow compilation * chore: use the same base in all machines (22.17.0) * chore: setup windows tests also in GHA for faster feedback This also adds a baseline: if the tests without special setup work here, it should work also in evergreen hosts if properly configured. * chore: remove unused deps and remove setup of MSVC DevTools In theory vcbuild.bat should detect where the MSVC DevTools are located (using vswhere.exe) and setup them correctly. We are going to verify this behaviour. * chore: support all architecture flags * chore: increase timeout (default is 6h, builds can take more time) * chore: fix linter issues * chore: use DEBUG, as it's faster, and it's good enough for a safety check * chore: split each test in it's own job to avoid disk space issues * chore: we can't use cache: npm because we don't have a package-lock * chore: delete precompiled headers on windows and node24> Compiling with a snapshot requires compiling twice: a base image and the image with the snapshot embedded. In that situation, clang-cl complains that there are precompiled headers that changed between compilations and does not refresh them, but kills the compilation process with an error. Due to this, before attempting the second compilation, we will delete all pch files. * chore: Remove test, now the behaviour is tested by the compiler This test was written so we could speed up the feedback loop. * chore: use rimraf instead of custom code, it should be easier to maintain * chore: Generate the GHA workflow from a template Because we can keep adding more tests, maintaining the GHA workflow can become a bit cumbersome. This script generates the GHA file from a template, and adds all the test cases in a matrix. We do this because each test is expensive in time and disk space, so we do sometimes hit the GHA limit of 6h or the we fill the disk. * chore: Fix linter issues (spacing and unused deps) * chore: use -f instead of -g for the test runner It seems that -g expects a regular expression, and if the regular expression is invalid, mocha just fails with Error: null. Using -f, uses a substring comparison, which is what we need. * chore: Remove pch files from compilation artifacts in tmp directory * chore: Print the folder where we are deleting pchs from * chore: attempt to upgrade rimraf to latest version * chore: Use follow: true, so it follows symlinks and junctions * chore: resolve the realpath of nodeSourcePath before deleting pchs nodeSourcePath in Windows refers to a user directory that contains an alias. For example, something like C:\Users\RUNNER~1 (in GHA) while MSVC uses the full name like C:\Users\runneradmin. This can make rimraf not delete the pch files properly. By resolving first, we make sure that both paths are absolute and unambiguous. * chore: Remove all directories that can contain compilation outputs clang-cl does not properly handle pch refresh when a source header changed after the pch file was generated * chore: try to delete the whole out directory for a fresh compilation * chore: Simplify naming, we now wipe out the whole out directory This will force Node.js to compile from scratch. It's slower, but it will only happens on Windows and it will be safer and more reliable there. * chore: ensure that any output directory is cleaned up before compiling Right now it's failing on the first compilation of the second test, as we are not doing any clean up. To ensure that we are in a consistent state in Windows, before attempting compiling, we will make sure we don't have any old compilation artifact. This might slow down Windows compilations as they can't reuse cached files. --------- Co-authored-by: Anna Henningsen <anna@addaleax.net>
1 parent 3048581 commit 3eb9bde

File tree

14 files changed

+354
-557
lines changed

14 files changed

+354
-557
lines changed

.evergreen.yml

Lines changed: 101 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ functions:
1414
set -e
1515
set -x
1616
17-
export NODE_VERSION=20.13.0
18-
bash .evergreen/install-node.sh
17+
if [ "$OS" == "Windows_NT" ]; then
18+
export NODE_GYP_FORCE_PYTHON="C:\python\Python311\python.exe"
19+
export PATH="/cygdrive/c/python/Python311/Scripts:/cygdrive/c/python/Python311:$PATH"
20+
fi
21+
22+
export NODE_VERSION=22.17.0
23+
. .evergreen/install-node.sh
1924
install:
2025
- command: shell.exec
2126
params:
@@ -25,17 +30,29 @@ functions:
2530
set -e
2631
set -x
2732
33+
if [ "$OS" == "Windows_NT" ]; then
34+
export NODE_GYP_FORCE_PYTHON="C:\python\Python311\python.exe"
35+
export PATH="/cygdrive/c/python/Python311/Scripts:/cygdrive/c/python/Python311:$PATH"
36+
fi
37+
2838
. .evergreen/use-node.sh
2939
npm install
3040
check:
3141
- command: shell.exec
3242
params:
3343
working_dir: src
3444
shell: bash
45+
env:
46+
NODE_VERSION: ${node_version}
3547
script: |
3648
set -e
3749
set -x
3850
51+
if [ "$OS" == "Windows_NT" ]; then
52+
export NODE_GYP_FORCE_PYTHON="C:\python\Python311\python.exe"
53+
export PATH="/cygdrive/c/python/Python311/Scripts:/cygdrive/c/python/Python311:$PATH"
54+
fi
55+
3956
. .evergreen/use-node.sh
4057
npm run build
4158
npm run lint
@@ -51,10 +68,29 @@ functions:
5168
AZURE_TEST_CONFIG: ${azure_test_config}
5269
AZURE_TEST_CREDENTIALS: ${azure_test_credentials}
5370
DISTRO_ID: ${distro_id}
71+
BOXEDNODE_DCHECKS_ENABLED: ${dchecks_enabled}
5472
script: |
5573
set -e
5674
set -x
5775
76+
if [ `uname` == "Darwin" ]; then
77+
# the CI macOS machines have an outdated Clang that
78+
# cannot build recent Node.js versions, so we use
79+
# the LLVM version installed via Homebrew
80+
# (both on arm64 and x64)
81+
82+
LLVM_PREFIX="$(brew --prefix llvm)"
83+
export PATH="$LLVM_PREFIX/bin:$PATH"
84+
export CC="$LLVM_PREFIX/bin/clang"
85+
export CXX="$LLVM_PREFIX/bin/clang++"
86+
export LDFLAGS="-L$LLVM_PREFIX/lib -L$LLVM_PREFIX/lib/c++ -L$LLVM_PREFIX/lib/unwind"
87+
export CPPFLAGS="-I$LLVM_PREFIX/include"
88+
export CMAKE_PREFIX_PATH="$LLVM_PREFIX"
89+
90+
$CC --version
91+
$CXX --version
92+
fi
93+
5894
rm -rf /tmp/m && mkdir -pv /tmp/m # Node.js compilation can fail on long path prefixes
5995
trap "rm -rf /tmp/m" EXIT
6096
export TMP=/tmp/m
@@ -64,49 +100,81 @@ functions:
64100
# able to compile OpenSSL with assembly support,
65101
# so we revert back to the slower version.
66102
if [ "$OS" == "Windows_NT" ]; then
67-
export PATH="/cygdrive/c/python/Python310/Scripts:/cygdrive/c/python/Python310:/cygdrive/c/Python310/Scripts:/cygdrive/c/Python310:$PATH"
103+
export NODE_GYP_FORCE_PYTHON="C:\python\Python311\python.exe"
104+
export PATH="/cygdrive/c/python/Python311/Scripts:/cygdrive/c/python/Python311:$PATH"
68105
export BOXEDNODE_CONFIGURE_ARGS='openssl-no-asm'
69106
elif uname -a | grep -q 'Darwin.*x86_64'; then
70107
export BOXEDNODE_CONFIGURE_ARGS='--openssl-no-asm'
71108
fi
72109
73110
. .evergreen/use-node.sh
74-
npm run build
75-
TEST_NODE_VERSION="$TEST_NODE_VERSION" npm run test-ci
111+
export TEST_NODE_VERSION="$TEST_NODE_VERSION"
112+
if [ "$OS" == "Windows_NT" ]; then
113+
# The CI machines we have for Windows don't have a working
114+
# installation of VS2022, (vswhere.exe can't find the correct path)
115+
# So we run the scripts to set up the environment manually, and they
116+
# only work properly in CMD
117+
WIN_PATH=$(cygpath -aw .evergreen/test-in-vcdev-env.bat)
118+
cmd.exe /c "$WIN_PATH"
119+
else
120+
npm run build
121+
npm run test-ci
122+
fi
76123
77124
tasks:
78-
- name: test_n14
125+
- name: test_n20
79126
commands:
80127
- func: checkout
81128
- func: install_node
82129
- func: install
83130
- func: test
84131
vars:
85-
node_version: "14.21.3"
86-
- name: test_n16
132+
node_version: "20.19.5"
133+
- name: test_n22
87134
commands:
88135
- func: checkout
89136
- func: install_node
90137
- func: install
91138
- func: test
92139
vars:
93-
node_version: "16.20.1"
94-
- name: test_n18
140+
node_version: "22.21.0"
141+
- name: test_n24
95142
commands:
96143
- func: checkout
97144
- func: install_node
98145
- func: install
99146
- func: test
100147
vars:
101-
node_version: "18.17.0"
102-
- name: test_n20
148+
node_version: "24.10.0"
149+
150+
- name: test_n20_dchecks
151+
commands:
152+
- func: checkout
153+
- func: install_node
154+
- func: install
155+
- func: test
156+
vars:
157+
node_version: "20.19.5"
158+
dchecks_enabled: 1
159+
- name: test_n22_dchecks
103160
commands:
104161
- func: checkout
105162
- func: install_node
106163
- func: install
107164
- func: test
108165
vars:
109-
node_version: "20.13.0"
166+
node_version: "22.21.0"
167+
dchecks_enabled: 1
168+
- name: test_n24_dchecks
169+
commands:
170+
- func: checkout
171+
- func: install_node
172+
- func: install
173+
- func: test
174+
vars:
175+
node_version: "24.10.0"
176+
dchecks_enabled: 1
177+
110178
- name: check
111179
commands:
112180
- func: checkout
@@ -119,32 +187,35 @@ buildvariants:
119187
display_name: 'Ubuntu 20.04 x64'
120188
run_on: ubuntu2004-large
121189
tasks:
122-
- test_n14
123-
- test_n16
124-
- test_n18
125190
- test_n20
191+
- test_n22
192+
- test_n24
126193
- check
194+
- name: ubuntu_arm64_dchecks
195+
display_name: 'Ubuntu 24.04 arm64 (Node.js/V8 DCHECKs)'
196+
run_on: ubuntu2404-arm64-latest-xlarge
197+
tasks:
198+
- test_n20_dchecks
199+
- test_n22_dchecks
200+
- test_n24_dchecks
127201
- name: macos_x64_test
128-
display_name: 'macOS 11.00 x64'
129-
run_on: macos-1100
202+
display_name: 'macOS 14.00 x64'
203+
run_on: macos-14
130204
tasks:
131-
- test_n14
132-
- test_n16
133-
- test_n18
134205
- test_n20
206+
- test_n22
207+
- test_n24
135208
- name: macos_arm64_test
136-
display_name: 'macOS 11.00 arm64'
137-
run_on: macos-1100-arm64
209+
display_name: 'macOS 14.00 arm64'
210+
run_on: macos-14-arm64
138211
tasks:
139-
- test_n14
140-
- test_n16
141-
- test_n18
142212
- test_n20
213+
- test_n22
214+
- test_n24
143215
- name: windows_x64_test
144216
display_name: 'Windows x64'
145-
run_on: windows-vsCurrent-xlarge
217+
run_on: windows-2022-xlarge
146218
tasks:
147-
- test_n14
148-
- test_n16
149-
- test_n18
150219
- test_n20
220+
- test_n22
221+
- test_n24

.evergreen/install-node.sh

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
set -e
44
set -x
55

6+
# so we use the devtools binaries first (for gcc/g++)
7+
export PATH="/opt/devtools/bin:$PATH"
8+
69
export BASEDIR="$PWD"
710
mkdir -p .deps
811
cd .deps
912

10-
NVM_URL="https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh"
13+
NVM_URL="https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh"
1114

1215
# this needs to be explicitly exported for the nvm install below
1316
export NVM_DIR="$PWD/nvm"
@@ -21,12 +24,18 @@ if [[ "$OS" == "Windows_NT" ]]; then
2124
mv -v node-v$NODE_VERSION-win-x64/* node/bin
2225
chmod a+x node/bin/*
2326
export PATH="$PWD/node/bin:$PATH"
24-
# install Node.js on Linux/MacOS
2527
else
26-
curl -o- $NVM_URL | bash
27-
set +x
28-
[ -s "${NVM_DIR}/nvm.sh" ] && source "${NVM_DIR}/nvm.sh"
29-
nvm install --no-progress "$NODE_VERSION"
28+
if [ "$(uname -s)" == "Darwin" ] ; then # install Node.js on MacOS
29+
curl -o- $NVM_URL | bash
30+
set +x
31+
[ -s "${NVM_DIR}/nvm.sh" ] && source "${NVM_DIR}/nvm.sh"
32+
nvm install --no-progress "$NODE_VERSION"
33+
else # Linux already has its own toolchain in evergreen
34+
mkdir -p node
35+
NODE_MAJOR=$(echo $NODE_VERSION | awk -F . '{print $1}')
36+
ln -s "/opt/devtools/node$NODE_MAJOR/bin/" "$PWD/node/bin"
37+
export PATH="$PWD/node/bin:$PATH"
38+
fi
3039
fi
3140

3241
which node && node -v || echo "node not found, PATH=$PATH"

.evergreen/test-in-vcdev-env.bat

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CALL "C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvars64.bat"
2+
REM APPDATA is empty in CMD, and npm requires it to be a valid path
3+
SET APPDATA="npm-cache"
4+
5+
CALL npm run build
6+
CALL npm run test-ci

.evergreen/use-node.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
if [[ "$OS" == "Windows_NT" ]]; then
2-
export PATH="$PWD/.deps/node/bin:$PATH"
2+
export APPDATA="npm-cache"
3+
export PATH="$PWD/.deps/node/bin:$PATH"
34
else
4-
export NVM_DIR="$PWD/.deps/nvm"
5-
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh"
5+
# so we use the devtools binaries first (for gcc/g++)
6+
export PATH="/opt/devtools/bin:$PATH"
7+
8+
if [ "$(uname -s)" == "Darwin" ] ; then # in OSX use nvm
9+
export NVM_DIR="$PWD/.deps/nvm"
10+
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh"
11+
else # In Linux, use .deps/node/bin because it was set up with symlink to an existing node in the toolchain
12+
export PATH="$PWD/.deps/node/bin:$PATH"
13+
fi
614
fi
715

816
echo "updated PATH=$PATH"

.github/workflows/codeql.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ jobs:
4242
- name: Checkout repository
4343
uses: actions/checkout@v3
4444

45-
- name: Use Node.js v18.x
45+
- name: Use Node.js v24.x
4646
if: matrix.language == 'cpp'
47-
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
47+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
4848
with:
49-
node-version: 18.x
49+
node-version: 24.x
5050

51-
- name: Use Node.js v18.x
51+
- name: Use Node.js v24.x
5252
if: matrix.language == 'cpp'
5353
run: |
5454
npm install

.github/workflows/nodejs.yml

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# This is a generated file. Please change .github/workflows/nodejs.yml.in
2+
# and run the following command to update the GHA Workflow
3+
# $> npm run update-gha-workflow
4+
# --------------------
15
on: [pull_request]
26

37
name: CI
@@ -13,19 +17,55 @@ jobs:
1317
fail-fast: false
1418
matrix:
1519
os: [ubuntu-latest]
16-
node-version: [14.x, 16.x, 18.x, 20.x]
20+
node-version: [20.x, 22.x, 24.x]
21+
test-to-run: ["works in a simple case","works with a Nan addon","works with a N-API addon","passes through env vars and runs the pre-compile hook","works with code caching support","works with snapshot support (compressBlobs = "]
1722
runs-on: ${{ matrix.os }}
1823
steps:
19-
- uses: actions/checkout@v2
24+
- uses: actions/checkout@v5
2025
- name: Use Node.js ${{ matrix.node-version }}
21-
uses: actions/setup-node@v2
26+
uses: actions/setup-node@v6
2227
with:
2328
check-latest: true
2429
node-version: ${{ matrix.node-version }}
25-
- name: Install npm@8.x
26-
if: ${{ matrix.node-version == '14.x' }}
27-
run: npm install -g npm@8.x
2830
- name: Install Dependencies
2931
run: npm install
32+
- name: Lint
33+
run: npm run lint
34+
- name: Build
35+
run: npm run build
3036
- name: Test
31-
run: npm test
37+
run: npm run test-ci -- -f "${{ matrix.test-to-run }}"
38+
39+
test-windows:
40+
name: Windows tests
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
os: [windows-latest]
45+
node-version: [20.x, 22.x, 24.x]
46+
vs-version: ['17'] # 17 => VS2022
47+
test-to-run: ["works in a simple case","works with a Nan addon","works with a N-API addon","passes through env vars and runs the pre-compile hook","works with code caching support","works with snapshot support (compressBlobs = "]
48+
runs-on: ${{ matrix.os }}
49+
steps:
50+
- uses: actions/checkout@v5
51+
- name: Use Node.js ${{ matrix.node-version }}
52+
uses: actions/setup-node@v6
53+
with:
54+
check-latest: true
55+
node-version: ${{ matrix.node-version }}
56+
- uses: microsoft/setup-msbuild@v2
57+
name: Setup MSBuild
58+
with:
59+
vs-version: ${{ matrix.vs-version }}
60+
msbuild-architecture: x64
61+
- name: Install Dependencies
62+
run: npm install
63+
- name: Lint
64+
run: npm run lint
65+
- name: Build
66+
run: npm run build
67+
- name: Test
68+
run: npm run test-ci -- -f "${{ matrix.test-to-run }}"
69+
env:
70+
BOXEDNODE_MAKE_ARGS: "debug"
71+

0 commit comments

Comments
 (0)