Skip to content

Commit 3c8c1ef

Browse files
committed
tools: add an option to generate lighter archives
PR-URL: nodejs/node#60294 Reviewed-By: Yagiz Nizipli <[email protected]>
1 parent 27892ec commit 3c8c1ef

File tree

2 files changed

+72
-6
lines changed

2 files changed

+72
-6
lines changed

.github/workflows/test-shared.yml

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,35 @@ permissions:
3535
contents: read
3636

3737
jobs:
38-
build:
38+
build-tarball:
3939
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+
- name: Upload tarball artifact
58+
if: ${{ github.event_name != 'workflow_dispatch' }}
59+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
60+
with:
61+
name: tarballs
62+
path: '*.tar.gz'
63+
compression-level: 0
64+
65+
build:
66+
needs: build-tarball
4067
strategy:
4168
fail-fast: false
4269
matrix:
@@ -52,9 +79,17 @@ jobs:
5279
name: '${{ matrix.system }}: with shared libraries'
5380
runs-on: ${{ matrix.runner }}
5481
steps:
55-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
82+
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
83+
if: ${{ github.event_name != 'workflow_dispatch' }}
5684
with:
57-
persist-credentials: false
85+
name: tarballs
86+
path: tarballs
87+
88+
- name: Extract tarball
89+
if: ${{ github.event_name != 'workflow_dispatch' }}
90+
run: |
91+
tar xzf tarballs/*.tar.gz -C "$RUNNER_TEMP"
92+
echo "TAR_DIR=$RUNNER_TEMP/$(basename tarballs/*.tar.gz .tar.gz)" >> "$GITHUB_ENV"
5893
5994
- uses: cachix/install-nix-action@7be5dee1421f63d07e71ce6e0a9f8a4b07c2a487 # v31.6.1
6095
with:
@@ -69,17 +104,24 @@ jobs:
69104
core.exportVariable('ACTIONS_RESULTS_URL', process.env.ACTIONS_RESULTS_URL || '');
70105
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
71106
107+
- name: Load shell.nix
108+
if: github.event_name != 'workflow_dispatch'
109+
run: |
110+
mv "$TAR_DIR"/*.nix .
111+
mkdir tools
112+
mv "$TAR_DIR"/tools/nix tools/.
113+
72114
- name: Build Node.js and run tests
73115
run: |
74116
nix-shell \
75117
-I nixpkgs=./tools/nix/pkgs.nix \
76-
--pure --keep FLAKY_TESTS \
118+
--pure --keep TAR_DIR --keep FLAKY_TESTS \
77119
--keep SCCACHE_GHA_VERSION --keep ACTIONS_CACHE_SERVICE_V2 --keep ACTIONS_RESULTS_URL --keep ACTIONS_RUNTIME_TOKEN \
78120
--arg loadJSBuiltinsDynamically false \
79121
--arg ccache '(import <nixpkgs> {}).sccache' \
80122
--arg devTools '[]' \
81123
--arg benchmarkTools '[]' \
82124
${{ endsWith(matrix.system, '-darwin') && '--arg extraConfigFlags ''["--without-inspector"]'' \' || '\' }}
83125
--run '
84-
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"
85127
'

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)