Skip to content

Commit d0eb82d

Browse files
author
Guy Bedford
authored
Initial StarlingMonkey Build (#764)
1 parent 728ae21 commit d0eb82d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+40608
-46
lines changed

.github/workflows/starlingmonkey.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: StarlingMonkey
2+
concurrency:
3+
group: ${{ github.head_ref }}-${{ github.workflow}}
4+
cancel-in-progress: true
5+
on:
6+
pull_request:
7+
push:
8+
branches: [main]
9+
defaults:
10+
run:
11+
shell: bash
12+
env:
13+
viceroy_version: 0.9.4
14+
wasm-tools_version: 1.0.28
15+
fastly-cli_version: 10.4.0
16+
17+
jobs:
18+
build:
19+
name: StarlingMonkey Build
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v3
23+
with:
24+
submodules: true
25+
- name: Install Rust 1.77.1
26+
run: |
27+
rustup toolchain install 1.77.1
28+
rustup target add wasm32-wasi --toolchain 1.77.1
29+
- name: Build
30+
run: npm run build:starlingmonkey:debug
31+
- uses: actions/upload-artifact@v3
32+
with:
33+
name: starling-debug
34+
path: starling.wasm
35+
36+
sdktest:
37+
if: github.ref != 'refs/heads/main'
38+
runs-on: ubuntu-latest
39+
needs: [build]
40+
steps:
41+
- name: Checkout fastly/js-compute-runtime
42+
uses: actions/checkout@v3
43+
- uses: actions/setup-node@v3
44+
with:
45+
node-version: 'lts/*'
46+
cache: 'yarn'
47+
48+
- name: Set up Fastly CLI
49+
uses: fastly/compute-actions/setup@v4
50+
with:
51+
token: ${{ secrets.GITHUB_TOKEN }}
52+
cli_version: ${{ env.fastly-cli_version }}
53+
54+
- name: Restore Viceroy from cache
55+
uses: actions/cache@v3
56+
with:
57+
path: "/home/runner/.cargo/bin/viceroy"
58+
key: crate-cache-viceroy-${{ env.viceroy_version }}
59+
60+
- name: Restore wasm-tools from cache
61+
uses: actions/cache@v3
62+
id: wasm-tools
63+
with:
64+
path: "/home/runner/.cargo/bin/wasm-tools"
65+
key: crate-cache-wasm-tools-${{ env.wasm-tools_version }}
66+
67+
- name: "Check wasm-tools has been restored"
68+
if: steps.wasm-tools.outputs.cache-hit != 'true'
69+
run: |
70+
echo "wasm-tools was not restored from the cache"
71+
echo "bailing out from the build early"
72+
exit 1
73+
74+
- name: Download Engine
75+
uses: actions/download-artifact@v3
76+
with:
77+
name: starling-debug
78+
- run: yarn install --frozen-lockfile
79+
80+
- name: Yarn install
81+
run: |
82+
yarn
83+
cd ./integration-tests/js-compute
84+
yarn
85+
86+
- run: |
87+
cd ./integration-tests/js-compute
88+
FASTLY_API_TOKEN=${{ secrets.FASTLY_API_TOKEN }} ./test.js --starlingmonkey --local

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
/integration-tests/**/fixtures/**/fastly.toml
44
/integration-tests/**/fixtures/**/*.wasm
55

6+
/runtime/fastly/build-*/
7+
68
/compute-js/
79
node_modules/
810
.DS_Store
@@ -13,6 +15,7 @@ node_modules/
1315
# compiler_flags
1416
/js-compute-runtime.wasm
1517
/js-compute-runtime-component.wasm
18+
/starling.wasm
1619
/runtime/js-compute-runtime/obj
1720
tests/wpt-harness/wpt-test-runner.js
1821
wpt-runtime.wasm

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@
88
[submodule "runtime/js-compute-runtime/third_party/fmt"]
99
path = runtime/js-compute-runtime/third_party/fmt
1010
url = https://github.com/fmtlib/fmt
11+
[submodule "runtime/StarlingMonkey"]
12+
path = runtime/StarlingMonkey
13+
url = [email protected]:bytecodealliance/StarlingMonkey

integration-tests/js-compute/compare-downstream-response.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export async function compareDownstreamResponse (configResponse, actualResponse)
1616
let errors = [];
1717
// Status
1818
if (configResponse.status != actualResponse.statusCode) {
19-
errors.push(new Error(`[DownstreamResponse: Status mismatch] Expected: ${configResponse.status} - Got: ${actualResponse.status}`));
19+
errors.push(new Error(`[DownstreamResponse: Status mismatch] Expected: ${configResponse.status} - Got: ${actualResponse.statusCode}`));
2020
}
2121

2222
// Headers

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,9 +737,16 @@ routes.set('/btoa', () => {
737737
if (error) { return error; }
738738
error = assertThrows(() => atob("--"))
739739
if (error) { return error; }
740-
error = assertThrows(() => atob("__"))
741-
if (error) { return error; }
742740
}
743741

744742
return pass('ok')
745743
});
744+
745+
routes.set('/btoa-doubleunderscore', () => {
746+
let error;
747+
748+
error = assertThrows(() => atob("__"))
749+
if (error) { return error; }
750+
751+
return pass('ok');
752+
});

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
/* eslint-env serviceworker */
22

