-
Notifications
You must be signed in to change notification settings - Fork 28
417 lines (374 loc) · 12 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
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.5.1
wasm-tools_version: 1.0.28
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 check-changelog
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: 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/gecko-revision',
'runtime/spidermonkey/object-files.list',
'runtime/rust-toolchain.toml'
) }}-${{ matrix.profile }}
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.5.1 # 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:
include:
- profile: debug
- profile: 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: 19
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:
fail-fast: false
matrix:
fixture:
- async-select
- btoa
- byob
- byte-repeater
- crypto
- config-store
- console
- dynamic-backend
- edge-dictionary
- env
- error
- extend-from-builtins
- extend-from-request
- fanout
- geoip
- hello-world
- includeBytes
- log
- missing-backend
- multiple-set-cookie
- kv-store
- random
- react-byob
- regex
- request-cache-key
- request-clone
- request-downstream
- request-headers
- request-limits
- request-upstream
- response
- response-headers
- response-json
- response-redirect
- secret-store
- status
- streaming-close
- tee
- timers
- transform-stream
- urlsearchparams
steps:
- name: Checkout fastly/js-compute-runtime
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 19
cache: 'yarn'
- name: Set up Fastly CLI
uses: fastly/compute-actions/setup@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
cli_version: '7.0.1'
- 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
# https://github.com/fastly/js-compute-runtime/issues/361
# TODO: Use engine-debug on all apps once we upgrade to FF 109
- name: Download Engine
uses: actions/download-artifact@v3
with:
name: ${{ matrix.fixture == 'regex' && 'engine-release' || 'engine-debug' }}
- run: yarn install --frozen-lockfile
- name: js-compute Integration Tests Job
timeout-minutes: 20
uses: ./.github/actions/compute-sdk-test
with:
fixture: ${{ matrix.fixture }}
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]
strategy:
matrix:
node-version: [18, 19]
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
- run: yarn
shell: bash
- run: npm test
e2e:
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
needs: [build]
strategy:
fail-fast: false
matrix:
fixture:
- 'async-select'
- 'byob'
- 'byte-repeater'
- 'cache-override'
- 'cache-simple'
- 'client'
- 'crypto'
- 'edge-dictionary'
- 'error'
- 'fanout'
- 'geoip'
- 'hello-world'
- 'multiple-set-cookie'
- 'kv-store'
- 'react-byob'
- 'request-clone'
- 'request-headers'
- 'request-limits'
- 'request-upstream'
- 'response'
- 'response-headers'
- 'response-json'
- 'response-redirect'
- 'secret-store'
- 'status'
- 'timers'
- 'transform-stream'
- 'urlsearchparams'
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 }}
github-token: ${{ secrets.GITHUB_TOKEN }}
fixture: ${{ matrix.fixture }}