-
Notifications
You must be signed in to change notification settings - Fork 111
603 lines (517 loc) · 19.7 KB
/
main.yml
File metadata and controls
603 lines (517 loc) · 19.7 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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
name: test
on:
merge_group:
push:
branches:
- main
pull_request:
branches:
- main
defaults:
run:
shell: bash
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "latest"
- name: Install Rust
run: rustup update stable --no-self-update
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
with:
shared-key: jco-${{ hashFiles('Cargo.lock') }}
- name: Cache npm install
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
path: |
node_modules
- name: Install NPM packages
run: npm install
- name: Build jco
run: npm run build
- name: Build rust test components
run: npm run build:test:components
- name: Upload jco build
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: jco-build
path: |
packages/jco/obj
- name: Upload jco test components
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: jco-test-components
path: |
packages/jco/test/output/rust-test-components
- name: Build jco-transpile
run: npm run build -w @bytecodealliance/jco-transpile
- name: Upload jco-transpile vendor
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: jco-transpile-vendor
path: |
packages/jco-transpile/vendor
test-jco:
runs-on: ${{ matrix.os }}
needs:
- build
strategy:
matrix:
os:
- ubuntu-22.04 # https://github.com/puppeteer/puppeteer/issues/12818#issuecomment-2593659514
- windows-2025
- macos-latest
node:
- 18.x
- 20.x
- 22.x
- latest
include:
- os: windows-2025
weval-bin-path: .weval-bin/weval.exe
- os: ubuntu-22.04
weval-bin-path: .weval-bin/weval
- os: macos-latest
weval-bin-path: .weval-bin/weval
exclude:
- os: macos-latest
node: 20.x
- os: macos-latest
node: 18.x
- os: windows-2025
node: latest
- os: windows-2025
node: 18.x
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ matrix.node }}
- uses: taiki-e/cache-cargo-install-action@f9eed3e4680f27610dc6d8c67be1b88593f7dade # v3.0.6
with:
tool: wasm-tools@1.244.0
# Determine weval version
- name: Determine weval version
id: weval-meta
shell: bash
run: |
export WEVAL_LATEST_URL=`curl -Ls -o /dev/null -w %{url_effective} https://github.com/bytecodealliance/weval/releases/latest`
export WEVAL_VERSION=${WEVAL_LATEST_URL#https://github.com/bytecodealliance/weval/releases/tag/}
echo -e "version=$WEVAL_VERSION" >> $GITHUB_OUTPUT
# Use cached weval bin if present
- name: Cache weval bin
id: cache-weval-bin
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: .weval-bin
key: weval-bin-${{ steps.weval-meta.outputs.version }}-${{ matrix.os }}
# (no cached weval bin) download weval release
- if: ${{ steps.cache-weval-bin.outputs.cache-hit != 'true' && matrix.os == 'ubuntu-latest' }}
run: |
curl -LO https://github.com/bytecodealliance/weval/releases/download/${{ steps.weval-meta.outputs.version }}/weval-${{ steps.weval-meta.outputs.version }}-x86_64-linux.tar.xz
tar -xvJf weval-${{ steps.weval-meta.outputs.version }}-x86_64-linux.tar.xz
mv weval-${{ steps.weval-meta.outputs.version }}-x86_64-linux/weval .weval-bin
- if: ${{ steps.cache-weval-bin.outputs.cache-hit != 'true' && matrix.os == 'windows-2025' }}
run: |
curl -LO https://github.com/bytecodealliance/weval/releases/download/${{ steps.weval-meta.outputs.version }}/weval-${{ steps.weval-meta.outputs.version }}-x86_64-windows.zip
unzip weval-${{ steps.weval-meta.outputs.version }}-x86_64-windows.zip
mv weval-${{ steps.weval-meta.outputs.version }}-x86_64-windows .weval-bin
- if: ${{ steps.cache-weval-bin.outputs.cache-hit != 'true' && matrix.os == 'macos-latest' }}
run: |
curl -LO https://github.com/bytecodealliance/weval/releases/download/${{ steps.weval-meta.outputs.version }}/weval-${{ steps.weval-meta.outputs.version }}-aarch64-macos.tar.xz
tar -xvJf weval-${{ steps.weval-meta.outputs.version }}-aarch64-macos.tar.xz
mkdir .weval-bin
mv weval-${{ steps.weval-meta.outputs.version }}-aarch64-macos/weval .weval-bin/
# see: https://github.com/npm/cli/issues/4828
- name: Remove package-lock
run: |
mv package-lock.json hidden.json
- run: |
npm install -g patch-package
- name: Install oxc-parser
if: ${{ matrix.node == '18.x' && matrix.os == 'ubuntu-22.04' }}
run: |
npm install oxc-parser --ignore-engines
npm install @oxc-parser/binding-linux-x64-gnu --ignore-engines
- name: Restore package-lock
run: |
mv hidden.json package-lock.json
- name: Install NPM packages
run: |
npm install
- name: Cache puppeteer install
id: cache-puppeteer
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: puppeteer-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('packages/jco/package.json') }}
path: |
/home/runner/.cache/puppeteer
- name: Install puppeteer
run: |
npx puppeteer browsers install chrome
- name: Restore jco build
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: jco-build
path: |
packages/jco/obj
- name: Restore jco test components
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: jco-test-components
path: |
packages/jco/test/output/rust-test-components
- name: Test LTS Node.js
if: matrix.node == '18.x' || matrix.node == '20.x' || matrix.ndoe == '22.x'
working-directory: packages/jco
run: |
npm run test:lts -- --maxWorkers 4 --minWorkers 2 --maxConcurrency 2
- name: Test Latest Node.js
if: matrix.node == 'latest'
working-directory: packages/jco
env:
WEVAL_BIN_PATH: ${{ matrix.weval-bin-path }}
run: |
npm run test -- --maxWorkers 4 --minWorkers 2 --maxConcurrency 2
test-wasi-deno:
runs-on: "ubuntu-latest"
needs:
- build
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: recursive
- name: Install Rust deps
run: |
rustup update stable --no-self-update && rustup default stable
rustup target add wasm32-unknown-unknown
rustup target add wasm32-wasip1
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "latest"
- uses: denoland/setup-deno@667a34cdef165d8d2b2e98dde39547c9daac7282 # v2.0.4
with:
deno-version: v1.x
- name: Cache npm install
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
path: |
node_modules
- name: Install NPM packages
run: npm install
- name: Restore jco build
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: jco-build
path: |
packages/jco/obj
- name: Restore jco test components
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: jco-test-components
path: |
packages/jco/test/output/rust-test-components
- name: Generate tests
run: |
cargo xtask generate tests preview2
- name: WASI Preview 2 Conformance
run: cargo test deno_
test-wasi-node:
strategy:
matrix:
os:
- ubuntu-latest
- windows-2025
- macos-latest
node:
- 18.x
- 20.x
- latest
exclude:
- os: macos-latest
node: 20.x
- os: macos-latest
node: 18.x
- os: windows-2025
node: 20.x
- os: windows-2025
node: 18.x
# TODO: after debugging hang in p2 TCP streams abort
# see: https://github.com/bytecodealliance/jco/pull/1280#issuecomment-3957689892
- os: windows-2025
node: latest
fail-fast: false
runs-on: ${{ matrix.os }}
needs:
- build
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: recursive
- name: Install Rust deps
run: |
rustup update stable --no-self-update && rustup default stable
rustup target add wasm32-unknown-unknown
rustup target add wasm32-wasip1
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ matrix.node }}
- name: Cache npm install
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
path: |
node_modules
- name: Restore jco build
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: jco-build
path: |
packages/jco/obj
- name: Restore jco test components
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: jco-test-components
path: |
packages/jco/test/output/rust-test-components
- name: Install NPM packages
run: npm install
- name: Generate tests
run: |
cargo xtask generate tests preview2
- name: WASI Preview 2 Conformance
run: |
cargo test node_
test-shims:
runs-on: ubuntu-latest
strategy:
matrix:
workspace:
- preview2-shim
- preview3-shim
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Rust
run: rustup update stable --no-self-update
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
with:
shared-key: jco-${{ hashFiles('Cargo.lock') }}
- name: Cache npm install
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
path: |
node_modules
- name: Install NPM packages
run: npm install
- name: Cache puppeteer install
id: cache-puppeteer
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: puppeteer-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('packages/jco/package.json') }}
path: |
/home/runner/.cache/puppeteer
- name: Install puppeteer
run: |
npx puppeteer browsers install chrome
- name: Build jco
run: npm run build
- name: Test Workspaces
env:
TEST_PUPPETEER_LAUNCH_ARGS: |
--no-sandbox
run: npm run test --workspace packages/${{ matrix.workspace }}
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Cache npm install
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
path: |
node_modules
- name: Install NPM packages
run: npm install
- name: Lint
run: npm run lint
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Cache npm install
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
path: |
node_modules
- name: Install NPM packages
run: npm install
- name: Format
run: npm run fmt:check
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Rust
run: rustup update stable && rustup default stable && rustup component add rustfmt
- name: Remove tests mod
run: rm -r crates/jco/tests/mod.rs
- uses: Swatinem/rust-cache@v2
- name: Format source code
run: cargo fmt -- --check
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Rust
run: rustup update stable && rustup default stable
- name: Remove tests mod
run: rm -r crates/jco/tests/mod.rs
- uses: Swatinem/rust-cache@v2
- name: Run clippy
run: cargo clippy --workspace --all-features --all-targets --keep-going -- -D warnings
test-jco-std:
runs-on: ubuntu-latest
strategy:
matrix:
workspace:
- jco-std
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Rust
run: rustup update stable --no-self-update
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
with:
shared-key: jco-${{ hashFiles('Cargo.lock') }}
- name: Cache npm install
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
path: |
node_modules
- uses: taiki-e/cache-cargo-install-action@f9eed3e4680f27610dc6d8c67be1b88593f7dade # v3.0.6
with:
tool: wasmtime-cli@40.0.2
- name: Install NPM packages
working-directory: packages/${{ matrix.workspace }}
run: |
npm install
- name: Build jco-transpile, jco-std
run: |
npm run build -w packages/jco-transpile
npm --workspace packages/${{ matrix.workspace }} run build
- name: Test jco-std workspace
run: |
npm run test --workspace packages/${{ matrix.workspace }}
examples:
needs:
- build
runs-on: ubuntu-latest
strategy:
matrix:
wac:
- version: 0.6.0
node:
- version: 24.x
project:
- name: add
workspace: examples/components/add
- name: adder
workspace: examples/components/adder
- name: string-reverse
workspace: examples/components/string-reverse
- name: string-reverse-upper
workspace: examples/components/string-reverse-upper
is-composed: true
- name: webidl-book-library
workspace: examples/components/webidl-book-library
requires-crates:
- webidl2wit-cli
- name: node-fetch
workspace: examples/components/node-fetch
- name: http-hello-world
workspace: examples/components/http-hello-world
- name: http-server-fetch-handler
workspace: examples/components/http-server-fetch-handler
- name: http-server-hono
workspace: examples/components/http-server-hono
setup: |
npm run build -w @bytecodealliance/jco-transpile
npm run build -w @bytecodealliance/jco-std
- name: host-logging
workspace: examples/components/host-logging
- name: ts-resource-import
workspace: examples/components/ts-resource-import
- name: ts-resource-export
workspace: examples/components/ts-resource-export
- name: typegen-async-export
workspace: examples/components/typegen-async-export
- name: node-compat
workspace: examples/components/node-compat
- name: fs-write-file
workspace: examples/components/fs-write-file
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ matrix.node.version }}
- name: Restore jco build
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: jco-build
path: |
packages/jco/obj
- name: Restore jco test components
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: jco-test-components
path: |
packages/jco/test/output/rust-test-components
- name: Restore jco-transpile vendor
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: jco-transpile-vendor
path: |
packages/jco-transpile/vendor
- name: Install Rust
if: ${{ matrix.project.requires-crates != '[]' }}
run: rustup update stable --no-self-update && rustup default stable
- name: Install required rust crates
if: ${{ matrix.project.requires-crates != '[]' }}
uses: taiki-e/install-action@787505cde8a44ea468a00478fe52baf23b15bccd # v2
with:
tool: ${{ join(matrix.project.requires-crates, ',') }}
- name: Install wac
if: ${{ matrix.project.is-composed }}
uses: jaxxstorm/action-install-gh-release@25e24d2d23ae098373794ef1d6faecb48ee52da8 # v3.0.0
with:
repo: bytecodealliance/wac
tag: v${{ matrix.wac.version }}
extension-matching: disable
rename-to: wac
chmod: 0755
- uses: bytecodealliance/actions/wasmtime/setup@9152e710e9f7182e4c29ad218e4f335a7b203613 # v1.1.3
- name: Cache npm install
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
path: |
node_modules
- run: npm install
- name: npm install (project)
working-directory: ${{ matrix.project.dir }}
run: npm install
- run: |
${{ matrix.project.setup }}
- name: Run all script for (${{ matrix.project.name }})
working-directory: ${{ matrix.project.dir }}
run: npm run all --workspace ${{ matrix.project.workspace }}