Skip to content

wasi:[email protected]: Add tests for read/write/append #504

wasi:[email protected]: Add tests for read/write/append

wasi:[email protected]: Add tests for read/write/append #504

Workflow file for this run

name: Compile tests
on:
push:
branches:
- main
pull_request:
branches:
- '*'
paths:
- 'tests/**'
- '.github/workflows/compile-tests.yml'
jobs:
build_assemblyscript:
name: Build Assemblyscript tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest, windows-11-arm]
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Initialize node.js environment
uses: actions/setup-node@v3
with:
node-version: 22
- name: Build tests
working-directory: tests/assemblyscript
run: |
./build.py
- name: Upload precompiled tests
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: assemblyscript-testsuite
path: tests/assemblyscript/testsuite
if-no-files-found: error
include-hidden-files: true
build_rust:
name: Build Rust tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest, windows-11-arm]
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Install nightly wasm32-wasip2 target for Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
target: wasm32-wasip2
- name: Install stable wasm32-wasip1 target for Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
target: wasm32-wasip1
- name: Build tests
working-directory: tests/rust
run: |
./build.py --toolchain=wasm32-wasip3:nightly
- name: 'Tar files'
if: matrix.os == 'ubuntu-latest'
run: tar -cvf rust-testsuite.tar tests/rust/testsuite
- name: Upload precompiled tests
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: rust-testsuite
path: rust-testsuite.tar
build_c:
name: Build C tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest, windows-11-arm]
env:
WASI_VERSION: 27
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Setup WASI SDK download - Linux
if: matrix.os == 'ubuntu-latest'
run: echo SYSTEM_NAME=x86_64-linux >> $GITHUB_ENV
- name: Setup WASI SDK download - MacOS
if: matrix.os == 'macos-latest'
run: echo SYSTEM_NAME=arm64-macos >> $GITHUB_ENV
- name: Setup WASI SDK download - Windows (x86)
if: matrix.os == 'windows-latest'
run: echo SYSTEM_NAME=x86_64-windows >> $env:GITHUB_ENV
- name: Setup WASI SDK download - Windows (ARM)
if: matrix.os == 'windows-11-arm'
run: echo SYSTEM_NAME=arm64-windows >> $env:GITHUB_ENV
- name: Download WASI SDK
working-directory: tests/c
shell: bash
run: curl -L -f https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION}.0-${SYSTEM_NAME}.tar.gz --output wasi-sdk.tar.gz
- name: Install WASI SDK
working-directory: tests/c
shell: bash
run: tar xvf wasi-sdk.tar.gz
- name: Check formatting
if: matrix.os == 'ubuntu-latest'
working-directory: tests/c
run: find testsuite -regex '.*\.\(c\|h\)' -print0 | xargs -0 -n1 ./wasi-sdk-${WASI_VERSION}.0-${SYSTEM_NAME}/bin/clang-format --style=file --dry-run -Werror
- name: Build tests
shell: bash
working-directory: tests/c
run: CC="./wasi-sdk-${WASI_VERSION}.0-${SYSTEM_NAME}/bin/clang" ./build.py
- name: Upload precompiled tests
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: c-testsuite
path: tests/c/testsuite
if-no-files-found: error
include-hidden-files: true
run_tests:
name: Run tests
runs-on: ${{ matrix.os }}
needs: [build_assemblyscript, build_c, build_rust]
env:
WASMTIME_VERSION: v37.0.1
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest, windows-11-arm]
runtime: [wasmtime]
steps:
- name: Check out repository code
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.sha }}
- name: Initialize Python environment
uses: actions/setup-python@v4
with:
python-version: '3.12'
cache: pip
- name: Install dependencies
working-directory: test-runner
run: pip install -r requirements.txt
- name: Install wasmtime
if: matrix.runtime == 'wasmtime' && matrix.os == 'windows-latest'
run: |
$url = "https://github.com/bytecodealliance/wasmtime/releases/download/$env:WASMTIME_VERSION/wasmtime-$env:WASMTIME_VERSION-x86_64-windows.zip"
Write-Host "URL: $url"
Invoke-WebRequest -Uri $url -OutFile "wasmtime.zip"
Expand-Archive -Path "wasmtime.zip" -DestinationPath "."
echo "$env:GITHUB_WORKSPACE\wasmtime-$env:WASMTIME_VERSION-x86_64-windows" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Install wasmtime
if: matrix.runtime == 'wasmtime' && matrix.os == 'windows-11-arm'
run: |
$url = "https://github.com/bytecodealliance/wasmtime/releases/download/$env:WASMTIME_VERSION/wasmtime-$env:WASMTIME_VERSION-aarch64-windows.zip"
Write-Host "URL: $url"
Invoke-WebRequest -Uri $url -OutFile "wasmtime.zip"
Expand-Archive -Path "wasmtime.zip" -DestinationPath "."
echo "$env:GITHUB_WORKSPACE\wasmtime-$env:WASMTIME_VERSION-aarch64-windows" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Install wasmtime
if: matrix.runtime == 'wasmtime' && (matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest')
run: |
set -e
curl https://wasmtime.dev/install.sh -sSf | bash -s -- --version $WASMTIME_VERSION
echo "$HOME/.wasmtime/bin" >> $GITHUB_PATH
- name: Download Rust test binaries
uses: actions/download-artifact@v4
with:
name: rust-testsuite
- name: Download C test binaries
uses: actions/download-artifact@v4
with:
name: c-testsuite
path: ./tests/c/testsuite
- name: Download AssemblyScript test binaries
uses: actions/download-artifact@v4
with:
name: assemblyscript-testsuite
path: ./tests/assemblyscript/testsuite
- name: Untar tests
run: |
tar -xvf rust-testsuite.tar
- name: Run tests
continue-on-error: true
run: |
python run-tests --verbose --runtime adapters/${{ matrix.runtime }}.py
upload_test_binaries:
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
runs-on: ubuntu-latest
needs: [build_assemblyscript, build_c, build_rust]
strategy:
max-parallel: 1
matrix:
suite: [assemblyscript, c, rust]
steps:
- name: Check out repository code
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: prod/testsuite-base
- name: Configure git
uses: ./.github/actions/git-config
- name: Merge main branch changes
run: |
git merge --no-commit --strategy ours ${{ github.sha }}
git checkout --no-overlay ${{ github.sha }} .
git checkout HEAD tests/assemblyscript/testsuite
git checkout HEAD tests/c/testsuite
git checkout HEAD tests/rust/testsuite
git diff --quiet HEAD || git commit -m "Merge commit ${{ github.sha }} into prod/testsuite-base"
- name: Remove existing binaries
run: rm -rf tests/${{ matrix.suite }}/testsuite
- name: Download ${{ matrix.suite }} test binaries
uses: actions/download-artifact@v4
with:
name: ${{ matrix.suite }}-testsuite
path: ./tests/${{ matrix.suite }}/testsuite
- name: Untar tests
if: ${{ matrix.suite }} == 'rust'
run: |
tar -xvf ${{ matrix.suite }}-testsuite.tar
- name: Publish changes to consumer branch
shell: bash
run: |
git add -f tests/${{ matrix.suite }}/testsuite
git diff --quiet HEAD || git commit -m "Update test binaries for ${{ matrix.suite }} test suite"
git push