Skip to content

Commit e10829d

Browse files
author
Guy Bedford
authored
feat: grpc backend option (#971)
1 parent 0dcff58 commit e10829d

File tree

12 files changed

+1063
-1550
lines changed

12 files changed

+1063
-1550
lines changed

.github/workflows/main.yml

Lines changed: 145 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
name: CI
2+
concurrency:
3+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
4+
cancel-in-progress: true
25
on:
36
pull_request:
47
push:
@@ -7,9 +10,9 @@ defaults:
710
run:
811
shell: bash
912
env:
10-
# Note: when updated, also update version in ensure_cargo_installs
13+
# Note: when updated, also update version in ensure-cargo-installs
1114
viceroy_version: 0.12.0
12-
# Note: when updated, also update version in ensure_cargo_installs
15+
# Note: when updated, also update version in ensure-cargo-installs
1316
wasm-tools_version: 1.216.0
1417
fastly-cli_version: 10.13.3
1518

@@ -37,7 +40,7 @@ jobs:
3740
- run: cd documentation && npm ci
3841
- run: cd documentation && npm run build
3942

40-
ensure_cargo_installs:
43+
ensure-cargo-installs:
4144
name: Ensure that all required "cargo install" commands are run, or we have a cache hit
4245
strategy:
4346
matrix:
@@ -153,13 +156,39 @@ jobs:
153156
- run: npm install
154157
- run: npm test
155158

159+
build-debug:
160+
name: Debug Build
161+
needs: [ensure-cargo-installs]
162+
runs-on: ubuntu-latest
163+
steps:
164+
- uses: actions/checkout@v3
165+
with:
166+
submodules: true
167+
- name: Install Rust 1.77.1
168+
run: |
169+
rustup toolchain install 1.77.1
170+
rustup target add wasm32-wasi --toolchain 1.77.1
171+
- name: Restore wasm-tools from cache
172+
uses: actions/cache@v3
173+
id: wasm-tools
174+
with:
175+
path: "/home/runner/.cargo/bin/wasm-tools"
176+
key: crate-cache-wasm-tools-${{ env.wasm-tools_version }}
177+
- name: Build
178+
run: npm run build:debug
179+
- uses: actions/upload-artifact@v3
180+
with:
181+
if-no-files-found: error
182+
name: fastly-debug
183+
path: fastly.debug.wasm
184+
156185
build:
157186
name: Build
158-
needs: [ensure_cargo_installs]
187+
needs: [ensure-cargo-installs]
159188
runs-on: ubuntu-latest
160189
strategy:
161190
matrix:
162-
profile: [debug, release, weval]
191+
profile: [release, weval]
163192
steps:
164193
- uses: actions/checkout@v3
165194
with:
@@ -177,9 +206,6 @@ jobs:
177206
- name: Build
178207
if: ${{ matrix.profile == 'release' }}
179208
run: npm run build
180-
- name: Build
181-
if: ${{ matrix.profile == 'debug' }}
182-
run: npm run build:debug
183209
- name: Build
184210
if: ${{ matrix.profile == 'weval' }}
185211
run: npm run build:weval
@@ -194,13 +220,58 @@ jobs:
194220
name: fastly-${{ matrix.profile }}-ic-cache
195221
path: fastly-ics.wevalcache
196222

197-
run_wpt:
223+
run-wpt-debug:
224+
if: github.ref != 'refs/heads/main'
225+
name: Run Web Platform Tests Debug
226+
needs: [build-debug, ensure-cargo-installs]
227+
runs-on: ubuntu-latest
228+
steps:
229+
- uses: actions/checkout@v3
230+
with:
231+
submodules: true
232+
- uses: actions/setup-node@v3
233+
with:
234+
node-version: 'lts/*'
235+
236+
- name: Download Engine
237+
uses: actions/download-artifact@v3
238+
with:
239+
name: fastly-debug
240+
241+
- name: Restore Viceroy from cache
242+
uses: actions/cache@v3
243+
with:
244+
path: "/home/runner/.cargo/bin/viceroy"
245+
key: crate-cache-viceroy-${{ env.viceroy_version }}
246+
247+
- name: Restore wasm-tools from cache
248+
uses: actions/cache@v3
249+
id: wasm-tools
250+
with:
251+
path: "/home/runner/.cargo/bin/wasm-tools"
252+
key: crate-cache-wasm-tools-${{ env.wasm-tools_version }}
253+
254+
- run: npm install
255+
256+
- name: Build WPT runtime
257+
run: tests/wpt-harness/build-wpt-runtime.sh --debug-build
258+
259+
- name: Prepare WPT hosts
260+
run: |
261+
cd tests/wpt-harness/wpt
262+
./wpt make-hosts-file | sudo tee -a /etc/hosts
263+
264+
- name: Run tests
265+
timeout-minutes: 20
266+
run: node ./tests/wpt-harness/run-wpt.mjs -vv
267+
268+
run-wpt:
198269
strategy:
199270
matrix:
200-
profile: [debug, release, weval]
271+
profile: [release, weval]
201272
if: github.ref != 'refs/heads/main'
202273
name: Run Web Platform Tests
203-
needs: [build, ensure_cargo_installs]
274+
needs: [build, ensure-cargo-installs]
204275
runs-on: ubuntu-latest
205276
steps:
206277
- uses: actions/checkout@v3
@@ -257,8 +328,8 @@ jobs:
257328
fail-fast: false
258329
matrix:
259330
platform: [viceroy, compute]
260-
profile: [debug, release, weval]
261-
needs: [build, ensure_cargo_installs]
331+
profile: [release, weval]
332+
needs: [build, ensure-cargo-installs]
262333
steps:
263334
- name: Checkout fastly/js-compute-runtime
264335
uses: actions/checkout@v3
@@ -300,17 +371,75 @@ jobs:
300371
with:
301372
name: fastly-${{ matrix.profile }}-ic-cache
302373

303-
- run: npm install
374+
- name: Npm install
375+
run: npm install && cd ./integration-tests/js-compute && npm install
376+
377+
- name: Run Tests
378+
run: SUFFIX_STRING=${{matrix.profile}} node integration-tests/js-compute/test.js ${{ matrix.platform == 'viceroy' && '--local' || '' }} ${{ matrix.profile == 'weval' && '--aot' || '' }}
379+
env:
380+
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}
381+
382+
- name: Run TLA Tests
383+
run: SUFFIX_STRING=${{matrix.profile}} node integration-tests/js-compute/test.js --tla ${{ matrix.platform == 'viceroy' && '--local' || '' }} ${{ matrix.profile == 'weval' && '--aot' || '' }}
384+
env:
385+
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}
386+
387+
sdktest-debug:
388+
concurrency:
389+
group: ${{ github.head_ref }}--sdktest-debug-${{matrix.platform}}
390+
if: github.ref != 'refs/heads/main'
391+
runs-on: ubuntu-latest
392+
strategy:
393+
fail-fast: false
394+
matrix:
395+
platform: [viceroy, compute]
396+
needs: [build-debug, ensure-cargo-installs]
397+
steps:
398+
- name: Checkout fastly/js-compute-runtime
399+
uses: actions/checkout@v3
400+
with:
401+
submodules: false
402+
ref: ${{ github.head_ref || github.ref_name }}
403+
- uses: actions/setup-node@v3
404+
with:
405+
node-version: 'lts/*'
406+
407+
- name: Set up Fastly CLI
408+
uses: fastly/compute-actions/setup@v4
409+
with:
410+
token: ${{ secrets.GITHUB_TOKEN }}
411+
cli_version: ${{ env.fastly-cli_version }}
412+
413+
- name: Restore Viceroy from cache
414+
if: ${{ matrix.platform == 'viceroy' }}
415+
uses: actions/cache@v3
416+
id: viceroy
417+
with:
418+
path: "/home/runner/.cargo/bin/viceroy"
419+
key: crate-cache-viceroy-${{ env.viceroy_version }}
420+
421+
- name: Restore wasm-tools from cache
422+
uses: actions/cache@v3
423+
id: wasm-tools
424+
with:
425+
path: "/home/runner/.cargo/bin/wasm-tools"
426+
key: crate-cache-wasm-tools-${{ env.wasm-tools_version }}
427+
428+
- name: Download Engine
429+
uses: actions/download-artifact@v3
430+
with:
431+
name: fastly-debug
304432

