@@ -136,130 +136,224 @@ jobs:
136136 path : packages/yoga-layout/build/wasm/
137137 retention-days : 7
138138
139- # REMOVED: build-ai-models job
140- # AI models are now bundled directly in CLI, no longer using separate cli-ai package.
141- # When larger payloads require lazy-loading, we'll revisit @socketbin/cli-ai.
142-
143- # TEMPORARILY DISABLED: ONNX Runtime build issues.
144- # Re-enable once build script is working correctly.
145- # build-onnx-runtime:
146- # name: 🌐 Build ONNX Runtime WASM
147- # runs-on: ubuntu-latest
148- # timeout-minutes: 90
149- # steps:
150- # - name: Checkout
151- # uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
152-
153- # - name: Setup Node.js
154- # uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
155- # with:
156- # node-version: 22
157-
158- # - name: Setup pnpm
159- # uses: pnpm/action-setup@9fd676a19091d4595eefd76e4bd31c97133911f1 # v4.2.0
160- # with:
161- # version: ^10.16.0
162-
163- # - name: Install dependencies
164- # run: pnpm install --frozen-lockfile
165-
166- # - name: Generate ONNX Runtime cache key
167- # id: onnx-cache-key
168- # run: |
169- # # Extract ONNX Runtime version from package.json (package version matches ONNX Runtime release).
170- # ONNX_VERSION=$(node -p "require('./packages/onnxruntime/package.json').version")
171- # # Hash includes script files and package.json.
172- # HASH=$(find packages/onnxruntime -type f \( -name "*.mjs" -o -name "package.json" \) | sort | xargs sha256sum | sha256sum | cut -d' ' -f1)
173- # FULL_HASH="${HASH}-${ONNX_VERSION}"
174- # echo "hash=$FULL_HASH" >> $GITHUB_OUTPUT
175- # echo "ONNX Runtime version: v$ONNX_VERSION"
176-
177- # - name: Restore ONNX Runtime output cache
178- # id: onnx-cache
179- # uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
180- # with:
181- # path: packages/onnxruntime/build/wasm
182- # key: onnx-runtime-${{ steps.onnx-cache-key.outputs.hash }}
183- # restore-keys: onnx-runtime-
184- # enableCrossOsArchive: true
185-
186- # - name: Restore ONNX Runtime build cache
187- # id: onnx-build-cache
188- # uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
189- # with:
190- # path: packages/onnxruntime/build
191- # key: onnx-runtime-build-${{ steps.onnx-cache-key.outputs.hash }}
192- # restore-keys: |
193- # onnx-runtime-build-
194-
195- # - name: Verify cached artifacts
196- # id: onnx-cache-valid
197- # run: |
198- # if [ -f "packages/onnxruntime/build/wasm/ort-wasm-simd-threaded.wasm" ] && [ -f "packages/onnxruntime/build/wasm/ort-wasm-simd-threaded.js" ]; then
139+ build-models :
140+ name : 🤖 Build AI Models (INT4 Quantized)
141+ runs-on : ubuntu-latest
142+ timeout-minutes : 60
143+ steps :
144+ - name : Checkout
145+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
146+
147+ - name : Setup Node.js
148+ uses : actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
149+ with :
150+ node-version : 22
151+
152+ - name : Setup pnpm
153+ uses : pnpm/action-setup@9fd676a19091d4595eefd76e4bd31c97133911f1 # v4.2.0
154+ with :
155+ version : ^10.16.0
156+
157+ - name : Setup Python
158+ uses : actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
159+ with :
160+ python-version : ' 3.11'
161+
162+ - name : Install Python dependencies
163+ run : |
164+ echo "::group::Installing Python ML dependencies"
165+ pip install --no-cache-dir torch transformers
166+ pip install optimum[onnx] onnxruntime>=1.21.0
167+ echo "::endgroup::"
168+
169+ - name : Install dependencies
170+ run : pnpm install --frozen-lockfile
171+
172+ - name : Generate models cache key
173+ id : models-cache-key
174+ run : |
175+ HASH=$(find packages/models -type f \( -name "*.mjs" -o -name "package.json" \) | sort | xargs sha256sum | sha256sum | cut -d' ' -f1)
176+ echo "hash=$HASH" >> $GITHUB_OUTPUT
177+
178+ - name : Restore models cache
179+ id : models-cache
180+ uses : actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
181+ with :
182+ path : packages/models/dist
183+ key : models-${{ steps.models-cache-key.outputs.hash }}
184+ restore-keys : models-
185+ enableCrossOsArchive : true
186+
187+ - name : Verify cached artifacts
188+ id : models-cache-valid
189+ run : |
190+ if [ -f "packages/models/dist/minilm-l6.onnx" ] && [ -f "packages/models/dist/codet5-encoder.onnx" ]; then
191+ echo "valid=true" >> $GITHUB_OUTPUT
192+ echo "Cache hit: artifacts found"
193+ ls -lh packages/models/dist/
194+ else
195+ echo "valid=false" >> $GITHUB_OUTPUT
196+ echo "Cache miss or incomplete: forcing rebuild"
197+ ls -lh packages/models/dist/ 2>/dev/null || echo "Directory does not exist"
198+ fi
199+
200+ - name : Build AI models
201+ if : steps.models-cache-valid.outputs.valid != 'true' || inputs.force
202+ run : |
203+ echo "::group::Building INT4-quantized AI models"
204+ if [ "${{ inputs.force }}" = "true" ]; then
205+ pnpm --filter @socketsecurity/models run build -- --force
206+ else
207+ pnpm --filter @socketsecurity/models run build
208+ fi
209+ echo "Build exit code: $?"
210+ echo "Checking for build artifacts..."
211+ ls -lh packages/models/dist/ || echo "dist directory not found"
212+ echo "::endgroup::"
213+
214+ - name : Verify build artifacts
215+ run : |
216+ echo "=== AI Models Build Artifacts ==="
217+ if [ ! -f "packages/models/dist/minilm-l6.onnx" ]; then
218+ echo "ERROR: minilm-l6.onnx not found!"
219+ ls -lh packages/models/dist/ || echo "Directory does not exist"
220+ exit 1
221+ fi
222+ if [ ! -f "packages/models/dist/codet5-encoder.onnx" ]; then
223+ echo "ERROR: codet5-encoder.onnx not found!"
224+ exit 1
225+ fi
226+ ls -lh packages/models/dist/
227+ echo ""
228+ echo "minilm-l6.onnx size: $(du -h packages/models/dist/minilm-l6.onnx | cut -f1)"
229+ echo "codet5-encoder.onnx size: $(du -h packages/models/dist/codet5-encoder.onnx | cut -f1)"
230+ echo "codet5-decoder.onnx size: $(du -h packages/models/dist/codet5-decoder.onnx | cut -f1)"
231+
232+ - name : Upload models artifacts
233+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
234+ with :
235+ name : ai-models
236+ path : packages/models/dist/
237+ retention-days : 7
238+
239+ build-onnx-runtime :
240+ name : 🌐 Build ONNX Runtime WASM
241+ runs-on : ubuntu-latest
242+ timeout-minutes : 90
243+ steps :
244+ - name : Checkout
245+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
246+
247+ - name : Setup Node.js
248+ uses : actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
249+ with :
250+ node-version : 22
251+
252+ - name : Setup pnpm
253+ uses : pnpm/action-setup@9fd676a19091d4595eefd76e4bd31c97133911f1 # v4.2.0
254+ with :
255+ version : ^10.16.0
256+
257+ - name : Install dependencies
258+ run : pnpm install --frozen-lockfile
259+
260+ - name : Generate ONNX Runtime cache key
261+ id : onnx-cache-key
262+ run : |
263+ # Extract ONNX Runtime version from package.json (package version matches ONNX Runtime release).
264+ ONNX_VERSION=$(node -p "require('./packages/onnxruntime/package.json').version")
265+ # Hash includes script files and package.json.
266+ HASH=$(find packages/onnxruntime -type f \( -name "*.mjs" -o -name "package.json" \) | sort | xargs sha256sum | sha256sum | cut -d' ' -f1)
267+ FULL_HASH="${HASH}-${ONNX_VERSION}"
268+ echo "hash=$FULL_HASH" >> $GITHUB_OUTPUT
269+ echo "ONNX Runtime version: v$ONNX_VERSION"
270+
271+ - name : Restore ONNX Runtime output cache
272+ id : onnx-cache
273+ uses : actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
274+ with :
275+ path : packages/onnxruntime/build/wasm
276+ key : onnx-runtime-${{ steps.onnx-cache-key.outputs.hash }}
277+ restore-keys : onnx-runtime-
278+ enableCrossOsArchive : true
279+
280+ - name : Restore ONNX Runtime build cache
281+ id : onnx-build-cache
282+ uses : actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
283+ with :
284+ path : packages/onnxruntime/build
285+ key : onnx-runtime-build-${{ steps.onnx-cache-key.outputs.hash }}
286+ restore-keys : |
287+ onnx-runtime-build-
288+
289+ - name : Verify cached artifacts
290+ id : onnx-cache-valid
291+ run : |
292+ if [ -f "packages/onnxruntime/build/wasm/ort-wasm-simd-threaded.wasm" ] && [ -f "packages/onnxruntime/build/wasm/ort-wasm-simd-threaded.js" ]; then
199293 # echo "valid=true" >> $GITHUB_OUTPUT
200294 # echo "Cache hit: artifacts found"
201295 # ls -lh packages/onnxruntime/build/wasm/
202- # else
296+ else
203297 # echo "valid=false" >> $GITHUB_OUTPUT
204298 # echo "Cache miss or incomplete: forcing rebuild"
205299 # ls -lh packages/onnxruntime/build/wasm/ 2>/dev/null || echo "Directory does not exist"
206- # fi
207-
208- # - name: Install Emscripten
209- # if: steps.onnx-cache-valid.outputs.valid != 'true' || inputs.force
210- # run: |
211- # echo "::group::Installing Emscripten"
212- # git clone https://github.com/emscripten-core/emsdk.git
213- # cd emsdk
214- # ./emsdk install latest
215- # ./emsdk activate latest
216- # echo "::endgroup::"
217-
218- # - name: Build ONNX Runtime WASM
219- # if: steps.onnx-cache-valid.outputs.valid != 'true' || inputs.force
220- # run: |
221- # echo "::group::Building ONNX Runtime WASM (this will take 30-60 minutes)"
222- # source emsdk/emsdk_env.sh
223- # if [ "${{ inputs.force }}" = "true" ]; then
300+ fi
301+
302+ - name : Install Emscripten
303+ if : steps.onnx-cache-valid.outputs.valid != 'true' || inputs.force
304+ run : |
305+ echo "::group::Installing Emscripten"
306+ git clone https://github.com/emscripten-core/emsdk.git
307+ cd emsdk
308+ ./emsdk install latest
309+ ./emsdk activate latest
310+ echo "::endgroup::"
311+
312+ - name : Build ONNX Runtime WASM
313+ if : steps.onnx-cache-valid.outputs.valid != 'true' || inputs.force
314+ run : |
315+ echo "::group::Building ONNX Runtime WASM (this will take 30-60 minutes)"
316+ source emsdk/emsdk_env.sh
317+ if [ "${{ inputs.force }}" = "true" ]; then
224318 # pnpm --filter @socketsecurity/onnxruntime run build -- --force
225- # else
319+ else
226320 # pnpm --filter @socketsecurity/onnxruntime run build
227- # fi
228- # echo "Build exit code: $?"
229- # echo "Checking for build artifacts..."
230- # ls -lh packages/onnxruntime/build/wasm/ || echo "wasm directory not found"
231- # echo "::endgroup::"
232-
233- # - name: Save ONNX Runtime build cache
234- # if: always() && (steps.onnx-cache-valid.outputs.valid != 'true' || inputs.force)
235- # uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
236- # with:
237- # path: packages/onnxruntime/build
238- # key: onnx-runtime-build-${{ steps.onnx-cache-key.outputs.hash }}-${{ github.run_id }}
239-
240- # - name: Verify build artifacts
241- # run: |
242- # echo "=== ONNX Runtime Build Artifacts ==="
243- # if [ ! -f "packages/onnxruntime/build/wasm/ort-wasm-simd-threaded.wasm" ] || [ ! -f "packages/onnxruntime/build/wasm/ort-wasm-simd-threaded.js" ]; then
321+ fi
322+ echo "Build exit code: $?"
323+ echo "Checking for build artifacts..."
324+ ls -lh packages/onnxruntime/build/wasm/ || echo "wasm directory not found"
325+ echo "::endgroup::"
326+
327+ - name : Save ONNX Runtime build cache
328+ if : always() && (steps.onnx-cache-valid.outputs.valid != 'true' || inputs.force)
329+ uses : actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
330+ with :
331+ path : packages/onnxruntime/build
332+ key : onnx-runtime-build-${{ steps.onnx-cache-key.outputs.hash }}-${{ github.run_id }}
333+
334+ - name : Verify build artifacts
335+ run : |
336+ echo "=== ONNX Runtime Build Artifacts ==="
337+ if [ ! -f "packages/onnxruntime/build/wasm/ort-wasm-simd-threaded.wasm" ] || [ ! -f "packages/onnxruntime/build/wasm/ort-wasm-simd-threaded.js" ]; then
244338 # echo "ERROR: Required ONNX Runtime WASM artifacts not found!"
245339 # ls -lh packages/onnxruntime/build/wasm/ || echo "Directory does not exist"
246340 # exit 1
247- # fi
248- # ls -lh packages/onnxruntime/build/wasm/
249- # echo ""
250- # echo "ort-wasm-simd-threaded.wasm size: $(du -h packages/onnxruntime/build/wasm/ort-wasm-simd-threaded.wasm | cut -f1)"
251- # echo "ort-wasm-simd-threaded.js size: $(du -h packages/onnxruntime/build/wasm/ort-wasm-simd-threaded.js | cut -f1)"
252-
253- # - name: Upload ONNX Runtime artifacts
254- # uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
255- # with:
256- # name: onnx-runtime
257- # path: packages/onnxruntime/build/wasm/
258- # retention-days: 7
341+ fi
342+ ls -lh packages/onnxruntime/build/wasm/
343+ echo ""
344+ echo "ort-wasm-simd-threaded.wasm size: $(du -h packages/onnxruntime/build/wasm/ort-wasm-simd-threaded.wasm | cut -f1)"
345+ echo "ort-wasm-simd-threaded.js size: $(du -h packages/onnxruntime/build/wasm/ort-wasm-simd-threaded.js | cut -f1)"
346+
347+ - name : Upload ONNX Runtime artifacts
348+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
349+ with :
350+ name : onnx-runtime
351+ path : packages/onnxruntime/build/wasm/
352+ retention-days : 7
259353
260354 summary :
261355 name : 📊 🧱 WASM Build Summary
262- needs : [build-yoga-layout] # build-onnx-runtime and build-ai-models disabled
356+ needs : [build-yoga-layout, build-models, build-onnx-runtime]
263357 runs-on : ubuntu-latest
264358 steps :
265359 - name : Download all artifacts
@@ -280,6 +374,7 @@ jobs:
280374 echo "| Asset | Files |" >> $GITHUB_STEP_SUMMARY
281375 echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY
282376 echo "| 🧘 Yoga Layout | \`yoga.wasm\`, \`yoga.js\` |" >> $GITHUB_STEP_SUMMARY
377+ echo "| 🤖 AI Models | \`minilm-l6.onnx\` (INT4), \`codet5-encoder.onnx\` (INT4), \`codet5-decoder.onnx\` (INT4) |" >> $GITHUB_STEP_SUMMARY
283378 echo "| 🌐 ONNX Runtime | \`ort-wasm-simd-threaded.wasm\`, \`ort-wasm-simd-threaded.js\` |" >> $GITHUB_STEP_SUMMARY
284379 echo "" >> $GITHUB_STEP_SUMMARY
285380 echo "### 🎯 Next Steps" >> $GITHUB_STEP_SUMMARY
0 commit comments