Skip to content

Commit 1e37c19

Browse files
committed
ci(build-infra): add explicit cache validation to SEA and smol builds
Add file existence checks for all cached assets in build-sea.yml and build-smol.yml workflows to match the robust validation pattern from build-wasm.yml. Benefits: - Earlier failure detection for corrupted or incomplete caches - Clear validation output (✓ valid / ✗ invalid) in workflow logs - Consistent cache checking patterns across all build workflows - Reduced wasted time on expensive setup when caches are invalid Changes to build-sea.yml: - Add Verify Yoga Layout cache step (checks yoga.wasm, yoga.js) - Add Verify AI models cache step (checks ai.bz, ai.js) - Add Verify ONNX Runtime cache step (checks onnxruntime-web.wasm) - Replace all cache-hit checks with validation outputs for WASM assets - Keep cache-hit checks for final SEA binary (verified in separate step) Changes to build-smol.yml: - Add Verify smol binary cache step (checks platform-specific binary) - Replace all cache-hit checks with validation output - Handle Windows .exe extension in validation logic
1 parent 5bd6edf commit 1e37c19

File tree

2 files changed

+74
-21
lines changed

2 files changed

+74
-21
lines changed

.github/workflows/build-sea.yml

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,27 +118,63 @@ jobs:
118118
key: onnx-runtime-${{ steps.wasm-cache-keys.outputs.onnx-hash }}
119119
restore-keys: onnx-runtime-
120120

121+
- name: Verify Yoga Layout cache
122+
id: yoga-cache-valid
123+
shell: bash
124+
run: |
125+
if [ -f "packages/yoga-layout/build/wasm/yoga.wasm" ] && [ -f "packages/yoga-layout/build/wasm/yoga.js" ]; then
126+
echo "valid=true" >> $GITHUB_OUTPUT
127+
echo "✓ Yoga Layout cache valid"
128+
else
129+
echo "valid=false" >> $GITHUB_OUTPUT
130+
echo "✗ Yoga Layout cache invalid or missing"
131+
fi
132+
133+
- name: Verify AI models cache
134+
id: ai-cache-valid
135+
shell: bash
136+
run: |
137+
if [ -f "packages/socketbin-cli-ai/dist/ai.bz" ] && [ -f "packages/socketbin-cli-ai/dist/ai.js" ]; then
138+
echo "valid=true" >> $GITHUB_OUTPUT
139+
echo "✓ AI models cache valid"
140+
else
141+
echo "valid=false" >> $GITHUB_OUTPUT
142+
echo "✗ AI models cache invalid or missing"
143+
fi
144+
145+
- name: Verify ONNX Runtime cache
146+
id: onnx-cache-valid
147+
shell: bash
148+
run: |
149+
if [ -f "packages/onnx-runtime-builder/dist/onnxruntime-web.wasm" ]; then
150+
echo "valid=true" >> $GITHUB_OUTPUT
151+
echo "✓ ONNX Runtime cache valid"
152+
else
153+
echo "valid=false" >> $GITHUB_OUTPUT
154+
echo "✗ ONNX Runtime cache invalid or missing"
155+
fi
156+
121157
- name: Setup Python for WASM builds
122-
if: steps.yoga-cache.outputs.cache-hit != 'true' || steps.ai-cache.outputs.cache-hit != 'true' || steps.onnx-cache.outputs.cache-hit != 'true'
158+
if: steps.yoga-cache-valid.outputs.valid != 'true' || steps.ai-cache-valid.outputs.valid != 'true' || steps.onnx-cache-valid.outputs.valid != 'true'
123159
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
124160
with:
125161
python-version: '3.11'
126162