305433
- name: Npm install
306434
run: npm install && cd ./integration-tests/js-compute && npm install
307435

308436
- name: Run Tests
309-
run: SUFFIX_STRING=${{matrix.profile}} node integration-tests/js-compute/test.js ${{ matrix.platform == 'viceroy' && '--local' || '' }} ${{ matrix.profile == 'weval' && '--aot' || '' }} ${{ matrix.profile == 'debug' && '--debug-build' || '' }}
437+
run: SUFFIX_STRING=debug node integration-tests/js-compute/test.js --debug-build ${{ matrix.platform == 'viceroy' && '--local' || '' }}
310438
env:
311439
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}
312440

313441
- name: Run TLA Tests
314-
run: SUFFIX_STRING=${{matrix.profile}} node integration-tests/js-compute/test.js --tla ${{ matrix.platform == 'viceroy' && '--local' || '' }} ${{ matrix.profile == 'weval' && '--aot' || '' }} ${{ matrix.profile == 'debug' && '--debug-build' || '' }}
442+
run: SUFFIX_STRING=debug node integration-tests/js-compute/test.js --tla --debug-build ${{ matrix.platform == 'viceroy' && '--local' || '' }}
315443
env:
316444
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}
445+

documentation/docs/backend/Backend/Backend.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ new Backend(backendConfiguration)
9797
- The PEM certificate string.
9898
- `key` _: SecretStoreEntry_
9999
- The `SecretStoreEntry` to use for the key, created via [`SecretStore.prototype.get`](../../fastly:secret-store/SecretStore/prototype/get.mdx) or alteratively via [`SecretStore.fromBytes`](../../fastly:secret-store/SecretStore/fromBytes.mdx).
100+
- `grpc` _: boolean_ _**optional**_
101+
- **_Experimental feature_**
102+
- When enabled, sets that this backend is to be used for gRPC traffic.
103+
- _Warning: When using this experimental feature, no guarantees are provided for behaviours for backends that do not provide gRPC traffic._
100104

101105
### Return value
102106

integration-tests/js-compute/fixtures/app/src/compute.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ routes.set('/compute/get-vcpu-ms', () => {
77
strictEqual(typeof cpuTime, 'number');
88
ok(cpuTime > 0);
99
ok(cpuTime < 3000);
10-
const arr = [];
11-
for (let i = 0; i < 10_000; i++) {
12-
arr.push(i);
10+
const arr = new Array(100_000).fill(1);
11+
for (let j = 1; j < 100; j++) {
12+
for (let i = 1; i < 100_000; i++) {
13+
arr[i] = (arr[i] + arr[i - 1] + i) / 3;
14+
}
1315
}
1416
const cpuTime2 = vCpuTime();
1517
ok(cpuTime2 > cpuTime);
1618
ok(cpuTime2 - cpuTime > 1);
17-
ok(cpuTime2 - cpuTime < 3000);
1819
return pass('ok');
1920
});
2021

0 commit comments

Comments
 (0)