Skip to content

Commit 7b6ae64

Browse files
committed
tools: add an option to generate lighter archives
1 parent 36bbff7 commit 7b6ae64

File tree

2 files changed

+69
-5
lines changed

2 files changed

+69
-5
lines changed

.github/workflows/test-shared.yml

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,36 @@ permissions:
5959
contents: read
6060

6161
jobs:
62+
build-tarball:
63+
if: github.event.pull_request.draft == false
64+
name: ${{ github.event_name == 'workflow_dispatch' && 'Skipped job' || 'Build slim tarball' }}
65+
runs-on: ubuntu-24.04-arm
66+
steps:
67+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
68+
if: ${{ github.event_name != 'workflow_dispatch' }}
69+
with:
70+
persist-credentials: false
71+
72+
- name: Make tarball
73+
if: ${{ github.event_name != 'workflow_dispatch' }}
74+
run: |
75+
export DATESTRING=$(date "+%Y-%m-%d")
76+
export COMMIT=$(git rev-parse --short=10 "$GITHUB_SHA")
77+
./configure && make tar -j4 SKIP_XZ=1 SKIP_SHARED_DEPS=1
78+
env:
79+
DISTTYPE: nightly
80+
81+
82+
- name: Upload tarball artifact
83+
if: ${{ github.event_name != 'workflow_dispatch' }}
84+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
85+
with:
86+
name: tarballs
87+
path: '*.tar.gz'
88+
compression-level: 0
89+
6290
build:
91+
needs: build-tarball
6392
strategy:
6493
fail-fast: false
6594
matrix:
@@ -75,10 +104,17 @@ jobs:
75104
name: '${{ matrix.system }}: with shared libraries'
76105
runs-on: ${{ matrix.runner }}
77106
steps:
78-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
107+
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
79108
if: ${{ github.event_name != 'workflow_dispatch' }}
80109
with:
81-
persist-credentials: false
110+
name: tarballs
111+
path: tarballs
112+
113+
- name: Extract tarball
114+
if: ${{ github.event_name != 'workflow_dispatch' }}
115+
run: |
116+
tar xzf tarballs/*.tar.gz -C "$RUNNER_TEMP"
117+
echo "TAR_DIR=$RUNNER_TEMP/$(basename tarballs/*.tar.gz .tar.gz)" >> "$GITHUB_ENV"
82118
83119
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
84120
if: ${{ github.event_name == 'workflow_dispatch' }}
@@ -109,6 +145,10 @@ jobs:
109145
core.exportVariable('ACTIONS_RESULTS_URL', process.env.ACTIONS_RESULTS_URL || '');
110146
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
111147
148+
- name: Load shell.nix
149+
if: github.event_name != 'workflow_dispatch'
150+
run: mv "$TAR_DIR"/*.nix .
151+
112152
- name: Load shell.nix
113153
if: github.event_name == 'workflow_dispatch'
114154
run: |
@@ -119,14 +159,14 @@ jobs:
119159
run: |
120160
nix-shell \
121161
-I nixpkgs=./nixpkgs.nix \
122-
--pure --keep FLAKY_TESTS \
162+
--pure --keep TAR_DIR --keep FLAKY_TESTS \
123163
--keep SCCACHE_GHA_VERSION --keep ACTIONS_CACHE_SERVICE_V2 --keep ACTIONS_RESULTS_URL --keep ACTIONS_RUNTIME_TOKEN \
124164
--arg loadJSBuiltinsDynamically false \
125165
--arg ccache '(import <nixpkgs> {}).sccache' \
126166
--arg devTools '[]' \
127167
--arg benchmarkTools '[]' \
128168
--run '
129-
make ${{ github.event_name == 'workflow_dispatch' && 'build' || 'run' }}-ci -j4 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9 --skip-tests=$CI_SKIP_TESTS"
169+
make ${{ github.event_name == 'workflow_dispatch' && 'build' || '-C "$TAR_DIR" run' }}-ci -j4 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9 --skip-tests=$CI_SKIP_TESTS"
130170
'
131171
132172
- name: Re-build Node.js on the merge commit

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)