-
Notifications
You must be signed in to change notification settings - Fork 2
308 lines (266 loc) · 8.93 KB
/
build-and-test.yaml
File metadata and controls
308 lines (266 loc) · 8.93 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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
name: "Build and Test (Reusable)"
on:
workflow_call:
inputs:
upload-artifacts:
description: "Upload build artifacts"
type: boolean
default: false
upload-webui-artifact:
description: "Upload webui build artifact for pages deployment"
type: boolean
default: false
env:
RUST_TOOLCHAIN: nightly-2025-10-23
NODE_VERSION: 20
NPM_VERSION: 11.5.1
WASM_PACK_VERSION: 0.14.0
WASM_OPT_VERSION: 0.116.1
jobs:
detect-changes:
name: "Detect Changes"
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.set-matrix.outputs.packages }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
fetch-depth: 0
- name: Determine changed packages
id: set-matrix
env:
GITHUB_EVENT_NAME: ${{ github.event_name }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: node .github/scripts/detect-changes.mjs
build:
name: "Build"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
fetch-depth: 0
- 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
packages/wasm-mps
packages/wasm-solana
packages/wasm-dot
packages/wasm-ton
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/
packages/wasm-mps/dist/
packages/wasm-mps/js/wasm/
packages/wasm-solana/dist/
packages/wasm-solana/js/wasm/
packages/wasm-dot/dist/
packages/wasm-dot/js/wasm/
packages/wasm-ton/dist/
packages/wasm-ton/js/wasm/
retention-days: 1
- name: Upload webui artifact
if: inputs.upload-webui-artifact
uses: actions/upload-pages-artifact@v3
with:
path: packages/webui/dist
test:
name: "Test ${{ matrix.package }}"
needs: [detect-changes, build]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package: ${{ fromJson(needs.detect-changes.outputs.packages) }}
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
- package: wasm-mps
needs-wasm-pack: false
has-wasm-pack-tests: false
- package: wasm-solana
needs-wasm-pack: false
has-wasm-pack-tests: false
- package: wasm-dot
needs-wasm-pack: false
has-wasm-pack-tests: false
- package: wasm-ton
needs-wasm-pack: false
has-wasm-pack-tests: false
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
fetch-depth: 0
- 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 }}
fetch-depth: 0
- 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 wasm-mps build artifacts
if: inputs.upload-artifacts
uses: actions/upload-artifact@v4
with:
name: wasm-mps-build
path: |
packages/wasm-mps/pkg/
packages/wasm-mps/dist/
retention-days: 1
- name: Upload wasm-utxo 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
- name: Upload wasm-solana build artifacts
if: inputs.upload-artifacts
uses: actions/upload-artifact@v4
with:
name: wasm-solana-build
path: |
packages/wasm-solana/pkg/
packages/wasm-solana/dist/
retention-days: 1
- name: Upload wasm-dot build artifacts
if: inputs.upload-artifacts
uses: actions/upload-artifact@v4
with:
name: wasm-dot-build
path: |
packages/wasm-dot/pkg/
packages/wasm-dot/dist/
retention-days: 1
- name: Upload wasm-ton build artifacts
if: inputs.upload-artifacts
uses: actions/upload-artifact@v4
with:
name: wasm-ton-build
path: |
packages/wasm-ton/pkg/
packages/wasm-ton/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"