127163
- name: Build WASM assets on cache miss
128-
if: steps.yoga-cache.outputs.cache-hit != 'true' || steps.ai-cache.outputs.cache-hit != 'true' || steps.onnx-cache.outputs.cache-hit != 'true'
164+
if: steps.yoga-cache-valid.outputs.valid != 'true' || steps.ai-cache-valid.outputs.valid != 'true' || steps.onnx-cache-valid.outputs.valid != 'true'
129165
shell: bash
130166
run: |
131167
echo "⚠️ WASM cache miss detected - building from source"
132168
echo "This will take 30-60 minutes. Consider running build-wasm.yml workflow to prime cache."
133169
echo ""
134170
echo "Cache status:"
135-
echo " Yoga Layout: ${{ steps.yoga-cache.outputs.cache-hit == 'true' && '✓ cached' || '✗ missing' }}"
136-
echo " AI Models: ${{ steps.ai-cache.outputs.cache-hit == 'true' && '✓ cached' || '✗ missing' }}"
137-
echo " ONNX Runtime: ${{ steps.onnx-cache.outputs.cache-hit == 'true' && '✓ cached' || '✗ missing' }}"
171+
echo " Yoga Layout: ${{ steps.yoga-cache-valid.outputs.valid == 'true' && '✓ cached' || '✗ missing' }}"
172+
echo " AI Models: ${{ steps.ai-cache-valid.outputs.valid == 'true' && '✓ cached' || '✗ missing' }}"
173+
echo " ONNX Runtime: ${{ steps.onnx-cache-valid.outputs.valid == 'true' && '✓ cached' || '✗ missing' }}"
138174
echo ""
139175
140176
# Install Emscripten if needed for Yoga/ONNX.
141-
if [ "${{ steps.yoga-cache.outputs.cache-hit }}" != "true" ] || [ "${{ steps.onnx-cache.outputs.cache-hit }}" != "true" ]; then
177+
if [ "${{ steps.yoga-cache-valid.outputs.valid }}" != "true" ] || [ "${{ steps.onnx-cache-valid.outputs.valid }}" != "true" ]; then
142178
echo "::group::Installing Emscripten"
143179
git clone https://github.com/emscripten-core/emsdk.git
144180
cd emsdk
@@ -160,27 +196,27 @@ jobs:
160196
fi
161197
162198
# Install Python deps if needed for AI models.
163-
if [ "${{ steps.ai-cache.outputs.cache-hit }}" != "true" ]; then
199+
if [ "${{ steps.ai-cache-valid.outputs.valid }}" != "true" ]; then
164200
echo "::group::Installing Python dependencies"
165201
python3 -m pip install --upgrade pip
166202
python3 -m pip install transformers torch optimum[onnx] "onnxruntime>=1.20.0"
167203
echo "::endgroup::"
168204
fi
169205
170206
# Build missing WASM assets.
171-
if [ "${{ steps.yoga-cache.outputs.cache-hit }}" != "true" ]; then
207+
if [ "${{ steps.yoga-cache-valid.outputs.valid }}" != "true" ]; then
172208
echo "::group::Building Yoga Layout WASM"
173209
pnpm --filter @socketsecurity/yoga-layout run build
174210
echo "::endgroup::"
175211
fi
176212
177-
if [ "${{ steps.ai-cache.outputs.cache-hit }}" != "true" ]; then
213+
if [ "${{ steps.ai-cache-valid.outputs.valid }}" != "true" ]; then
178214
echo "::group::Building AI models (10-15 minutes)"
179215
pnpm --filter @socketbin/cli-ai run build
180216
echo "::endgroup::"
181217
fi
182218
183-
if [ "${{ steps.onnx-cache.outputs.cache-hit }}" != "true" ]; then
219+
if [ "${{ steps.onnx-cache-valid.outputs.valid }}" != "true" ]; then
184220
echo "::group::Building ONNX Runtime (20-30 minutes)"
185221
pnpm --filter @socketsecurity/onnx-runtime-builder run build
186222
echo "::endgroup::"
@@ -204,7 +240,7 @@ jobs:
204240
restore-keys: node-sea-${{ matrix.platform }}-${{ matrix.arch }}-
205241

206242
- name: Check WASM cache requirements (Windows)
207-
if: matrix.os == 'windows' && (steps.yoga-cache.outputs.cache-hit != 'true' || steps.ai-cache.outputs.cache-hit != 'true' || steps.onnx-cache.outputs.cache-hit != 'true')
243+
if: matrix.os == 'windows' && (steps.yoga-cache-valid.outputs.valid != 'true' || steps.ai-cache-valid.outputs.valid != 'true' || steps.onnx-cache-valid.outputs.valid != 'true')
208244
run: |
209245
echo "::error::WASM assets not cached for Windows build. Run build-wasm.yml workflow first to prime the cache."
210246
echo "Windows builds require pre-cached WASM assets due to network reliability issues."

.github/workflows/build-smol.yml

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,31 @@ jobs:
112112
key: node-smol-${{ matrix.platform }}-${{ matrix.arch }}-${{ steps.smol-cache-key.outputs.hash }}
113113
restore-keys: node-smol-${{ matrix.platform }}-${{ matrix.arch }}-
114114

115+
- name: Verify smol binary cache
116+
id: smol-cache-valid
117+
shell: bash
118+
run: |
119+
BINARY_PATH="packages/node-smol-builder/dist/socket-smol-${{ matrix.platform }}-${{ matrix.arch }}"
120+
if [ "${{ matrix.os }}" = "windows" ]; then
121+
BINARY_PATH="${BINARY_PATH}.exe"
122+
fi
123+
124+
if [ -f "$BINARY_PATH" ]; then
125+
echo "valid=true" >> $GITHUB_OUTPUT
126+
echo "✓ Smol binary cache valid: $BINARY_PATH"
127+
else
128+
echo "valid=false" >> $GITHUB_OUTPUT
129+
echo "✗ Smol binary cache invalid or missing: $BINARY_PATH"
130+
fi
131+
115132
- name: Setup Python
116-
if: steps.smol-cache.outputs.cache-hit != 'true' || inputs.force
133+
if: steps.smol-cache-valid.outputs.valid != 'true' || inputs.force
117134
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
118135
with:
119136
python-version: '3.11'
120137

