Skip to content

Commit b78d627

Browse files
committed
tools: cache V8 builds
1 parent 5a877ec commit b78d627

4 files changed

Lines changed: 65 additions & 39 deletions

File tree

.github/workflows/test-shared.yml

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ concurrency:
106106

107107
env:
108108
FLAKY_TESTS: keep_retrying
109-
# Latest OpenSSL major.minor cycle we support running tests with.
110-
# The nixpkgs updater regenerates the OpenSSL matrix using this value.
111-
SUPPORTED_OPENSSL_VERSION: '4.0'
112109

113110
permissions:
114111
contents: read
@@ -141,6 +138,47 @@ jobs:
141138
path: '*.tar.gz'
142139
compression-level: 0
143140

141+
build-aarch64-linux-v8:
142+
needs: build-tarball
143+
runs-on: ubuntu-24.04-arm
144+
name: 'aarch64-linux: Cache V8 build'
145+
steps:
146+
- name: Check if Cachix is available
147+
id: cachix-check
148+
run: echo 'IS_AVAILABLE=${{ secrets.CACHIX_AUTH_TOKEN && 'true' }}' >> "$GITHUB_OUTPUT"
149+
150+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
151+
if: ${{ steps.cachix-check.outputs.IS_AVAILABLE == 'true' }}
152+
with:
153+
name: tarballs
154+
path: tarballs
155+
156+
- name: Extract tarball
157+
if: ${{ steps.cachix-check.outputs.IS_AVAILABLE == 'true' }}
158+
shell: bash
159+
run: |
160+
tar xzf tarballs/*.tar.gz -C "$RUNNER_TEMP"
161+
echo "TAR_DIR=$RUNNER_TEMP/$(basename tarballs/*.tar.gz .tar.gz)" >> "$GITHUB_ENV"
162+
163+
- uses: cachix/install-nix-action@96951a368ba55167b55f1c916f7d416bac6505fe # v31.10.3
164+
if: ${{ steps.cachix-check.outputs.IS_AVAILABLE == 'true' }}
165+
with:
166+
extra_nix_config: sandbox = true
167+
168+
- uses: cachix/cachix-action@1eb2ef646ac0255473d23a5907ad7b04ce94065c # v17
169+
if: ${{ steps.cachix-check.outputs.IS_AVAILABLE == 'true' }}
170+
with:
171+
name: nodejs
172+
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
173+
174+
- name: Build V8 derivation
175+
if: ${{ steps.cachix-check.outputs.IS_AVAILABLE == 'true' }}
176+
run: |
177+
set +x
178+
nix-build "$(
179+
nix-instantiate -E "builtins.filter (p: p.pname == ''v8'') (import $TAR_DIR/shell.nix { useSeparateDerivationForV8=true; }).buildInputs"
180+
)"
181+
144182
build:
145183
needs: build-tarball
146184
strategy:
@@ -149,8 +187,8 @@ jobs:
149187
include:
150188
- runner: ubuntu-24.04
151189
system: x86_64-linux
152-
- runner: ubuntu-24.04-arm
153-
system: aarch64-linux
190+
# - runner: ubuntu-24.04-arm
191+
# system: aarch64-linux
154192
- runner: macos-15-intel
155193
system: x86_64-darwin
156194
- runner: macos-latest
@@ -181,21 +219,24 @@ jobs:
181219
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
182220
with:
183221
persist-credentials: false
184-
sparse-checkout: tools/nix
222+
sparse-checkout: tools/nix/openssl-matrix.json
185223
sparse-checkout-cone-mode: false
186224
- id: query
187225
run: |
188-
matrix=$(jq -c . tools/nix/openssl-matrix.json)
189-
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
190-
226+
{
227+
echo 'matrix<<EOF'
228+
cat tools/nix/openssl-matrix.json
229+
echo 'EOF'
230+
} >> "$GITHUB_OUTPUT"
231+
191232
# Builds and tests Node.js with shared libraries against every supported
192233
# OpenSSL release version available in the repo-pinned nixpkgs. The default
193234
# shared `openssl` from tools/nix/sharedLibDeps.nix is overridden per matrix
194235
# entry, while all other shared libs remain at their defaults. Only runs on
195236
# a single runner/system (aarch64-linux) to keep the matrix to a minimum.
196237
build-openssl:
197238
needs:
198-
- build-tarball
239+
- build-aarch64-linux-v8
199240
- collect-openssl-versions
200241
strategy:
201242
fail-fast: false

tools/dep_updaters/update-nixpkgs-pin.sh

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,7 @@ TMP_FILE=$(mktemp)
2727
sed "s/$CURRENT_VERSION_SHA1/$NEW_UPSTREAM_SHA1/;s/$CURRENT_TARBALL_HASH/$NEW_TARBALL_HASH/" "$NIXPKGS_PIN_FILE" > "$TMP_FILE"
2828
mv "$TMP_FILE" "$NIXPKGS_PIN_FILE"
2929

30-
SUPPORTED_OPENSSL_VERSION=$(sed -nE "s/^[[:space:]]*SUPPORTED_OPENSSL_VERSION:[[:space:]]*'([^']+)'[[:space:]]*$/\1/p" "$TEST_SHARED_WORKFLOW_FILE" | head -n1)
31-
32-
if [ -z "$SUPPORTED_OPENSSL_VERSION" ]; then
33-
echo "Could not resolve SUPPORTED_OPENSSL_VERSION from $TEST_SHARED_WORKFLOW_FILE" >&2
34-
exit 1
35-
fi
36-
37-
SUPPORTED_OPENSSL_VERSION="$SUPPORTED_OPENSSL_VERSION" \
38-
"$BASE_DIR/tools/nix/collect-openssl-matrix.sh" | jq . > "$OPENSSL_MATRIX_FILE"
30+
"$BASE_DIR/tools/nix/collect-openssl-matrix.sh" | jq . > "$OPENSSL_MATRIX_FILE"
3931

4032
cat -<<EOF
4133
All done!

tools/nix/collect-openssl-matrix.sh

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,17 @@
66
# This helper is used by tools/dep_updaters/update-nixpkgs-pin.sh to
77
# regenerate tools/nix/openssl-matrix.json.
88
#
9-
# Inputs (env):
10-
# SUPPORTED_OPENSSL_VERSION Latest OpenSSL major.minor cycle we support
11-
# running tests with. Newer cycles are emitted
12-
# with "continue-on-error": true.
13-
#
149
# Output (stdout): a JSON array with shape
1510
# [{ "version": "3.6.1", "attr": "openssl_3_6", "continue-on-error": false }, ...]
1611
#
17-
# Usage: SUPPORTED_OPENSSL_VERSION=4.0 ./tools/nix/collect-openssl-matrix.sh
12+
# Usage: ./tools/nix/collect-openssl-matrix.sh
1813

1914
set -eu
2015

21-
: "${SUPPORTED_OPENSSL_VERSION:?SUPPORTED_OPENSSL_VERSION must be set}"
16+
# Latest OpenSSL major.minor cycle we support
17+
# running tests with. Newer cycles are emitted
18+
# with "continue-on-error": true.
19+
SUPPORTED_OPENSSL_VERSION=4.0
2220

2321
here=$(cd -- "$(dirname -- "$0")" && pwd)
2422

@@ -38,25 +36,16 @@ nix_json=$(nix-instantiate --eval --strict --json -E "
3836
in map (n: { attr = n; version = pkgs.\${n}.version; }) safe
3937
")
4038

41-
# 2. Resolve the OpenSSL version the `build` job already covers (the default
42-
# from sharedLibDeps.nix) so we can drop it from the matrix to avoid
43-
# duplicate coverage.
44-
default_openssl_version=$(nix-instantiate --eval --strict --json -E "
45-
(import $here/sharedLibDeps.nix {}).openssl.version
46-
" | jq -r .)
47-
48-
# 3. Fetch OpenSSL release versions from endoflife.date, keep entries that
39+
# 2. Fetch OpenSSL release versions from endoflife.date, keep entries that
4940
# are either not past EOL or still under extended support, then pick the
5041
# first nix attr whose `.version` starts with the release version
5142
# followed by `.` / letter / end-of-string (so "3.6" matches "3.6.1",
5243
# "1.1.1" matches "1.1.1w", and "1.1" does NOT swallow "1.1.1").
53-
# Releases without a matching nix attr and the one covered by default in
54-
# `build` are dropped.
44+
# Releases without a matching nix attr are dropped.
5545
curl -sf https://endoflife.date/api/openssl.json \
5646
| jq -c \
5747
--argjson nix "$nix_json" \
58-
--arg supported "$SUPPORTED_OPENSSL_VERSION" \
59-
--arg default_version "$default_openssl_version" '
48+
--arg supported "$SUPPORTED_OPENSSL_VERSION" '
6049
(now | strftime("%Y-%m-%d")) as $today |
6150
# Compare OpenSSL major.minor cycles as numeric tuples.
6251
def cycle_tuple($v):
@@ -68,7 +57,6 @@ curl -sf https://endoflife.date/api/openssl.json \
6857
| map(select(.version | test("^" + ($v | gsub("\\."; "\\.")) + "([.a-z]|$)")))
6958
| first) as $m
7059
| select($m != null)
71-
| select($m.version != $default_version)
7260
| {
7361
version: $m.version,
7462
attr: $m.attr,

tools/nix/openssl-matrix.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
"attr": "openssl_3_6",
1010
"continue-on-error": false
1111
},
12+
{
13+
"version": "3.5.5",
14+
"attr": "openssl_3_5",
15+
"continue-on-error": false
16+
},
1217
{
1318
"version": "3.0.19",
1419
"attr": "openssl_3",

0 commit comments

Comments
 (0)