-
Notifications
You must be signed in to change notification settings - Fork 26
60 lines (47 loc) · 1.56 KB
/
wasm.yml
File metadata and controls
60 lines (47 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: WASM Build
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
wasm_build:
name: Build WASM
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v5
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: Cache Cargo
uses: Swatinem/rust-cache@v2
with:
# Only save cache from main branch to prevent cache proliferation
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Build WASM
run: cargo build --package pcb-zen-wasm --target wasm32-unknown-unknown --release
- name: Check WASM artifact size
run: |
WASM_FILE="target/wasm32-unknown-unknown/release/pcb_zen_wasm.wasm"
if [ ! -f "$WASM_FILE" ]; then
echo "Error: WASM artifact not found"
exit 1
fi
# Get file size in bytes
SIZE=$(stat -c%s "$WASM_FILE" 2>/dev/null || stat -f%z "$WASM_FILE")
SIZE_MB=$((SIZE / 1024 / 1024))
echo "WASM bundle size: ${SIZE_MB}MB"
ls -lh "$WASM_FILE"
# Fail if size exceeds 30MB
if [ $SIZE -gt 31457280 ]; then
echo "Error: WASM bundle is too large (${SIZE_MB}MB > 30MB)"
exit 1
fi
echo "WASM build successful! Size is within limits."