Skip to content

Fix SimpleCache example #2930

Fix SimpleCache example

Fix SimpleCache example #2930

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.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-19 (linux)"
run: |
set -x
curl -sS -L -O https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz
tar xf wasi-sdk-19.0-linux.tar.gz
sudo mkdir -p /opt/wasi-sdk
sudo mv wasi-sdk-19.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
- name: Locate component resources
run: |
cp runtime/js-compute-runtime/fastly.wit .
- 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 }}