3-
import { CacheOverride } from 'fastly:cache-override';
3+
import * as cacheOverride from 'fastly:cache-override';
44
import { routes } from "./routes";
55

6+
const { CacheOverride } = cacheOverride;
7+
68
routes.set('/byte-repeater', () => {
79
let headers = new Headers();
810
headers.set("AssemblyScriptHeader", "AssemblyScriptValue");

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33

44
import { pass, assert, assertDoesNotThrow, assertThrows, sleep, streamToString, assertResolves } from "./assertions.js";
55
import { routes } from "./routes.js";
6-
import { CoreCache, CacheEntry, CacheState, TransactionCacheEntry } from 'fastly:cache';
7-
import { FastlyBody } from "fastly:body";
6+
import { CoreCache, CacheEntry } from 'fastly:cache';
7+
import * as fastlyCache from 'fastly:cache';
8+
import * as fastlyBody from "fastly:body";
9+
10+
const { CacheState, TransactionCacheEntry } = fastlyCache;
11+
const { FastlyBody } = fastlyBody;
812

913
let error;
1014

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { CacheOverride } from 'fastly:cache-override';
1+
import * as cacheOverride from 'fastly:cache-override';
22
import { pass, assert, assertThrows, assertDoesNotThrow } from "./assertions.js";
33
import { isRunningLocally, routes } from "./routes.js";
44

5+
const { CacheOverride } = cacheOverride;
6+
57
// CacheOverride constructor
68
{
79

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
/* eslint-env serviceworker */
33

44
import { pass, assert, assertDoesNotThrow, assertThrows, assertRejects, iteratableToStream, streamToString, assertResolves } from "./assertions.js";
5-
import { SimpleCache, SimpleCacheEntry } from 'fastly:cache';
5+
import { SimpleCache } from 'fastly:cache';
6+
import * as fastlyCache from 'fastly:cache';
67
import { routes, isRunningLocally } from "./routes.js";
78

9+
const { SimpleCacheEntry } = fastlyCache;
10+
811
let error;
912
routes.set("/simple-cache/interface", () => {
1013
let actual = Reflect.ownKeys(SimpleCache)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
/* eslint-env serviceworker */
22
import { pass, assert } from "./assertions.js";
3-
import { ConfigStore } from 'fastly:config-store'
3+
import * as configStore from 'fastly:config-store'
44
import { routes } from "./routes.js";
55

6+
const { ConfigStore } = configStore;
7+
68
routes.set("/config-store", () => {
79
let config = new ConfigStore("testconfig");
810
let twitterValue = config.get("twitter");

0 commit comments

Comments
 (0)