Skip to content

Commit 958ff1d

Browse files
thephezclaude
andauthored
fix(wasm-sdk): resolve test failures and optimize CI workflow (#2735)
Co-authored-by: Claude <[email protected]>
1 parent cfd9b57 commit 958ff1d

File tree

8 files changed

+236
-1261
lines changed

8 files changed

+236
-1261
lines changed

.github/workflows/wasm-sdk-build.yml

Lines changed: 127 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build WASM SDK
1+
name: Build and Test WASM SDK
22

33
on:
44
pull_request:
@@ -26,37 +26,42 @@ on:
2626
- 'packages/rs-context-provider/**'
2727
workflow_dispatch:
2828

29+
concurrency:
30+
group: ${{ github.workflow }}-${{ github.ref }}
31+
cancel-in-progress: true
32+
2933
env:
3034
CARGO_TERM_COLOR: always
3135
RUSTFLAGS: "-C lto=off"
3236
CARGO_PROFILE_RELEASE_LTO: false
37+
CI: true
3338

3439
jobs:
3540
build-wasm-sdk:
3641
runs-on: ubuntu-latest
37-
42+
3843
steps:
3944
- name: Checkout repository
4045
uses: actions/checkout@v4
41-
46+
4247
- name: Setup Rust toolchain
4348
uses: dtolnay/rust-toolchain@stable
4449
with:
4550
targets: wasm32-unknown-unknown
46-
47-
- name: Install protoc
51+
52+
- name: Install system dependencies (protoc, clang, llvm)
4853
run: |
54+
# Install protoc
4955
curl -Lo /tmp/protoc.zip \
5056
"https://github.com/protocolbuffers/protobuf/releases/download/v27.3/protoc-27.3-linux-x86_64.zip"
5157
unzip -o /tmp/protoc.zip -d ${HOME}/.local
5258
echo "${HOME}/.local/bin" >> $GITHUB_PATH
5359
export PATH="${PATH}:${HOME}/.local/bin"
54-
55-
- name: Install clang
56-
run: |
60+
61+
# Install clang and llvm
5762
sudo apt update -qq
5863
sudo apt install -qq --yes clang llvm
59-
64+
6065
- name: Cache cargo dependencies
6166
uses: actions/cache@v4
6267
with:
@@ -68,7 +73,7 @@ jobs:
6873
key: ${{ runner.os }}-cargo-wasm-sdk-${{ hashFiles('**/Cargo.lock') }}
6974
restore-keys: |
7075
${{ runner.os }}-cargo-wasm-sdk-
71-
76+
7277
- name: Install wasm-pack
7378
run: |
7479
if ! command -v wasm-pack &> /dev/null; then
@@ -77,15 +82,15 @@ jobs:
7782
else
7883
echo "wasm-pack already installed"
7984
fi
80-
85+
8186
- name: Install wasm-opt
8287
run: |
8388
if ! command -v wasm-opt &> /dev/null; then
8489
echo "Installing wasm-opt from GitHub releases..."
8590
# Get the latest release version
8691
WASM_OPT_VERSION=$(curl -s https://api.github.com/repos/WebAssembly/binaryen/releases/latest | grep -oP '"tag_name": "\K[^"]+')
8792
echo "Installing wasm-opt version: $WASM_OPT_VERSION"
88-
93+
8994
# Detect architecture
9095
ARCH=$(uname -m)
9196
if [ "$ARCH" = "x86_64" ]; then
@@ -96,31 +101,31 @@ jobs:
96101
echo "Unsupported architecture: $ARCH"
97102
exit 1
98103
fi
99-
104+
100105
echo "Detected architecture: $ARCH, using binaryen arch: $BINARYEN_ARCH"
101-
106+
102107
# Download and extract binaryen
103108
curl -L "https://github.com/WebAssembly/binaryen/releases/download/${WASM_OPT_VERSION}/binaryen-${WASM_OPT_VERSION}-${BINARYEN_ARCH}-linux.tar.gz" -o /tmp/binaryen.tar.gz
104109
tar -xzf /tmp/binaryen.tar.gz -C /tmp
105-
110+
106111
# Move wasm-opt to PATH
107112
sudo mv /tmp/binaryen-${WASM_OPT_VERSION}/bin/wasm-opt /usr/local/bin/
108113
sudo chmod +x /usr/local/bin/wasm-opt
109-
114+
110115
# Clean up
111116
rm -rf /tmp/binaryen.tar.gz /tmp/binaryen-${WASM_OPT_VERSION}
112-
117+
113118
echo "wasm-opt installed successfully"
114119
else
115120
echo "wasm-opt already installed"
116121
fi
117-
122+
118123
- name: Build WASM SDK
119124
working-directory: packages/wasm-sdk
120125
run: |
121126
chmod +x build.sh
122127
./build.sh
123-
128+
124129
- name: Verify build output
125130
working-directory: packages/wasm-sdk
126131
run: |
@@ -133,10 +138,111 @@ jobs:
133138
test -f pkg/wasm_sdk.d.ts
134139
test -f pkg/package.json
135140
echo "Build verification successful!"
136-
141+
137142
- name: Upload build artifacts
138143
uses: actions/upload-artifact@v4
139144
with:
140145
name: wasm-sdk-build
141146
path: packages/wasm-sdk/pkg/
142-
retention-days: 7
147+
retention-days: 7
148+
149+
test-wasm-sdk:
150+
runs-on: ubuntu-latest
151+
needs: build-wasm-sdk
152+
153+
steps:
154+
- name: Checkout test directory only
155+
uses: actions/checkout@v4
156+
with:
157+
sparse-checkout: |
158+
packages/wasm-sdk/test
159+
sparse-checkout-cone-mode: false
160+
161+
- name: Download WASM SDK build artifacts
162+
uses: actions/download-artifact@v4
163+
with:
164+
name: wasm-sdk-build
165+
path: packages/wasm-sdk/pkg/
166+
167+
- name: Verify WASM SDK artifacts
168+
working-directory: packages/wasm-sdk
169+
run: |
170+
echo "Verifying downloaded WASM SDK artifacts..."
171+
ls -lah pkg/
172+
173+
# Verify all required files exist
174+
required_files=(
175+
"pkg/wasm_sdk_bg.wasm"
176+
"pkg/optimized.wasm"
177+
"pkg/wasm_sdk.js"
178+
"pkg/wasm_sdk.d.ts"
179+
"pkg/package.json"
180+
)
181+
182+
for file in "${required_files[@]}"; do
183+
if [ ! -f "$file" ]; then
184+
echo "❌ Missing required file: $file"
185+
exit 1
186+
else
187+
echo "✅ Found: $file"
188+
fi
189+
done
190+
191+
echo "🎉 All WASM SDK artifacts verified successfully!"
192+
193+
- name: Setup Node.js
194+
uses: actions/setup-node@v4
195+
with:
196+
node-version: '20'
197+
198+
- name: Install test dependencies
199+
working-directory: packages/wasm-sdk/test
200+
run: |
201+
if [ -f package.json ]; then
202+
npm install
203+
fi
204+
205+
- name: Run comprehensive test suite
206+
working-directory: packages/wasm-sdk
207+
run: |
208+
echo "Running WASM SDK comprehensive test suite..."
209+
node test/run-all-tests.mjs | tee test-output.log
210+
211+
- name: Generate job summary
212+
if: always()
213+
working-directory: packages/wasm-sdk
214+
run: |
215+
echo "## 🧪 WASM SDK Test Results" >> $GITHUB_STEP_SUMMARY
216+
echo "" >> $GITHUB_STEP_SUMMARY
217+
218+
# Extract test results from the test output
219+
if [ -f test-output.log ]; then
220+
# Extract overall summary
221+
total_tests=$(grep -o "Total Tests: [0-9]*" test-output.log | grep -o "[0-9]*" || echo "0")
222+
total_passed=$(grep -o "Passed: [0-9]*" test-output.log | grep -o "[0-9]*" || echo "0")
223+
total_failed=$(grep -o "Failed: [0-9]*" test-output.log | grep -o "[0-9]*" || echo "0")
224+
total_time=$(grep -o "Time: [0-9]*\.[0-9]*s" test-output.log | grep -o "[0-9]*\.[0-9]*" || echo "0.00")
225+
226+
# Display overall summary
227+
echo "**$total_tests** tests • **$total_passed** passed • **$total_failed** failed • **${total_time}s**" >> $GITHUB_STEP_SUMMARY
228+
echo "" >> $GITHUB_STEP_SUMMARY
229+
230+
if [ "$total_failed" != "0" ]; then
231+
echo "❌ **Some tests failed** - Check the detailed test report for specifics" >> $GITHUB_STEP_SUMMARY
232+
else
233+
echo "✅ **All tests passed**" >> $GITHUB_STEP_SUMMARY
234+
fi
235+
else
236+
echo "⚠️ No test output captured" >> $GITHUB_STEP_SUMMARY
237+
fi
238+
239+
echo "" >> $GITHUB_STEP_SUMMARY
240+
echo "📦 **Artifacts**: WASM SDK build files and detailed test report available for download" >> $GITHUB_STEP_SUMMARY
241+
242+
- name: Upload test report
243+
if: always() && hashFiles('packages/wasm-sdk/test/test-report.html') != ''
244+
uses: actions/upload-artifact@v4
245+
with:
246+
name: wasm-sdk-test-report
247+
path: packages/wasm-sdk/test/test-report.html
248+
retention-days: 7

0 commit comments

Comments
 (0)