Skip to content

Commit b0fa732

Browse files
authored
tools: update build-shared/action.yml to a reusable workflow
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: #64059 Reviewed-By: Jithil P Ponnan <jithil@outlook.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent 4f177f1 commit b0fa732

3 files changed

Lines changed: 119 additions & 115 deletions

File tree

.github/actions/build-shared/action.yml

Lines changed: 0 additions & 65 deletions
This file was deleted.

.github/workflows/build-shared.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Build Node.js (shared libraries)
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
runner:
7+
description: The runner to use for the job.
8+
required: true
9+
type: string
10+
extra-nix-flags:
11+
description: Additional CLI arguments appended to the nix-shell invocation.
12+
required: false
13+
type: string
14+
default: ''
15+
with-sccache:
16+
description: Whether to enable sccache
17+
required: false
18+
type: boolean
19+
default: false
20+
v8-nar:
21+
description: An optional name for the NAR archive for V8 that needs to be downloaded
22+
required: false
23+
type: string
24+
default: ''
25+
secrets:
26+
CACHIX_AUTH_TOKEN:
27+
description: Cachix auth token for nodejs.cachix.org.
28+
required: false
29+
30+
permissions: {}
31+
32+
env:
33+
FLAKY_TESTS: keep_retrying
34+
35+
jobs:
36+
build:
37+
runs-on: ${{ inputs.runner }}
38+
steps:
39+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
40+
with:
41+
name: tarballs
42+
path: tarballs
43+
44+
- name: Extract tarball
45+
shell: bash
46+
run: |
47+
tar xzf tarballs/*.tar.gz -C "$RUNNER_TEMP"
48+
echo "TAR_DIR=$RUNNER_TEMP/$(basename tarballs/*.tar.gz .tar.gz)" >> "$GITHUB_ENV"
49+
50+
- uses: cachix/install-nix-action@8aa03977d8d733052d78f4e008a241fd1dbf36b3 # v31.10.6
51+
with:
52+
extra_nix_config: sandbox = true
53+
54+
- uses: cachix/cachix-action@5f2d7c5294214f71b873db4b969586b980625e71 # v17
55+
with:
56+
name: nodejs
57+
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
58+
59+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
60+
if: inputs.v8-nar
61+
with:
62+
name: ${{ inputs.v8-nar }}
63+
64+
- name: Configure sccache
65+
if: inputs.with-sccache
66+
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
67+
with:
68+
script: |
69+
core.exportVariable('SCCACHE_GHA_ENABLED', 'on');
70+
core.exportVariable('ACTIONS_CACHE_SERVICE_V2', 'on');
71+
core.exportVariable('ACTIONS_RESULTS_URL', process.env.ACTIONS_RESULTS_URL || '');
72+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
73+
core.exportVariable('NIX_SCCACHE', '(import <nixpkgs> {}).sccache');
74+
75+
- name: Build Node.js and run tests
76+
shell: bash
77+
run: |
78+
nix-shell \
79+
-I "nixpkgs=$TAR_DIR/tools/nix/pkgs.nix" \
80+
--pure --keep TAR_DIR --keep FLAKY_TESTS \
81+
--keep SCCACHE_GHA_ENABLED --keep ACTIONS_CACHE_SERVICE_V2 --keep ACTIONS_RESULTS_URL --keep ACTIONS_RUNTIME_TOKEN \
82+
--arg loadJSBuiltinsDynamically false \
83+
--arg ccache "${NIX_SCCACHE:-null}" \
84+
--arg devTools '[]' \
85+
--arg benchmarkTools '[]' \
86+
${{ inputs.extra-nix-flags }} \
87+
--run '
88+
make -C "$TAR_DIR" run-ci -j4 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9 --skip-tests=$CI_SKIP_TESTS"
89+
' "$TAR_DIR/shell.nix"

.github/workflows/test-shared.yml

Lines changed: 30 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ on:
4848
- vcbuild.bat
4949
- .**
5050
- '!.github/workflows/test-shared.yml'
51-
- '!.github/actions/build-shared/**'
51+
- '!.github/workflows/build-shared.yml'
5252
types: [opened, synchronize, reopened, ready_for_review]
5353
push:
5454
branches:
@@ -100,15 +100,12 @@ on:
100100
- vcbuild.bat
101101
- .**
102102
- '!.github/workflows/test-shared.yml'
103-
- '!.github/actions/build-shared/**'
103+
- '!.github/workflows/build-shared.yml'
104104

105105
concurrency:
106106
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
107107
cancel-in-progress: true
108108

109-
env:
110-
FLAKY_TESTS: keep_retrying
111-
112109
permissions:
113110
contents: read
114111

@@ -153,20 +150,15 @@ jobs:
153150
- runner: macos-latest
154151
system: aarch64-darwin
155152
name: '${{ matrix.system }}: with shared libraries'
156-
runs-on: ${{ matrix.runner }}
157-
steps:
158-
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
159-
with:
160-
persist-credentials: false
161-
sparse-checkout: .github/actions
162-
sparse-checkout-cone-mode: false
163-
- uses: ./.github/actions/build-shared
164-
name: Build and test Node.js
165-
with:
166-
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
167-
extra-nix-flags: |
168-
--arg useSeparateDerivationForV8 true \
169-
${{ endsWith(matrix.system, '-darwin') && '--arg withAmaro false --arg withLief false --arg withSQLite false --arg withFFI false --arg extraConfigFlags ''["--without-inspector" "--without-node-options"]'' \' || '\' }}
153+
uses: ./.github/workflows/build-shared.yml
154+
with:
155+
runner: ${{ matrix.runner }}
156+
with-sccache: ${{ github.base_ref == 'main' || github.ref_name == 'main' }}
157+
extra-nix-flags: |
158+
--arg useSeparateDerivationForV8 true \
159+
${{ endsWith(matrix.system, '-darwin') && '--arg withAmaro false --arg withLief false --arg withSQLite false --arg withFFI false --arg extraConfigFlags ''["--without-inspector" "--without-node-options"]'' \' || '\' }}
160+
secrets:
161+
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
170162

171163
build-aarch64-linux-v8:
172164
needs: build-tarball
@@ -249,34 +241,22 @@ jobs:
249241
matrix:
250242
openssl: ${{ fromJSON(needs.build-aarch64-linux-v8.outputs.matrix) }}
251243
name: 'aarch64-linux: with shared ${{ matrix.openssl.name }}'
252-
runs-on: ubuntu-24.04-arm
253-
continue-on-error: false
254-
env:
255-
OPENSSL_ATTR: ${{ matrix.openssl.attr }}
256-
steps:
257-
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
258-
with:
259-
persist-credentials: false
260-
sparse-checkout: .github/actions
261-
sparse-checkout-cone-mode: false
262-
263-
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
264-
if: ${{ needs.build-aarch64-linux-v8.outputs.local-cache }}
265-
with:
266-
name: libv8-aarch64-linux.nar
267-
268-
- uses: ./.github/actions/build-shared
269-
name: Build and test Node.js
270-
with:
271-
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
272-
# Override just the `openssl` attr of the default shared-lib set with
273-
# the matrix-selected nixpkgs attribute (e.g. `openssl_3_6`). All
274-
# other shared libs (brotli, cares, libuv, …) keep their defaults.
275-
# `permittedInsecurePackages` whitelists just the matrix-selected
276-
# release (e.g. `openssl-1.1.1w`) so EOL-with-extended-support
277-
# cycles evaluate without relaxing nixpkgs' meta check globally.
278-
extra-nix-flags: |
279-
--arg useSeparateDerivationForV8 ${{ needs.build-aarch64-linux-v8.outputs.local-cache && '"$(nix-store --import < libv8-aarch64-linux.nar)"' || 'true' }} \
280-
--arg sharedLibDeps "(import $TAR_DIR/tools/nix/sharedLibDeps.nix {}) // {
281-
openssl = (import $TAR_DIR/tools/nix/openssl-matrix.nix {}).$OPENSSL_ATTR;
282-
}" \
244+
uses: ./.github/workflows/build-shared.yml
245+
with:
246+
runner: ubuntu-24.04-arm
247+
v8-nar: ${{ needs.build-aarch64-linux-v8.outputs.local-cache && 'libv8-aarch64-linux.nar' }}
248+
# Override just the `openssl` attr of the default shared-lib set with
249+
# the matrix-selected nixpkgs attribute (e.g. `openssl_3_6`). All
250+
# other shared libs (brotli, cares, libuv, …) keep their defaults.
251+
# `permittedInsecurePackages` whitelists just the matrix-selected
252+
# release (e.g. `openssl-1.1.1w`) so EOL-with-extended-support
253+
# cycles evaluate without relaxing nixpkgs' meta check globally.
254+
extra-nix-flags: |
255+
--arg useSeparateDerivationForV8 ${{ needs.build-aarch64-linux-v8.outputs.local-cache && '"$(nix-store --import < libv8-aarch64-linux.nar)"' || 'true' }} \
256+
--arg sharedLibDeps "(import $TAR_DIR/tools/nix/sharedLibDeps.nix {}) // {
257+
openssl = builtins.getAttr \"${{
258+
!contains(matrix.openssl.attr, '$') && !contains(matrix.openssl.attr, '\"') && !contains(matrix.openssl.attr, '\') && !contains(matrix.openssl.attr, '`') && matrix.openssl.attr
259+
}}\" (import $TAR_DIR/tools/nix/openssl-matrix.nix {});
260+
}" \
261+
secrets:
262+
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}

0 commit comments

Comments
 (0)