-
Notifications
You must be signed in to change notification settings - Fork 28
496 lines (432 loc) · 14.7 KB
/
main.yml
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
name: CI
concurrency:
group: ${{ github.head_ref }}-${{ github.workflow}}
cancel-in-progress: true
on:
pull_request:
push:
branches: [main]
defaults:
run:
shell: bash
env:
viceroy_version: 0.9.4
wasm-tools_version: 1.0.28
fastly-cli_version: 10.8.10
jobs:
check-changelog:
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: 'yarn'
- run: yarn install --immutable
- run: npm run format-changelog
check-docusaurus:
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: 'yarn'
- run: cd documentation && yarn install
- run: cd documentation && yarn build
build:
name: Build
needs: [ensure_cargo_installs]
strategy:
matrix:
profile: [debug, release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: ./.github/actions/cache-crates
with:
lockfiles: 'runtime/js-compute-runtime/**/Cargo.lock'
- name: Restore wasm-tools from cache
uses: actions/cache@v3
id: wasm-tools
with:
path: "/home/runner/.cargo/bin/wasm-tools"
key: crate-cache-wasm-tools-${{ env.wasm-tools_version }}
- name: "Check wasm-tools has been restored"
if: steps.wasm-tools.outputs.cache-hit != 'true'
run: |
echo "wasm-tools was not restored from the cache"
echo "bailing out from the build early"
exit 1
- uses: ./.github/actions/install-rust
with:
path: runtime
- name: gecko-dev hash
id: gecko-dev-hash
run: cd runtime/spidermonkey/gecko-dev && echo "GECKO_DEV_HASH=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
shell: bash
- name: Cache SpiderMonkey object files
uses: actions/cache@v3
id: sm-cache
with:
path: |
runtime/spidermonkey/${{ matrix.profile }}
key: cache-${{ hashFiles(
'runtime/spidermonkey/build-engine.sh',
'runtime/spidermonkey/object-files.list'
) }}-${{ matrix.profile }}-${{ steps.gecko-dev-hash.outputs.GECKO_DEV_HASH }}
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
- name: "Build SpiderMonkey"
if: steps.sm-cache.outputs.cache-hit != 'true'
run: |
cd runtime/spidermonkey/
sudo apt-get update -y
bash ./build-engine.sh ${{ matrix.profile }}
- name: "Install wasi-sdk-20 (linux)"
run: |
set -x
curl -sS -L -O https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz
tar xf wasi-sdk-20.0-linux.tar.gz
sudo mkdir -p /opt/wasi-sdk
sudo mv wasi-sdk-20.0/* /opt/wasi-sdk/
- name: "Install Binaryen (linux)"
run: |
set -x
export BINARYEN_VERSION=105
curl -sS -L "https://github.com/WebAssembly/binaryen/releases/download/version_${BINARYEN_VERSION}/binaryen-version_${BINARYEN_VERSION}-x86_64-linux.tar.gz" | tar xzf - &&
echo "$PWD/binaryen-version_${BINARYEN_VERSION}/bin" >> $GITHUB_PATH
- name: Cache built Rust dependencies
uses: actions/cache@v3
with:
path: runtime/js-compute-runtime/rusturl
key: engine-cargo-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('runtime/rust-toolchain.toml', 'runtime/js-compute-runtime/**/Cargo.lock') }}
# We trust cargo to only reuse valid parts of the cache when dependencies change.
restore-keys: engine-cargo-${{ runner.os }}-${{ runner.arch }}-
# Out of an abundance of caution, ensure that tagged releases rebuild all
# crates from source.
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
- name: "Build JS runtime (debug)"
run: DEBUG=1 OPT_FLAGS="-O1" npm run build
if: matrix.profile == 'debug'
- name: "Build JS runtime (release)"
run: npm run build
if: matrix.profile == 'release'
- uses: actions/upload-artifact@v3
with:
name: engine-${{ matrix.profile }}
path: |
js-compute-runtime.wasm
js-compute-runtime-component.wasm
ensure_cargo_installs:
name: Ensure that all required "cargo install" commands are run, or we have a cache hit
strategy:
matrix:
include:
- crate: viceroy
version: 0.9.4 # Note: workflow-level env vars can't be used in matrix definitions
options: ""
- crate: wasm-tools
version: 1.0.28 # Note: workflow-level env vars can't be used in matrix definitions
options: ""
runs-on: ubuntu-latest
steps:
- name: Cache ${{ matrix.crate }} ${{ matrix.version }}
id: cache-crate
uses: actions/cache@v3
with:
path: "/home/runner/.cargo/bin/${{ matrix.crate }}"
key: crate-cache-${{ matrix.crate }}-${{ matrix.version }}
- name: Install ${{ matrix.crate }} ${{ matrix.version }}
run: cargo install ${{ matrix.crate }} ${{ matrix.options }} --version ${{ matrix.version }}
if: steps.cache-crate.outputs.cache-hit != 'true'
run_wpt:
if: github.ref != 'refs/heads/main'
name: Run Web Platform Tests
strategy:
matrix:
profile: [debug, release]
needs: [build, ensure_cargo_installs]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-node@v3
with:
node-version: 20
cache: 'yarn'
- name: Download Engine
uses: actions/download-artifact@v3
with:
name: engine-${{ matrix.profile }}
- name: Restore Viceroy from cache
uses: actions/cache@v3
with:
path: "/home/runner/.cargo/bin/viceroy"
key: crate-cache-viceroy-${{ env.viceroy_version }}
- name: Restore wasm-tools from cache
uses: actions/cache@v3
id: wasm-tools
with:
path: "/home/runner/.cargo/bin/wasm-tools"
key: crate-cache-wasm-tools-${{ env.wasm-tools_version }}
- name: "Check wasm-tools has been restored"
if: steps.wasm-tools.outputs.cache-hit != 'true'
run: |
echo "wasm-tools was not restored from the cache"
echo "bailing out from the build early"
exit 1
- run: yarn install --frozen-lockfile
- name: Build WPT runtime
run: |
bash ./tests/wpt-harness/build-wpt-runtime.sh
- name: Prepare WPT hosts
run: |
cd tests/wpt-harness/wpt
./wpt make-hosts-file | sudo tee -a /etc/hosts
- name: Run tests
timeout-minutes: 20
run: |
# Skip slow tests when testing the debug runtime.
node ./tests/wpt-harness/run-wpt.mjs -vv $(((${{ matrix.profile }} == "debug")) && echo "--skip-slow-tests")
# Consumes all published artifacts from all the previous build steps, and runs
# the integration tests for the linux build.
sdktest:
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
needs: [build, ensure_cargo_installs]
strategy:
matrix:
profile: [debug, release]
steps:
- name: Checkout fastly/js-compute-runtime
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
cache: 'yarn'
- name: Set up Fastly CLI
uses: fastly/compute-actions/setup@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
cli_version: ${{ env.fastly-cli_version }}
- name: Restore Viceroy from cache
uses: actions/cache@v3
with:
path: "/home/runner/.cargo/bin/viceroy"
key: crate-cache-viceroy-${{ env.viceroy_version }}
- name: Restore wasm-tools from cache
uses: actions/cache@v3
id: wasm-tools
with:
path: "/home/runner/.cargo/bin/wasm-tools"
key: crate-cache-wasm-tools-${{ env.wasm-tools_version }}
- name: "Check wasm-tools has been restored"
if: steps.wasm-tools.outputs.cache-hit != 'true'
run: |
echo "wasm-tools was not restored from the cache"
echo "bailing out from the build early"
exit 1
- name: Download Engine
uses: actions/download-artifact@v3
with:
name: 'engine-${{ matrix.profile }}'
- run: yarn install --frozen-lockfile
- name: js-compute Integration Tests Job
timeout-minutes: 20
uses: ./.github/actions/compute-sdk-test
with:
fastly-api-token: ${{ secrets.FASTLY_API_TOKEN }}
fastly-cli-version: ${{ env.fastly-cli_version }}
github-token: ${{ secrets.GITHUB_TOKEN }}
shellcheck:
env:
SHELLCHECK_VERSION: v0.8.0
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
id: cache-shellcheck
with:
path: ${{ runner.tool_cache }}/shellcheck
key: shellcheck-${{ runner.os }}-${{ env.SHELLCHECK_VERSION }}
- name: Download shellcheck
if: steps.cache-shellcheck.output.cache-hit != 'true'
run: |
version="${{ env.SHELLCHECK_VERSION }}"
baseurl="https://github.com/koalaman/shellcheck/releases/download"
curl -Lso "shellcheck.tar.xz" \
"${baseurl}/${version}/shellcheck-${version}.linux.x86_64.tar.xz"
mkdir -p "${{ runner.tool_cache }}/shellcheck/bin"
tar -xf shellcheck.tar.xz -C "${{ runner.tool_cache }}/shellcheck/bin"
- name: Add shellcheck to path
run: echo "${{ runner.tool_cache }}/shellcheck/bin" >> $GITHUB_PATH
- name: Run shellcheck
run: ci/shellcheck.sh
format:
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: |
clang-format --version
ci/clang-format.sh
- run: |
ci/rustfmt.sh
test-npm-package:
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
needs: [build, starlingmonkey-build]
strategy:
matrix:
node-version: [18, 20]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Download Engine
uses: actions/download-artifact@v3
with:
name: engine-release
- name: Download Engine
uses: actions/download-artifact@v3
with:
name: starling-release
- run: yarn
shell: bash
- run: npm test
e2e:
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v3
with:
submodules: false
ref: ${{ github.head_ref || github.ref_name }}
- uses: ./.github/actions/e2e
with:
fastly-api-token: ${{ secrets.FASTLY_API_TOKEN }}
fastly-cli-version: ${{ env.fastly-cli_version }}
github-token: ${{ secrets.GITHUB_TOKEN }}
starlingmonkey-build:
name: StarlingMonkey Build
runs-on: ubuntu-latest
strategy:
matrix:
profile: [debug, release]
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install Rust 1.77.1
run: |
rustup toolchain install 1.77.1
rustup target add wasm32-wasi --toolchain 1.77.1
- name: Build
if: ${{ matrix.profile == 'release' }}
run: npm run build:starlingmonkey
- name: Build
if: ${{ matrix.profile == 'debug' }}
run: npm run build:starlingmonkey:debug
- uses: actions/upload-artifact@v3
with:
name: starling-${{ matrix.profile }}
path: starling.wasm
starlingmonkey-run_wpt:
if: github.ref != 'refs/heads/main'
name: Run Web Platform Tests
needs: [starlingmonkey-build, ensure_cargo_installs]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-node@v3
with:
node-version: 20
cache: 'yarn'
- name: Download Engine
uses: actions/download-artifact@v3
with:
name: starling-release
- name: Restore Viceroy from cache
uses: actions/cache@v3
with:
path: "/home/runner/.cargo/bin/viceroy"
key: crate-cache-viceroy-${{ env.viceroy_version }}
- name: Restore wasm-tools from cache
uses: actions/cache@v3
id: wasm-tools
with:
path: "/home/runner/.cargo/bin/wasm-tools"
key: crate-cache-wasm-tools-${{ env.wasm-tools_version }}
- name: "Check wasm-tools has been restored"
if: steps.wasm-tools.outputs.cache-hit != 'true'
run: |
echo "wasm-tools was not restored from the cache"
echo "bailing out from the build early"
exit 1
- run: yarn install --frozen-lockfile
- name: Build WPT runtime
run: tests/wpt-harness/build-wpt-runtime.sh --starlingmonkey
- name: Prepare WPT hosts
run: |
cd tests/wpt-harness/wpt
./wpt make-hosts-file | sudo tee -a /etc/hosts
- name: Run tests
timeout-minutes: 20
run: node ./tests/wpt-harness/run-wpt.mjs --starlingmonkey -vv
starlingmonkey-sdktest:
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
strategy:
matrix:
platform: [viceroy, compute]
profile: [debug, release]
exclude:
- platform: compute
profile: release
needs: [starlingmonkey-build]
steps:
- name: Checkout fastly/js-compute-runtime
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 'lts/*'
cache: 'yarn'
- name: Set up Fastly CLI
uses: fastly/compute-actions/setup@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
cli_version: ${{ env.fastly-cli_version }}
- name: Restore Viceroy from cache
if: ${{ matrix.platform == 'viceroy' }}
uses: actions/cache@v3
id: viceroy
with:
path: "/home/runner/.cargo/bin/viceroy"
key: crate-cache-viceroy-${{ env.viceroy_version }}
- name: Restore wasm-tools from cache
uses: actions/cache@v3
id: wasm-tools
with:
path: "/home/runner/.cargo/bin/wasm-tools"
key: crate-cache-wasm-tools-${{ env.wasm-tools_version }}
- name: "Check caches have been restored"
if: steps.wasm-tools.outputs.cache-hit != 'true' || matrix.platform == 'viceory' && steps.viceroy.outputs.cache-hit != 'true'
run: echo "Unable to restore from the cache, bailing." && exit 1
- name: Download Engine
uses: actions/download-artifact@v3
with:
name: starling-${{ matrix.profile }}
- run: yarn install --frozen-lockfile
- name: Yarn install
run: yarn && cd ./integration-tests/js-compute && yarn
- run: node integration-tests/js-compute/test.js --starlingmonkey ${{ matrix.platform == 'viceroy' && '--local' || '' }}
env:
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}