-
Notifications
You must be signed in to change notification settings - Fork 2
212 lines (177 loc) · 5.94 KB
/
build-and-test.yaml
File metadata and controls
212 lines (177 loc) · 5.94 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: "Build and Test (Reusable)"
on:
workflow_call:
inputs:
upload-artifacts:
description: "Upload build artifacts"
type: boolean
default: false
env:
RUST_TOOLCHAIN: nightly-2025-10-23
NODE_VERSION: 20
NPM_VERSION: 11.5.1
WASM_PACK_VERSION: 0.13.1
WASM_OPT_VERSION: 0.116.1
jobs:
build:
name: "Build"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Install Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt, clippy
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
with:
workspaces: |
packages/wasm-utxo
packages/wasm-bip32
cache-on-failure: true
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install npm and wasm tools
run: |
npm install -g npm@${{ env.NPM_VERSION }}
cargo install wasm-pack --version ${{ env.WASM_PACK_VERSION }}
cargo install wasm-opt --version ${{ env.WASM_OPT_VERSION }}
cargo install cargo-deny --locked
- name: Build Info
run: |
echo "node $(node --version)"
echo "npm $(npm --version)"
echo "rustc $(rustc --version)"
echo "wasm-pack $(wasm-pack --version)"
echo "wasm-opt $(wasm-opt --version)"
echo "cargo-deny $(cargo deny --version)"
- name: Fetch Base Ref
if: github.event_name == 'pull_request'
run: git fetch origin $GITHUB_BASE_REF
- name: Install Packages
run: npm ci --workspaces --include-workspace-root
- name: Check dependencies with cargo-deny
run: cargo deny check
working-directory: packages/wasm-utxo
- name: Build packages
run: npm --workspaces run build
- name: Check Source Code Formatting
run: npm run check-fmt
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-output
path: |
packages/wasm-utxo/dist/
packages/wasm-utxo/js/wasm/
packages/wasm-bip32/dist/
packages/wasm-bip32/js/wasm/
retention-days: 1
test:
name: "Test ${{ matrix.package }}"
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package: [wasm-bip32, wasm-utxo]
include:
- package: wasm-utxo
needs-wasm-pack: true
has-wasm-pack-tests: true
- package: wasm-bip32
needs-wasm-pack: false
has-wasm-pack-tests: false
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Install Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt, clippy
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
with:
workspaces: packages/${{ matrix.package }}
cache-on-failure: true
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install npm
run: npm install -g npm@${{ env.NPM_VERSION }}
- name: Install wasm-pack
if: matrix.needs-wasm-pack
run: cargo install wasm-pack --version ${{ env.WASM_PACK_VERSION }}
- name: Install Packages
run: npm ci --workspaces --include-workspace-root
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-output
path: packages/
- name: Lint
run: npm run lint
working-directory: packages/${{ matrix.package }}
- name: Cargo Test
run: cargo test --workspace
working-directory: packages/${{ matrix.package }}
- name: Wasm-Pack Test (Node)
if: matrix.has-wasm-pack-tests
run: npm run test:wasm-pack-node
working-directory: packages/${{ matrix.package }}
- name: Wasm-Pack Test (Chrome)
if: matrix.has-wasm-pack-tests
run: npm run test:wasm-pack-chrome
working-directory: packages/${{ matrix.package }}
- name: Unit Test
run: npm test
working-directory: packages/${{ matrix.package }}
finalize:
name: "Finalize"
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install npm
run: npm install -g npm@${{ env.NPM_VERSION }}
- name: Install Packages
run: npm ci --workspaces --include-workspace-root
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-output
path: packages/
- name: webui / Unit Test
run: npm test
working-directory: packages/webui
- name: Upload final build artifacts
if: inputs.upload-artifacts
uses: actions/upload-artifact@v4
with:
name: wasm-utxo-build
path: |
packages/wasm-utxo/pkg/
packages/wasm-utxo/dist/
retention-days: 1
# This job provides a stable "test / Test" status check for branch protection.
# It runs after all other jobs complete successfully.
gate:
name: "Test"
needs: [build, test, finalize]
runs-on: ubuntu-latest
steps:
- run: echo "All checks passed"