Skip to content

Commit 3fc30b1

Browse files
committed
tools: add an option to generate lighter archives
1 parent 98081b6 commit 3fc30b1

File tree

2 files changed

+83
-6
lines changed

2 files changed

+83
-6
lines changed

.github/workflows/test-shared.yml

Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,58 @@ permissions:
5757
contents: read
5858

5959
jobs:
60+
build-tarball:
61+
if: github.event.pull_request.draft == false
62+
runs-on: ubuntu-24.04-arm
63+
steps:
64+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
65+
if: ${{ github.event_name != 'workflow_dispatch' }}
66+
with:
67+
persist-credentials: false
68+
69+
- uses: cachix/install-nix-action@f0fe604f8a612776892427721526b4c7cfb23aba # v31
70+
if: ${{ github.event_name != 'workflow_dispatch' }}
71+
with:
72+
extra_nix_config: sandbox = true
73+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
74+
nix_path: nixpkgs=${{ env.NIXPKGS_REPO }}/archive/${{ env.NIXPKGS_PIN }}.tar.gz
75+
76+
- uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16
77+
if: ${{ github.event_name != 'workflow_dispatch' }}
78+
with:
79+
name: nodejs
80+
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
81+
82+
- name: Make tarball
83+
if: ${{ github.event_name != 'workflow_dispatch' }}
84+
run: |
85+
export DATESTRING=$(date "+%Y-%m-%d")
86+
export COMMIT=$(git rev-parse --short=10 "$GITHUB_SHA")
87+
nix-shell \
88+
--pure --keep DISTTYPE --keep DATESTRING --keep COMMIT \
89+
--arg loadJSBuiltinsDynamically false \
90+
--arg ccache 'null' \
91+
--arg icu 'null' \
92+
--arg devTools '[]' \
93+
--arg benchmarkTools '[]' \
94+
--arg sharedLibDeps '{}' \
95+
--run '
96+
./configure && make tar -j8 SKIP_XZ=1 SKIP_SHARED_DEPS=1
97+
'
98+
env:
99+
DISTTYPE: nightly
100+
101+
102+
- name: Upload tarball artifact
103+
if: ${{ github.event_name != 'workflow_dispatch' }}
104+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
105+
with:
106+
name: tarballs
107+
path: '*.tar.gz'
108+
compression-level: 0
109+
60110
build:
111+
needs: build-tarball
61112
strategy:
62113
fail-fast: false
63114
matrix:
@@ -73,10 +124,17 @@ jobs:
73124
name: '${{ matrix.system }}: with shared libraries'
74125
runs-on: ${{ matrix.runner }}
75126
steps:
76-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
127+
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
77128
if: ${{ github.event_name != 'workflow_dispatch' }}
78129
with:
79-
persist-credentials: false
130+
name: tarballs
131+
path: tarballs
132+
133+
- name: Extract tarball
134+
if: ${{ github.event_name != 'workflow_dispatch' }}
135+
run: |
136+
tar xzf tarballs/*.tar.gz -C "$RUNNER_TEMP"
137+
echo "TAR_DIR=$RUNNER_TEMP/$(basename tarballs/*.tar.gz .tar.gz)" >> "$GITHUB_ENV"
80138
81139
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
82140
if: ${{ github.event_name == 'workflow_dispatch' }}
@@ -116,23 +174,22 @@ jobs:
116174
117175
- name: Patch npm gyp (to be able to build addons for the tests)
118176
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
177+
run: curl -L https://github.com/npm/cli/pull/8531.diff | git apply --directory="$TAR_DIR/deps/npm" --exclude="$TAR_DIR/deps/npm/package-lock.json"
120178

121179
- name: Load shell.nix
122-
if: ${{ github.event_name == 'workflow_dispatch' }}
123180
run: curl -fsLSO https://github.com/${GITHUB_REPOSITORY}/raw/${GITHUB_SHA}/shell.nix
124181

125182
- name: Build Node.js ${{ github.event_name == 'workflow_dispatch' && 'on the base commit' || 'and run tests' }}
126183
run: |
127184
nix-shell \
128-
--pure --keep FLAKY_TESTS \
185+
--pure --keep TAR_DIR --keep FLAKY_TESTS \
129186
--keep SCCACHE_GHA_VERSION --keep ACTIONS_CACHE_SERVICE_V2 --keep ACTIONS_RESULTS_URL --keep ACTIONS_RUNTIME_TOKEN \
130187
--arg loadJSBuiltinsDynamically false \
131188
--arg ccache '(import <nixpkgs> {}).sccache' \
132189
--arg devTools '[]' \
133190
--arg benchmarkTools '[]' \
134191
--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"
192+
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"
136193
'
137194
138195
- name: Re-build Node.js on the merge commit

Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,8 @@ BINARYTAR=$(BINARYNAME).tar
10441044
HAS_XZ ?= $(shell command -v xz > /dev/null 2>&1; [ $$? -eq 0 ] && echo 1 || echo 0)
10451045
# Supply SKIP_XZ=1 to explicitly skip .tar.xz creation
10461046
SKIP_XZ ?= 0
1047+
# Supply SKIP_XZ=1 to explicitly skip all dependencies that can be included as shared deps
1048+
SKIP_SHARED_DEPS ?= 0
10471049
XZ = $(shell [ $(HAS_XZ) -eq 1 ] && [ $(SKIP_XZ) -eq 0 ] && echo 1 || echo 0)
10481050
XZ_COMPRESSION ?= 9e
10491051
PKG=$(TARNAME).pkg
@@ -1213,12 +1215,30 @@ $(TARBALL): release-only doc-only
12131215
$(RM) -r $(TARNAME)/.editorconfig
12141216
$(RM) -r $(TARNAME)/.git*
12151217
$(RM) -r $(TARNAME)/.mailmap
1218+
ifeq ($(SKIP_SHARED_DEPS), 1)
1219+
$(RM) -r $(TARNAME)/deps/ada
1220+
$(RM) -r $(TARNAME)/deps/brotli
1221+
$(RM) -r $(TARNAME)/deps/cares
1222+
$(RM) -r $(TARNAME)/deps/icu-small
1223+
$(RM) -r $(TARNAME)/deps/icu-tmp
1224+
$(RM) -r $(TARNAME)/deps/llhttp
1225+
$(RM) -r $(TARNAME)/deps/nghttp2
1226+
$(RM) -r $(TARNAME)/deps/ngtcp2
1227+
$(RM) -r $(TARNAME)/deps/openssl
1228+
$(RM) -r $(TARNAME)/deps/simdjson
1229+
$(RM) -r $(TARNAME)/deps/sqlite
1230+
$(RM) -r $(TARNAME)/deps/uv
1231+
$(RM) -r $(TARNAME)/deps/uvwasi
1232+
$(RM) -r $(TARNAME)/deps/zlib
1233+
$(RM) -r $(TARNAME)/deps/zstd
1234+
else
12161235
$(RM) -r $(TARNAME)/deps/openssl/openssl/demos
12171236
$(RM) -r $(TARNAME)/deps/openssl/openssl/doc
12181237
$(RM) -r $(TARNAME)/deps/openssl/openssl/test
12191238
$(RM) -r $(TARNAME)/deps/uv/docs
12201239
$(RM) -r $(TARNAME)/deps/uv/samples
12211240
$(RM) -r $(TARNAME)/deps/uv/test
1241+
endif
12221242
$(RM) -r $(TARNAME)/deps/v8/samples
12231243
$(RM) -r $(TARNAME)/deps/v8/tools/profviz
12241244
$(RM) -r $(TARNAME)/deps/v8/tools/run-tests.py

0 commit comments

Comments
 (0)