Skip to content

Commit fbc47fa

Browse files
committed
tools: update build-shared/action.yml to a reusable workflow
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 4d3198c commit fbc47fa

3 files changed

Lines changed: 120 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: 31 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ on:
4747
- vcbuild.bat
4848
- .**
4949
- '!.github/workflows/test-shared.yml'
50-
- '!.github/actions/build-shared/**'
50+
- '!.github/workflows/build-shared.yml'
5151
types: [opened, synchronize, reopened, ready_for_review]
5252
push:
5353
branches:
@@ -98,15 +98,12 @@ on:
9898
- vcbuild.bat
9999
- .**
100100
- '!.github/workflows/test-shared.yml'
101-
- '!.github/actions/build-shared/**'
101+
- '!.github/workflows/build-shared.yml'
102102

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

107-
env:
108-
FLAKY_TESTS: keep_retrying
109-
110107
permissions:
111108
contents: read
112109

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

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

0 commit comments

Comments
 (0)