Skip to content

Commit bac3821

Browse files
committed
ci(integration): test SEA and smol binaries from cache
Update integration test to check for and test all available binary distributions instead of only JS: - Always test JS distribution (built fresh) - Test SEA binary if cached from build-sea.yml workflow - Test smol binary if cached from build-smol.yml workflow Implementation: - Generate cache keys matching build-sea.yml and build-smol.yml - Restore cached binaries using actions/cache/restore - Copy platform-specific binaries to test-expected locations - Run integration tests with --all flag This provides comprehensive integration coverage when cached binaries are available, while gracefully handling cache misses.
1 parent 3387b32 commit bac3821

1 file changed

Lines changed: 84 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 84 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,14 @@ jobs:
7575
# Binary distribution integration tests.
7676
# Tests the JS distribution and optionally SEA/smol if cached binaries are available.
7777
integration:
78-
name: Integration Tests (${{ matrix.distribution }})
78+
name: Integration Tests
7979
needs: ci
8080
runs-on: ubuntu-latest
8181
timeout-minutes: 15
8282
strategy:
8383
fail-fast: false
8484
matrix:
8585
node-version: ['24.10.0']
86-
distribution: ['js']
8786
steps:
8887
- uses: SocketDev/socket-registry/.github/actions/setup-and-install@1a96ced97aaa85d61543351b90d6f463b983c46c # main
8988
with:
@@ -93,9 +92,90 @@ jobs:
9392
working-directory: packages/cli
9493
run: pnpm run build
9594

96-
- name: Run integration tests (${{ matrix.distribution }})
95+
- name: Generate cache keys for binary distributions
96+
id: cache-keys
97+
shell: bash
98+
run: |
99+
# SEA cache key (matches build-sea.yml).
100+
SEA_HASH=$(find packages/node-sea-builder packages/cli/src -type f \( -name "*.mts" -o -name "*.ts" -o -name "*.mjs" -o -name "*.js" \) 2>/dev/null | sort | xargs sha256sum 2>/dev/null | sha256sum | cut -d' ' -f1 || echo "none")
101+
DEPS_HASH=$(find packages/bootstrap packages/socket -type f \( -name "*.mts" -o -name "*.ts" -o -name "*.mjs" -o -name "*.js" -o -name "*.json" \) ! -path "*/node_modules/*" ! -path "*/dist/*" ! -path "*/build/*" 2>/dev/null | sort | xargs sha256sum 2>/dev/null | sha256sum | cut -d' ' -f1 || echo "none")
102+
LOCK_HASH=$(sha256sum pnpm-lock.yaml 2>/dev/null | cut -d' ' -f1 || echo "none")
103+
SEA_DEPS_HASH=$(echo "$DEPS_HASH-$LOCK_HASH" | sha256sum | cut -d' ' -f1)
104+
SEA_COMBINED=$(echo "$SEA_HASH-$SEA_DEPS_HASH" | sha256sum | cut -d' ' -f1)
105+
echo "sea-hash=$SEA_COMBINED" >> $GITHUB_OUTPUT
106+
107+
# Smol cache key (matches build-smol.yml).
108+
SMOL_HASH=$(find patches packages/node-smol-builder/patches packages/node-smol-builder/additions scripts -type f \( -name "*.patch" -o -name "*.template.patch" -o -name "*.mjs" -o -name "*.template.mjs" -o -name "*.h" -o -name "*.c" -o -name "*.cc" \) 2>/dev/null | sort | xargs sha256sum 2>/dev/null | sha256sum | cut -d' ' -f1 || echo "none")
109+
SMOL_DEPS_HASH=$(echo "$DEPS_HASH-$LOCK_HASH" | sha256sum | cut -d' ' -f1)
110+
SMOL_COMBINED=$(echo "$SMOL_HASH-$SMOL_DEPS_HASH" | sha256sum | cut -d' ' -f1)
111+
echo "smol-hash=$SMOL_COMBINED" >> $GITHUB_OUTPUT
112+
113+
- name: Restore SEA binary cache
114+
id: sea-cache
115+
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
116+
with:
117+
path: packages/node-sea-builder/dist/
118+
key: node-sea-linux-x64-${{ steps.cache-keys.outputs.sea-hash }}
119+
restore-keys: node-sea-linux-x64-
120+
121+
- name: Restore smol binary cache
122+
id: smol-cache
123+
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
124+
with:
125+
path: packages/node-smol-builder/dist/
126+
key: node-smol-linux-x64-${{ steps.cache-keys.outputs.smol-hash }}
127+
restore-keys: node-smol-linux-x64-
128+
129+
- name: Setup cached binaries for testing
130+
id: setup-binaries
131+
shell: bash
132+
run: |
133+
echo "Setting up cached binaries for integration tests..."
134+
echo ""
135+
136+
# Copy SEA binary from cache to expected test location.
137+
SEA_CACHED="packages/node-sea-builder/dist/sea/socket-linux-x64"
138+
SEA_TARGET="packages/node-sea-builder/dist/socket-sea"
139+
if [ -f "$SEA_CACHED" ]; then
140+
mkdir -p "$(dirname "$SEA_TARGET")"
141+
cp "$SEA_CACHED" "$SEA_TARGET"
142+
chmod +x "$SEA_TARGET"
143+
echo "✓ SEA binary restored from cache: $SEA_TARGET"
144+
echo "sea=true" >> $GITHUB_OUTPUT
145+
else
146+
echo "✗ SEA binary not found in cache (expected: $SEA_CACHED)"
147+
echo "sea=false" >> $GITHUB_OUTPUT
148+
fi
149+
150+
# Copy smol binary from cache to expected test location.
151+
SMOL_CACHED="packages/node-smol-builder/dist/socket-smol-linux-x64"
152+
SMOL_TARGET="packages/node-smol-builder/dist/socket-smol"
153+
if [ -f "$SMOL_CACHED" ]; then
154+
mkdir -p "$(dirname "$SMOL_TARGET")"
155+
cp "$SMOL_CACHED" "$SMOL_TARGET"
156+
chmod +x "$SMOL_TARGET"
157+
echo "✓ Smol binary restored from cache: $SMOL_TARGET"
158+
echo "smol=true" >> $GITHUB_OUTPUT
159+
else
160+
echo "✗ Smol binary not found in cache (expected: $SMOL_CACHED)"
161+
echo "smol=false" >> $GITHUB_OUTPUT
162+
fi
163+
164+
# JS distribution (always available after build).
165+
if [ -f "packages/cli/dist/index.js" ]; then
166+
echo "✓ JS distribution: packages/cli/dist/index.js"
167+
echo "js=true" >> $GITHUB_OUTPUT
168+
else
169+
echo "✗ JS distribution: not found"
170+
echo "js=false" >> $GITHUB_OUTPUT
171+
fi
172+
173+
echo ""
174+
echo "Integration tests will run against all available distributions."
175+
176+
- name: Run integration tests (all available distributions)
97177
working-directory: packages/cli
98-
run: node scripts/integration.mjs --${{ matrix.distribution }}
178+
run: node scripts/integration.mjs --all
99179

100180
e2e:
101181
name: E2E Tests

0 commit comments

Comments
 (0)