-
Notifications
You must be signed in to change notification settings - Fork 28
448 lines (400 loc) · 13.4 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
name: CI
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
on:
pull_request:
push:
branches: [main]
defaults:
run:
shell: bash
env:
# Note: when updated, also update version in ensure-cargo-installs
viceroy_version: 0.12.0
# Note: when updated, also update version in ensure-cargo-installs
wasm-tools_version: 1.216.0
fastly-cli_version: 10.13.3
jobs:
check-changelog:
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 'lts/*'
- run: npm ci
- 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:
node-version: 'lts/*'
- run: cd documentation && npm run add-fastly-prefix
- run: cd documentation && npm ci
- run: cd documentation && npm run build
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.12.0 # Note: workflow-level env vars can't be used in matrix definitions
options: ""
- crate: wasm-tools
version: 1.216.0 # 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 }}
if: steps.cache-crate.outputs.cache-hit != 'true'
run: cargo install ${{ matrix.crate }} ${{ matrix.options }} --version ${{ matrix.version }} --force
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
- 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/
ls /opt/wasi-sdk/
- run: |
/opt/wasi-sdk/bin/clang-format --version
ci/clang-format.sh
- run: |
ci/rustfmt.sh
- run: npm install
- run: npm run format:check
test-npm-package:
if: github.ref != 'refs/heads/main'
needs: [build]
strategy:
matrix:
node-version: [18, 22]
os: [
ubuntu-latest,
windows-latest,
macos-latest
]
exclude:
- os: macos-latest
node-version: 18
- os: windows-latest
node-version: 18
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Download Engine
uses: actions/download-artifact@v3
with:
name: fastly-release
- name: Download Engine
uses: actions/download-artifact@v3
with:
name: fastly-debug
- name: Download Engine
uses: actions/download-artifact@v3
with:
name: fastly-weval
- name: Download Engine Weval Cache
uses: actions/download-artifact@v3
with:
name: fastly-weval-ic-cache
- run: npm install
- run: npm test
build-debug:
name: Debug Build
needs: [ensure-cargo-installs]
runs-on: ubuntu-latest
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: 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: Build with full debug info
run: npm run build:debug:info
- uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: fastly-debug
path: fastly.debug.wasm
build:
name: Build
needs: [ensure-cargo-installs]
runs-on: ubuntu-latest
strategy:
matrix:
profile: [release, weval]
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: 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: Build
if: matrix.profile == 'release'
run: npm run build
- name: Build
if: matrix.profile == 'weval'
run: npm run build:weval
- uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: fastly-${{ matrix.profile }}
path: fastly${{ matrix.profile == 'debug' && '.debug.wasm' || (matrix.profile == 'weval' && '-weval.wasm' || '.wasm') }}
- uses: actions/upload-artifact@v3
if: matrix.profile == 'weval'
with:
name: fastly-${{ matrix.profile }}-ic-cache
path: fastly-ics.wevalcache
run-wpt-debug:
if: github.ref != 'refs/heads/main'
name: Run Web Platform Tests Debug
needs: [build-debug, ensure-cargo-installs]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-node@v3
with:
node-version: 'lts/*'
- name: Download Engine
uses: actions/download-artifact@v3
with:
name: fastly-debug
- 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 }}
- run: npm install
- name: Build WPT runtime
run: tests/wpt-harness/build-wpt-runtime.sh --debug-build
- 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 -vv
run-wpt:
strategy:
matrix:
profile: [release, weval]
if: github.ref != 'refs/heads/main'
name: Run Web Platform Tests
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: 'lts/*'
- name: Download Engine
uses: actions/download-artifact@v3
with:
name: fastly-${{ matrix.profile }}
- name: Download Engine Weval Cache
if: matrix.profile == 'weval'
uses: actions/download-artifact@v3
with:
name: fastly-weval-ic-cache
- 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 }}
- run: npm install
- name: Build WPT runtime
run: tests/wpt-harness/build-wpt-runtime.sh ${{matrix.profile == 'weval' && '--enable-experimental-aot' || matrix.profile == 'debug' && '--debug-build' || ''}}
- 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 -vv
sdktest:
concurrency:
group: ${{ github.head_ref }}--sdktest-${{matrix.profile}}-${{matrix.platform}}
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform: [viceroy, compute]
profile: [release, weval]
needs: [build, ensure-cargo-installs]
steps:
- name: Checkout fastly/js-compute-runtime
uses: actions/checkout@v3
with:
submodules: false
ref: ${{ github.head_ref || github.ref_name }}
- uses: actions/setup-node@v3
with:
node-version: 'lts/*'
- 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: Download Engine
uses: actions/download-artifact@v3
with:
name: fastly-${{ matrix.profile }}
- name: Download Engine (AOT weval cache)
uses: actions/download-artifact@v3
if: matrix.profile == 'weval'
with:
name: fastly-${{ matrix.profile }}-ic-cache
- name: Npm install
run: npm install && cd ./integration-tests/js-compute && npm install
- name: Run Tests
run: SUFFIX_STRING=${{matrix.profile}} node integration-tests/js-compute/test.js ${{ matrix.platform == 'viceroy' && '--local' || '' }} ${{ matrix.profile == 'weval' && '--aot' || '' }}
env:
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}
- name: Run TLA Tests
run: SUFFIX_STRING=${{matrix.profile}} node integration-tests/js-compute/test.js --tla ${{ matrix.platform == 'viceroy' && '--local' || '' }} ${{ matrix.profile == 'weval' && '--aot' || '' }}
env:
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}
sdktest-debug:
concurrency:
group: ${{ github.head_ref }}--sdktest-debug-${{matrix.platform}}
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform: [viceroy, compute]
needs: [build-debug, ensure-cargo-installs]
steps:
- name: Checkout fastly/js-compute-runtime
uses: actions/checkout@v3
with:
submodules: false
ref: ${{ github.head_ref || github.ref_name }}
- uses: actions/setup-node@v3
with:
node-version: 'lts/*'
- 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: Download Engine
uses: actions/download-artifact@v3
with:
name: fastly-debug
- name: Strip debug sections (compute only)
if: matrix.platform == 'compute'
run: wasm-tools strip fastly.debug.wasm -d ".debug_(info|loc|ranges|abbrev|line|str)" -o fastly.debug.wasm
- name: Npm install
run: npm install && cd ./integration-tests/js-compute && npm install
- name: Run Tests
run: SUFFIX_STRING=debug node integration-tests/js-compute/test.js --debug-build ${{ matrix.platform == 'viceroy' && '--local' || '' }}
env:
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}
- name: Run TLA Tests
run: SUFFIX_STRING=debug node integration-tests/js-compute/test.js --tla --debug-build ${{ matrix.platform == 'viceroy' && '--local' || '' }}
env:
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}