Skip to content

Commit fd1d632

Browse files
committed
tools: add an option to generate lighter archives
1 parent b13f99c commit fd1d632

File tree

2 files changed

+81
-11
lines changed

2 files changed

+81
-11
lines changed

.github/workflows/test-shared.yml

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,46 @@ permissions:
5757
contents: read
5858

5959
jobs:
60+
build-tarball:
61+
if: github.event.pull_request.draft == false
62+
name: ${{ github.event_name == 'workflow_dispatch' && 'Skipped job' || 'Build slim tarball' }}
63+
runs-on: ubuntu-24.04-arm
64+
steps:
65+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
66+
if: ${{ github.event_name != 'workflow_dispatch' }}
67+
with:
68+
persist-credentials: false
69+
70+
- name: Patch npm gyp (to be able to build addons for the tests)
71+
if: ${{ github.event_name != 'workflow_dispatch' }}
72+
run: |
73+
curl -L https://github.com/nodejs/gyp-next/commit/8224deef984add7e7afe846cfb82c9d3fa6da1fb.diff \
74+
| git apply --directory=deps/npm/node_modules/node-gyp/gyp
75+
git add deps/npm/node_modules/node-gyp/gyp
76+
git config --local user.email "github-bot@iojs.org"
77+
git config --local user.name "Node.js GitHub Bot"
78+
git commit --fixup HEAD
79+
80+
- name: Make tarball
81+
if: ${{ github.event_name != 'workflow_dispatch' }}
82+
run: |
83+
export DATESTRING=$(date "+%Y-%m-%d")
84+
export COMMIT=$(git rev-parse --short=10 "$GITHUB_SHA")
85+
./configure && make tar -j4 SKIP_XZ=1 SKIP_SHARED_DEPS=1
86+
env:
87+
DISTTYPE: nightly
88+
89+
90+
- name: Upload tarball artifact
91+
if: ${{ github.event_name != 'workflow_dispatch' }}
92+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
93+
with:
94+
name: tarballs
95+
path: '*.tar.gz'
96+
compression-level: 0
97+
6098
build:
99+
needs: build-tarball
61100
strategy:
62101
fail-fast: false
63102
matrix:
@@ -73,10 +112,17 @@ jobs:
73112
name: '${{ matrix.system }}: with shared libraries'
74113
runs-on: ${{ matrix.runner }}
75114
steps:
76-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
115+
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
77116
if: ${{ github.event_name != 'workflow_dispatch' }}
78117
with:
79-
persist-credentials: false
118+
name: tarballs
119+
path: tarballs
120+
121+
- name: Extract tarball
122+
if: ${{ github.event_name != 'workflow_dispatch' }}
123+
run: |
124+
tar xzf tarballs/*.tar.gz -C "$RUNNER_TEMP"
125+
echo "TAR_DIR=$RUNNER_TEMP/$(basename tarballs/*.tar.gz .tar.gz)" >> "$GITHUB_ENV"
80126
81127
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
82128
if: ${{ github.event_name == 'workflow_dispatch' }}
@@ -113,26 +159,25 @@ jobs:
113159
core.exportVariable('ACTIONS_CACHE_SERVICE_V2', 'on');
114160
core.exportVariable('ACTIONS_RESULTS_URL', process.env.ACTIONS_RESULTS_URL || '');
115161
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
116-
117-
- name: Patch npm gyp (to be able to build addons for the tests)
118-
if: ${{ github.event_name != 'workflow_dispatch' }}
119-
run: curl -L https://github.com/npm/cli/pull/8531.diff | git apply --directory=deps/npm --exclude=deps/npm/package-lock.json
120162
121163
- name: Load shell.nix
122-
if: ${{ github.event_name == 'workflow_dispatch' }}
123-
run: curl -fsLSO https://github.com/${GITHUB_REPOSITORY}/raw/${GITHUB_SHA}/shell.nix
164+
run: |
165+
${{ github.event_name == 'workflow_dispatch' &&
166+
'curl -fsLSO https://github.com/${GITHUB_REPOSITORY}/raw/${GITHUB_SHA}/shell.nix'
167+
|| 'mv "$TAR_DIR/shell.nix" .'
168+
}}
124169
125170
- name: Build Node.js ${{ github.event_name == 'workflow_dispatch' && 'on the base commit' || 'and run tests' }}
126171
run: |
127172
nix-shell \
128-
--pure --keep FLAKY_TESTS \
173+
--pure --keep TAR_DIR --keep FLAKY_TESTS \
129174
--keep SCCACHE_GHA_VERSION --keep ACTIONS_CACHE_SERVICE_V2 --keep ACTIONS_RESULTS_URL --keep ACTIONS_RUNTIME_TOKEN \
130175
--arg loadJSBuiltinsDynamically false \
131176
--arg ccache '(import <nixpkgs> {}).sccache' \
132177
--arg devTools '[]' \
133178
--arg benchmarkTools '[]' \
134179
--run '
135-
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"
180+
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"
136181
'
137182
138183
- name: Re-build Node.js on the merge commit

Makefile

Lines changed: 26 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
@@ -1213,12 +1218,31 @@ $(TARBALL): release-only doc-only
12131218
$(RM) -r $(TARNAME)/.editorconfig
12141219
$(RM) -r $(TARNAME)/.git*
12151220
$(RM) -r $(TARNAME)/.mailmap
1221+
ifeq ($(SKIP_SHARED_DEPS), 1)
1222+
$(RM) -r $(TARNAME)/deps/ada
1223+
$(RM) -r $(TARNAME)/deps/brotli
1224+
$(RM) -r $(TARNAME)/deps/cares
1225+
$(RM) -r $(TARNAME)/deps/icu-small
1226+
$(RM) -r $(TARNAME)/deps/icu-tmp
1227+
$(RM) -r $(TARNAME)/deps/llhttp
1228+
$(RM) -r $(TARNAME)/deps/nghttp2
1229+
$(RM) -r $(TARNAME)/deps/ngtcp2
1230+
find $(TARNAME)/deps/openssl -maxdepth 1 -type f ! -name 'nodejs-openssl.cnf' -exec $(RM) {} +
1231+
find $(TARNAME)/deps/openssl -mindepth 1 -maxdepth 1 -type d -exec $(RM) -r {} +
1232+
$(RM) -r $(TARNAME)/deps/simdjson
1233+
$(RM) -r $(TARNAME)/deps/sqlite
1234+
$(RM) -r $(TARNAME)/deps/uv
1235+
$(RM) -r $(TARNAME)/deps/uvwasi
1236+
$(RM) -r $(TARNAME)/deps/zlib
1237+
$(RM) -r $(TARNAME)/deps/zstd
1238+
else
12161239
$(RM) -r $(TARNAME)/deps/openssl/openssl/demos
12171240
$(RM) -r $(TARNAME)/deps/openssl/openssl/doc
12181241
$(RM) -r $(TARNAME)/deps/openssl/openssl/test
12191242
$(RM) -r $(TARNAME)/deps/uv/docs
12201243
$(RM) -r $(TARNAME)/deps/uv/samples
12211244
$(RM) -r $(TARNAME)/deps/uv/test
1245+
endif
12221246
$(RM) -r $(TARNAME)/deps/v8/samples
12231247
$(RM) -r $(TARNAME)/deps/v8/tools/profviz
12241248
$(RM) -r $(TARNAME)/deps/v8/tools/run-tests.py
@@ -1227,6 +1251,7 @@ $(TARBALL): release-only doc-only
12271251
$(RM) -r $(TARNAME)/tools/cpplint.py
12281252
$(RM) -r $(TARNAME)/tools/eslint
12291253
$(RM) -r $(TARNAME)/tools/eslint-rules
1254+
$(RM) -r $(TARNAME)/test/parallel/test-eslint-*
12301255
$(RM) -r $(TARNAME)/tools/license-builder.sh
12311256
$(RM) -r $(TARNAME)/tools/eslint/node_modules
12321257
$(RM) -r $(TARNAME)/tools/osx-*

0 commit comments

Comments
 (0)