Skip to content

Commit a8bf222

Browse files
committed
tools: add an option to generate lighter archives
1 parent 875a7bb commit a8bf222

File tree

2 files changed

+73
-5
lines changed

2 files changed

+73
-5
lines changed

.github/workflows/test-shared.yml

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,36 @@ permissions:
3535
contents: read
3636

3737
jobs:
38+
build-tarball:
39+
if: github.event.pull_request.draft == false
40+
name: ${{ github.event_name == 'workflow_dispatch' && 'Skipped job' || 'Build slim tarball' }}
41+
runs-on: ubuntu-24.04-arm
42+
steps:
43+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
44+
if: ${{ github.event_name != 'workflow_dispatch' }}
45+
with:
46+
persist-credentials: false
47+
48+
- name: Make tarball
49+
if: ${{ github.event_name != 'workflow_dispatch' }}
50+
run: |
51+
export DATESTRING=$(date "+%Y-%m-%d")
52+
export COMMIT=$(git rev-parse --short=10 "$GITHUB_SHA")
53+
./configure && make tar -j4 SKIP_XZ=1 SKIP_SHARED_DEPS=1
54+
env:
55+
DISTTYPE: nightly
56+
57+
58+
- name: Upload tarball artifact
59+
if: ${{ github.event_name != 'workflow_dispatch' }}
60+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
61+
with:
62+
name: tarballs
63+
path: '*.tar.gz'
64+
compression-level: 0
65+
3866
build:
67+
needs: build-tarball
3968
strategy:
4069
fail-fast: false
4170
matrix:
@@ -51,9 +80,17 @@ jobs:
5180
name: '${{ matrix.system }}: with shared libraries'
5281
runs-on: ${{ matrix.runner }}
5382
steps:
54-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
83+
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
84+
if: ${{ github.event_name != 'workflow_dispatch' }}
5585
with:
56-
persist-credentials: false
86+
name: tarballs
87+
path: tarballs
88+
89+
- name: Extract tarball
90+
if: ${{ github.event_name != 'workflow_dispatch' }}
91+
run: |
92+
tar xzf tarballs/*.tar.gz -C "$RUNNER_TEMP"
93+
echo "TAR_DIR=$RUNNER_TEMP/$(basename tarballs/*.tar.gz .tar.gz)" >> "$GITHUB_ENV"
5794
5895
- uses: cachix/install-nix-action@7be5dee1421f63d07e71ce6e0a9f8a4b07c2a487 # v31.6.1
5996
with:
@@ -68,16 +105,23 @@ jobs:
68105
core.exportVariable('ACTIONS_RESULTS_URL', process.env.ACTIONS_RESULTS_URL || '');
69106
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
70107
108+
- name: Load shell.nix
109+
if: github.event_name != 'workflow_dispatch'
110+
run: |
111+
mv "$TAR_DIR"/*.nix .
112+
mkdir tools
113+
mv "$TAR_DIR"/tools/nix tools/.
114+
71115
- name: Build Node.js and run tests
72116
run: |
73117
nix-shell \
74118
-I nixpkgs=./tools/nix/pkgs.nix \
75-
--pure --keep FLAKY_TESTS \
119+
--pure --keep TAR_DIR --keep FLAKY_TESTS \
76120
--keep SCCACHE_GHA_VERSION --keep ACTIONS_CACHE_SERVICE_V2 --keep ACTIONS_RESULTS_URL --keep ACTIONS_RUNTIME_TOKEN \
77121
--arg loadJSBuiltinsDynamically false \
78122
--arg ccache '(import <nixpkgs> {}).sccache' \
79123
--arg devTools '[]' \
80124
--arg benchmarkTools '[]' \
81125
--run '
82-
make run-ci -j4 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9 --skip-tests=$CI_SKIP_TESTS"
126+
make -C "$TAR_DIR" run-ci -j4 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9 --skip-tests=$CI_SKIP_TESTS"
83127
'

Makefile

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ ADDONS_HEADERS_PREREQS := tools/install.py \
399399
$(wildcard deps/uv/include/*/*.h) \
400400
$(wildcard deps/v8/include/*.h) \
401401
$(wildcard deps/v8/include/*/*.h) \
402-
deps/zlib/zconf.h deps/zlib/zlib.h \
402+
$(wildcard deps/zlib/z*.h) \
403403
src/node.h src/node_api.h src/js_native_api.h src/js_native_api_types.h \
404404
src/node_api_types.h src/node_buffer.h src/node_object_wrap.h \
405405
src/node_version.h
@@ -1032,6 +1032,11 @@ override DESTCPU=x86
10321032
endif
10331033

10341034
TARNAME=node-$(FULLVERSION)
1035+
# Supply SKIP_SHARED_DEPS=1 to explicitly skip all dependencies that can be included as shared deps
1036+
SKIP_SHARED_DEPS ?= 0
1037+
ifeq ($(SKIP_SHARED_DEPS), 1)
1038+
TARNAME:=$(TARNAME)-slim
1039+
endif
10351040
TARBALL=$(TARNAME).tar
10361041
# Custom user-specified variation, use it directly
10371042
ifdef VARIATION
@@ -1215,12 +1220,31 @@ $(TARBALL): release-only doc-only
12151220
$(RM) -r $(TARNAME)/.mailmap
12161221
$(RM) -r $(TARNAME)/deps/corepack
12171222
$(RM) $(TARNAME)/test/parallel/test-corepack-version.js
1223+
ifeq ($(SKIP_SHARED_DEPS), 1)
1224+
$(RM) -r $(TARNAME)/deps/ada
1225+
$(RM) -r $(TARNAME)/deps/brotli
1226+
$(RM) -r $(TARNAME)/deps/cares
1227+
$(RM) -r $(TARNAME)/deps/icu-small
1228+
$(RM) -r $(TARNAME)/deps/icu-tmp
1229+
$(RM) -r $(TARNAME)/deps/llhttp
1230+
$(RM) -r $(TARNAME)/deps/nghttp2
1231+
$(RM) -r $(TARNAME)/deps/ngtcp2
1232+
find $(TARNAME)/deps/openssl -maxdepth 1 -type f ! -name 'nodejs-openssl.cnf' -exec $(RM) {} +
1233+
find $(TARNAME)/deps/openssl -mindepth 1 -maxdepth 1 -type d -exec $(RM) -r {} +
1234+
$(RM) -r $(TARNAME)/deps/simdjson
1235+
$(RM) -r $(TARNAME)/deps/sqlite
1236+
$(RM) -r $(TARNAME)/deps/uv
1237+
$(RM) -r $(TARNAME)/deps/uvwasi
1238+
$(RM) -r $(TARNAME)/deps/zlib
1239+
$(RM) -r $(TARNAME)/deps/zstd
1240+
else
12181241
$(RM) -r $(TARNAME)/deps/openssl/openssl/demos
12191242
$(RM) -r $(TARNAME)/deps/openssl/openssl/doc
12201243
$(RM) -r $(TARNAME)/deps/openssl/openssl/test
12211244
$(RM) -r $(TARNAME)/deps/uv/docs
12221245
$(RM) -r $(TARNAME)/deps/uv/samples
12231246
$(RM) -r $(TARNAME)/deps/uv/test
1247+
endif
12241248
$(RM) -r $(TARNAME)/deps/v8/samples
12251249
$(RM) -r $(TARNAME)/deps/v8/tools/profviz
12261250
$(RM) -r $(TARNAME)/deps/v8/tools/run-tests.py

0 commit comments

Comments
 (0)