Skip to content

Commit 85900e8

Browse files
aduh95panva
authored andcommitted
tools: cache V8 builds in test-shared
1 parent a301de0 commit 85900e8

4 files changed

Lines changed: 64 additions & 38 deletions

File tree

.github/workflows/test-shared.yml

Lines changed: 50 additions & 9 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
@@ -149,8 +146,9 @@ jobs:
149146
include:
150147
- runner: ubuntu-24.04
151148
system: x86_64-linux
152-
- runner: ubuntu-24.04-arm
153-
system: aarch64-linux
149+
# built separately in build-aarch64-linux-v8
150+
# - runner: ubuntu-24.04-arm
151+
# system: aarch64-linux
154152
- runner: macos-15-intel
155153
system: x86_64-darwin
156154
- runner: macos-latest
@@ -169,6 +167,46 @@ jobs:
169167
system: ${{ matrix.system }}
170168
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
171169

170+
build-aarch64-linux-v8:
171+
needs: build-tarball
172+
runs-on: ubuntu-24.04-arm
173+
name: 'aarch64-linux: Cache V8 build'
174+
steps:
175+
- name: Check if Cachix is available
176+
id: cachix-check
177+
run: echo 'IS_AVAILABLE=${{ secrets.CACHIX_AUTH_TOKEN && 'true' }}' >> "$GITHUB_OUTPUT"
178+
179+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
180+
if: ${{ steps.cachix-check.outputs.IS_AVAILABLE == 'true' }}
181+
with:
182+
name: tarballs
183+
path: tarballs
184+
185+
- name: Extract tarball
186+
if: ${{ steps.cachix-check.outputs.IS_AVAILABLE == 'true' }}
187+
shell: bash
188+
run: |
189+
tar xzf tarballs/*.tar.gz -C "$RUNNER_TEMP"
190+
echo "TAR_DIR=$RUNNER_TEMP/$(basename tarballs/*.tar.gz .tar.gz)" >> "$GITHUB_ENV"
191+
192+
- uses: cachix/install-nix-action@96951a368ba55167b55f1c916f7d416bac6505fe # v31.10.3
193+
if: ${{ steps.cachix-check.outputs.IS_AVAILABLE == 'true' }}
194+
with:
195+
extra_nix_config: sandbox = true
196+
197+
- uses: cachix/cachix-action@1eb2ef646ac0255473d23a5907ad7b04ce94065c # v17
198+
if: ${{ steps.cachix-check.outputs.IS_AVAILABLE == 'true' }}
199+
with:
200+
name: nodejs
201+
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
202+
203+
- name: Build V8 derivation
204+
if: ${{ steps.cachix-check.outputs.IS_AVAILABLE == 'true' }}
205+
run: |
206+
nix-build "$(
207+
nix-instantiate -E "builtins.filter (p: p.pname == ''v8'') (import $TAR_DIR/shell.nix { useSeparateDerivationForV8=true; }).buildInputs"
208+
)"
209+
172210
# Builds the matrix for `build-openssl` from tools/nix/openssl-matrix.json.
173211
# Output shape:
174212
# [{ "version": "3.6.1", "attr": "openssl_3_6", "continue-on-error": false }, ...]
@@ -181,12 +219,15 @@ 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"
226+
{
227+
echo 'matrix<<EOF'
228+
cat tools/nix/openssl-matrix.json
229+
echo 'EOF'
230+
} >> "$GITHUB_OUTPUT"
190231
191232
# Builds and tests Node.js with shared libraries against every supported
192233
# OpenSSL release version available in the repo-pinned nixpkgs. The default
@@ -195,7 +236,7 @@ jobs:
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)