Skip to content

Complete StarlingMonkey SDK Tests #4046

Complete StarlingMonkey SDK Tests

Complete StarlingMonkey SDK Tests #4046

Workflow file for this run

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:
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: 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]
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
# 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: 'engine-debug'
- 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]
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
- 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 }}