-
Notifications
You must be signed in to change notification settings - Fork 3
73 lines (58 loc) · 2 KB
/
Copy pathwasm.yml
File metadata and controls
73 lines (58 loc) · 2 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
61
62
63
64
65
66
67
68
69
70
71
72
73
name: WASM
on:
pull_request:
branches: [main]
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
workflow_call:
concurrency:
group: wasm-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
wasm-build:
name: WASM Build and Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: Restore cargo registry cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: wasm
shared-key: lite-wasm
- name: Restore wasm-pack cache
uses: actions/cache@v4
with:
path: ~/.cache/wasm-pack
key: wasm-pack-${{ runner.os }}
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Check workspace for wasm32 target
run: cargo check --workspace --target wasm32-unknown-unknown
- name: Build WASM release
run: wasm-pack build --target web --release nodedb-lite-wasm
- name: Rewrite pkg/package.json metadata
working-directory: nodedb-lite-wasm/pkg
run: |
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
pkg.name = '@nodedb/lite';
pkg.version = '0.1.0';
pkg.license = 'Apache-2.0';
pkg.repository = { type: 'git', url: 'https://github.com/NodeDB-Lab/nodedb-lite' };
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
"
- name: Run WASM node tests
run: wasm-pack test --node nodedb-lite-wasm
- name: Install Chrome for browser tests
uses: browser-actions/setup-chrome@v1
- name: Run WASM browser tests (headless Chrome)
run: wasm-pack test --headless --chrome nodedb-lite-wasm