Skip to content

Commit 3e809ed

Browse files
committed
tools: cache V8 on test-shared workflow
1 parent 7215ea4 commit 3e809ed

File tree

4 files changed

+39
-10
lines changed

4 files changed

+39
-10
lines changed

.github/workflows/test-shared.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,25 +182,19 @@ jobs:
182182
core.exportVariable('ACTIONS_CACHE_SERVICE_V2', 'on');
183183
core.exportVariable('ACTIONS_RESULTS_URL', process.env.ACTIONS_RESULTS_URL || '');
184184
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
185-
186-
- name: Load shell.nix
187-
if: github.event_name != 'workflow_dispatch'
188-
run: |
189-
mv "$TAR_DIR"/*.nix .
190-
mkdir tools
191-
mv "$TAR_DIR"/tools/nix tools/.
185+
core.exportVariable('NIX_SCCACHE', '(import <nixpkgs> {}).sccache');
192186
193187
- name: Build Node.js and run tests
194188
run: |
195189
nix-shell \
196-
-I nixpkgs=./tools/nix/pkgs.nix \
190+
-I "nixpkgs=$TAR_DIR/tools/nix/pkgs.nix" \
197191
--pure --keep TAR_DIR --keep FLAKY_TESTS \
198192
--keep SCCACHE_GHA_ENABLED --keep ACTIONS_CACHE_SERVICE_V2 --keep ACTIONS_RESULTS_URL --keep ACTIONS_RUNTIME_TOKEN \
199193
--arg loadJSBuiltinsDynamically false \
200-
--arg ccache '(import <nixpkgs> {}).sccache' \
194+
--arg ccache "${NIX_SCCACHE:-null}" \
201195
--arg devTools '[]' \
202196
--arg benchmarkTools '[]' \
203197
${{ endsWith(matrix.system, '-darwin') && '--arg withAmaro false --arg withLief false --arg withSQLite false --arg extraConfigFlags ''["--without-inspector" "--without-node-options"]'' \' || '\' }}
204198
--run '
205199
make -C "$TAR_DIR" run-ci -j4 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9 --skip-tests=$CI_SKIP_TESTS"
206-
'
200+
' "$TAR_DIR/shell.nix"

configure.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,13 @@
10901090
help='do not use V8 includes from the bundled deps folder. ' +
10911091
'(This mode is not officially supported for regular applications)')
10921092

1093+
parser.add_argument('--external-v8',
1094+
action='store',
1095+
dest='external_v8_path',
1096+
default=False,
1097+
help='Path to shared V8. ' +
1098+
'(This mode is not officially supported for regular applications)')
1099+
10931100
parser.add_argument('--verbose',
10941101
action='store_true',
10951102
dest='verbose',
@@ -2068,6 +2075,11 @@ def configure_v8(o, configs):
20682075
raise Exception('--enable-d8 is incompatible with --without-bundled-v8.')
20692076
if options.without_bundled_v8 and options.enable_v8windbg:
20702077
raise Exception('--enable-v8windbg is incompatible with --without-bundled-v8.')
2078+
if options.external_v8_path:
2079+
if not options.without_bundled_v8:
2080+
raise Exception('--external-v8 requires --without-bundled-v8.')
2081+
output['libraries'] += [f"-L{options.external_v8_path}/lib", '-lv8']
2082+
output['include_dirs'] += [f"-L{options.external_v8_path}/include"]
20712083
if options.static_zoslib_gyp:
20722084
o['variables']['static_zoslib_gyp'] = options.static_zoslib_gyp
20732085
if flavor != 'linux' and options.v8_enable_hugepage:

shell.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
withTemporal
2828
;
2929
},
30+
cachedV8 ? pkgs.callPackage ./tools/nix/v8.nix { },
3031

3132
# dev tools (not needed to build Node.js, useful to maintain it)
3233
ncu-path ? null, # Provide this if you want to use a local version of NCU
@@ -83,6 +84,10 @@ pkgs.mkShell {
8384
)
8485
]
8586
++ extraConfigFlags
87+
++ pkgs.lib.optionals (cachedV8 != null) [
88+
"--without-bundled-v8"
89+
"--external-v8=${cachedV8}"
90+
]
8691
++ pkgs.lib.optional (!withAmaro) "--without-amaro"
8792
++ pkgs.lib.optional (!withLief) "--without-lief"
8893
++ pkgs.lib.optional withQuic "--experimental-quic"

tools/nix/v8.nix

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
lib,
3+
nodejs-slim_latest,
4+
}:
5+
6+
(nodejs-slim_latest.overrideAttrs (old: {
7+
prePatch = (old.prePatch or "") + ''
8+
cp ${../../common.gypi} common.gypi
9+
cp ${../../node.gypi} node.gypi
10+
cp ${../../node.gyp} node.gyp
11+
cp -r ${../../deps/v8} deps/v8
12+
cp -r ${../../src} src
13+
cp -r ${../../tools/gyp} tools/gyp
14+
cp -r ${../../tools/make-v8.sh} tools/make-v8.sh
15+
cp -r ${../../tools/v8_gypfiles} tools/v8_gypfiles
16+
'';
17+
doCheck = false;
18+
})).libv8

0 commit comments

Comments
 (0)