Skip to content

Commit d5b076c

Browse files
committed
fix(ci): add WASM asset preparation before CI tests
- Add prepare-wasm job to restore WASM caches before CI runs - Upload WASM artifacts (yoga-layout, AI models, ONNX) for CI job - Add artifacts-to-download and artifacts-path to CI workflow inputs - Create directories with setup-script before downloading artifacts - Fixes ENOENT error for yoga.wasm during CLI build The CI was failing because yoga.wasm and other WASM assets weren't available during the build phase. These files are gitignored (in build/ directories) and must be restored from cache or built from source.
1 parent 7b2b3f7 commit d5b076c

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

.github/workflows/ci.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,81 @@ permissions:
3636
contents: read
3737

3838
jobs:
39+
prepare-wasm:
40+
name: Prepare WASM Assets
41+
runs-on: ubuntu-latest
42+
timeout-minutes: 10
43+
steps:
44+
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
45+
46+
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
47+
48+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
49+
with:
50+
node-version: 20
51+
cache: 'pnpm'
52+
53+
- name: Generate WASM cache keys
54+
id: wasm-cache-keys
55+
run: |
56+
YOGA_HASH=$(find packages/yoga-layout -type f \( -name "*.cpp" -o -name "*.h" -o -name "*.mjs" -o -name "CMakeLists.txt" \) | sort | xargs shasum -a 256 | shasum -a 256 | cut -d' ' -f1)
57+
echo "yoga-hash=$YOGA_HASH" >> $GITHUB_OUTPUT
58+
59+
AI_HASH=$(find packages/socketbin-cli-ai -type f \( -name "*.mjs" -o -name "*.ts" \) | sort | xargs shasum -a 256 | shasum -a 256 | cut -d' ' -f1)
60+
echo "ai-hash=$AI_HASH" >> $GITHUB_OUTPUT
61+
62+
ONNX_HASH=$(find packages/onnx-runtime-builder -type f \( -name "*.mjs" -o -name "*.patch" \) | sort | xargs shasum -a 256 | shasum -a 256 | cut -d' ' -f1)
63+
echo "onnx-hash=$ONNX_HASH" >> $GITHUB_OUTPUT
64+
65+
- name: Restore Yoga Layout WASM cache
66+
id: yoga-cache
67+
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
68+
with:
69+
path: packages/yoga-layout/build/wasm
70+
key: yoga-wasm-${{ steps.wasm-cache-keys.outputs.yoga-hash }}
71+
restore-keys: yoga-wasm-
72+
73+
- name: Restore AI models cache
74+
id: ai-cache
75+
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
76+
with:
77+
path: packages/socketbin-cli-ai/dist
78+
key: ai-models-${{ steps.wasm-cache-keys.outputs.ai-hash }}
79+
restore-keys: ai-models-
80+
81+
- name: Restore ONNX Runtime cache
82+
id: onnx-cache
83+
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
84+
with:
85+
path: packages/onnx-runtime-builder/dist
86+
key: onnx-runtime-${{ steps.wasm-cache-keys.outputs.onnx-hash }}
87+
restore-keys: onnx-runtime-
88+
89+
- name: Upload WASM artifacts for CI
90+
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
91+
with:
92+
name: wasm-assets
93+
path: |
94+
packages/yoga-layout/build/wasm/
95+
packages/socketbin-cli-ai/dist/
96+
packages/onnx-runtime-builder/dist/
97+
retention-days: 1
98+
3999
ci:
40100
name: Run CI Pipeline
101+
needs: prepare-wasm
41102
uses: SocketDev/socket-registry/.github/workflows/ci.yml@d8ff3b0581d799466cfbf150f715c1a4bf9f84a5 # 2025-10-23
42103
with:
104+
setup-script: 'mkdir -p packages/yoga-layout/build/wasm packages/socketbin-cli-ai/dist packages/onnx-runtime-builder/dist'
43105
test-setup-script: 'echo "=== Build Setup Debug ===" && pwd && echo "Before build:" && (ls -la packages/cli/ 2>/dev/null || dir packages\\cli\\ || true) && pnpm --filter @socketsecurity/cli run build && echo "After build:" && (ls -la packages/cli/dist/ 2>/dev/null || dir packages\\cli\\dist\\ || true) && echo "Checking cli.js:" && (ls -la packages/cli/dist/cli.js 2>/dev/null || dir packages\\cli\\dist\\cli.js || true) && echo "=== Build Setup Complete ==="'
44106
lint-script: 'pnpm --filter @socketsecurity/cli run check'
45107
type-check-script: 'pnpm --filter @socketsecurity/cli run type'
46108
test-script: ${{ inputs.skip-tests && 'echo "Tests skipped"' || 'pnpm --filter @socketsecurity/cli run test:unit' }}
47109
node-versions: ${{ inputs.node-versions || '[20, 22, 24]' }}
48110
os-versions: '["ubuntu-latest", "macos-latest", "windows-latest"]'
49111
fail-fast: false
112+
artifacts-to-download: 'wasm-assets'
113+
artifacts-path: '.'
50114

51115
e2e:
52116
name: E2E Tests

0 commit comments

Comments
 (0)