Skip to content

Commit 0db47ef

Browse files
committed
refactor(ci): use build-wasm workflow for WASM preparation
- Replace custom prepare-wasm job with existing build-wasm workflow - Add force-wasm-rebuild input to workflow_dispatch for cache bypass - Reuse build-wasm.yml's cache logic and artifact uploads - Download individual artifacts (yoga-wasm, ai-models, onnx-runtime) - Eliminates code duplication and improves maintainability The build-wasm workflow already handles cache restoration, conditional building, and artifact uploads. This approach is cleaner and allows forcing rebuilds via workflow_dispatch.
1 parent d5b076c commit 0db47ef

File tree

1 file changed

+12
-61
lines changed

1 file changed

+12
-61
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ on:
2626
required: false
2727
type: boolean
2828
default: false
29+
force-wasm-rebuild:
30+
description: 'Force WASM rebuild (ignore cache)'
31+
required: false
32+
type: boolean
33+
default: false
2934
node-versions:
3035
description: 'Node.js versions to test (JSON array)'
3136
required: false
@@ -36,69 +41,15 @@ permissions:
3641
contents: read
3742

3843
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
44+
build-wasm:
45+
name: Build WASM Assets
46+
uses: ./.github/workflows/build-wasm.yml
47+
with:
48+
force: ${{ inputs.force-wasm-rebuild || false }}
9849

9950
ci:
10051
name: Run CI Pipeline
101-
needs: prepare-wasm
52+
needs: build-wasm
10253
uses: SocketDev/socket-registry/.github/workflows/ci.yml@d8ff3b0581d799466cfbf150f715c1a4bf9f84a5 # 2025-10-23
10354
with:
10455
setup-script: 'mkdir -p packages/yoga-layout/build/wasm packages/socketbin-cli-ai/dist packages/onnx-runtime-builder/dist'
@@ -109,7 +60,7 @@ jobs:
10960
node-versions: ${{ inputs.node-versions || '[20, 22, 24]' }}
11061
os-versions: '["ubuntu-latest", "macos-latest", "windows-latest"]'
11162
fail-fast: false
112-
artifacts-to-download: 'wasm-assets'
63+
artifacts-to-download: 'yoga-wasm,ai-models,onnx-runtime'
11364
artifacts-path: '.'
11465

11566
e2e:

0 commit comments

Comments
 (0)