121138
- name: Verify Python installation
122-
if: steps.smol-cache.outputs.cache-hit != 'true' || inputs.force
139+
if: steps.smol-cache-valid.outputs.valid != 'true' || inputs.force
123140
shell: bash
124141
run: |
125142
echo "Python version:"
@@ -128,25 +145,25 @@ jobs:
128145
echo "PATH=$PATH"
129146
130147
- name: Install build dependencies (Ubuntu)
131-
if: (steps.smol-cache.outputs.cache-hit != 'true' || inputs.force) && matrix.platform == 'linux'
148+
if: (steps.smol-cache-valid.outputs.valid != 'true' || inputs.force) && matrix.platform == 'linux'
132149
run: |
133150
sudo apt-get update
134151
sudo apt-get install -y build-essential gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
135152
136153
- name: Cache Ninja (Ubuntu)
137-
if: (steps.smol-cache.outputs.cache-hit != 'true' || inputs.force) && matrix.platform == 'linux'
154+
if: (steps.smol-cache-valid.outputs.valid != 'true' || inputs.force) && matrix.platform == 'linux'
138155
id: ninja-cache-ubuntu
139156
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
140157
with:
141158
path: /usr/bin/ninja
142159
key: ninja-ubuntu-${{ runner.os }}-${{ runner.arch }}
143160

144161
- name: Install Ninja (Ubuntu)
145-
if: (steps.smol-cache.outputs.cache-hit != 'true' || inputs.force) && matrix.platform == 'linux' && steps.ninja-cache-ubuntu.outputs.cache-hit != 'true'
162+
if: (steps.smol-cache-valid.outputs.valid != 'true' || inputs.force) && matrix.platform == 'linux' && steps.ninja-cache-ubuntu.outputs.cache-hit != 'true'
146163
run: sudo apt-get install -y ninja-build
147164

148165
- name: Cache Ninja (macOS)
149-
if: (steps.smol-cache.outputs.cache-hit != 'true' || inputs.force) && matrix.platform == 'darwin'
166+
if: (steps.smol-cache-valid.outputs.valid != 'true' || inputs.force) && matrix.platform == 'darwin'
150167
id: ninja-cache-macos
151168
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
152169
with:
@@ -156,23 +173,23 @@ jobs:
156173
key: ninja-macos-${{ runner.os }}-${{ runner.arch }}
157174

158175
- name: Install Ninja (macOS)
159-
if: (steps.smol-cache.outputs.cache-hit != 'true' || inputs.force) && matrix.platform == 'darwin' && steps.ninja-cache-macos.outputs.cache-hit != 'true'
176+
if: (steps.smol-cache-valid.outputs.valid != 'true' || inputs.force) && matrix.platform == 'darwin' && steps.ninja-cache-macos.outputs.cache-hit != 'true'
160177
run: brew install ninja
161178

162179
- name: Cache Ninja (Windows)
163-
if: (steps.smol-cache.outputs.cache-hit != 'true' || inputs.force) && matrix.platform == 'win32'
180+
if: (steps.smol-cache-valid.outputs.valid != 'true' || inputs.force) && matrix.platform == 'win32'
164181
id: ninja-cache-windows
165182
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
166183
with:
167184
path: C:\ProgramData\chocolatey\bin\ninja.exe
168185
key: ninja-windows-${{ runner.os }}-${{ runner.arch }}
169186

170187
- name: Install Ninja (Windows)
171-
if: (steps.smol-cache.outputs.cache-hit != 'true' || inputs.force) && matrix.platform == 'win32' && steps.ninja-cache-windows.outputs.cache-hit != 'true'
188+
if: (steps.smol-cache-valid.outputs.valid != 'true' || inputs.force) && matrix.platform == 'win32' && steps.ninja-cache-windows.outputs.cache-hit != 'true'
172189
run: choco install ninja
173190

174191
- name: Build smol binary
175-
if: steps.smol-cache.outputs.cache-hit != 'true' || inputs.force
192+
if: steps.smol-cache-valid.outputs.valid != 'true' || inputs.force
176193
run: pnpm --filter @socketbin/node-smol-builder run build
177194

178195
- name: Verify smol binary

0 commit comments

Comments
 (0)