Skip to content

Commit d1a979e

Browse files
authored
Merge pull request #171 from wingo/pr-ci
Run tests in pull requests as part of CI
2 parents 2e683c8 + 527a748 commit d1a979e

File tree

3 files changed

+84
-1
lines changed

3 files changed

+84
-1
lines changed

.github/workflows/compile-tests.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
pull_request:
88
branches:
99
- '*'
10+
paths:
11+
- 'tests/**'
1012

1113
jobs:
1214
build_assemblyscript:
@@ -131,6 +133,81 @@ jobs:
131133
if-no-files-found: error
132134
include-hidden-files: true
133135

136+
run_tests:
137+
name: Run tests
138+
runs-on: ${{ matrix.os }}
139+
needs: [build_assemblyscript, build_c, build_rust]
140+
env:
141+
WASMTIME_VERSION: v37.0.1
142+
strategy:
143+
matrix:
144+
os: [ubuntu-latest, windows-latest, macos-latest, windows-11-arm]
145+
runtime: [wasmtime]
146+
steps:
147+
- name: Check out repository code
148+
uses: actions/checkout@v3
149+
with:
150+
fetch-depth: 0
151+
ref: ${{ github.sha }}
152+
153+
- name: Initialize Python environment
154+
uses: actions/setup-python@v4
155+
with:
156+
python-version: '3.12'
157+
cache: pip
158+
159+
- name: Install dependencies
160+
working-directory: test-runner
161+
run: pip install -r requirements.txt
162+
163+
- name: Install wasmtime
164+
if: matrix.runtime == 'wasmtime' && matrix.os == 'windows-latest'
165+
run: |
166+
$url = "https://github.com/bytecodealliance/wasmtime/releases/download/$env:WASMTIME_VERSION/wasmtime-$env:WASMTIME_VERSION-x86_64-windows.zip"
167+
Write-Host "URL: $url"
168+
Invoke-WebRequest -Uri $url -OutFile "wasmtime.zip"
169+
Expand-Archive -Path "wasmtime.zip" -DestinationPath "."
170+
echo "$env:GITHUB_WORKSPACE\wasmtime-$env:WASMTIME_VERSION-x86_64-windows" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
171+
172+
- name: Install wasmtime
173+
if: matrix.runtime == 'wasmtime' && matrix.os == 'windows-11-arm'
174+
run: |
175+
$url = "https://github.com/bytecodealliance/wasmtime/releases/download/$env:WASMTIME_VERSION/wasmtime-$env:WASMTIME_VERSION-aarch64-windows.zip"
176+
Write-Host "URL: $url"
177+
Invoke-WebRequest -Uri $url -OutFile "wasmtime.zip"
178+
Expand-Archive -Path "wasmtime.zip" -DestinationPath "."
179+
echo "$env:GITHUB_WORKSPACE\wasmtime-$env:WASMTIME_VERSION-aarch64-windows" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
180+
181+
- name: Install wasmtime
182+
if: matrix.runtime == 'wasmtime' && (matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest')
183+
run: |
184+
set -e
185+
curl https://wasmtime.dev/install.sh -sSf | bash -s -- --version $WASMTIME_VERSION
186+
echo "$HOME/.wasmtime/bin" >> $GITHUB_PATH
187+
188+
- name: Download Rust test binaries
189+
uses: actions/download-artifact@v4
190+
with:
191+
name: rust-testsuite
192+
path: ./tests/rust/testsuite
193+
194+
- name: Download C test binaries
195+
uses: actions/download-artifact@v4
196+
with:
197+
name: c-testsuite
198+
path: ./tests/c/testsuite
199+
200+
- name: Download AssemblyScript test binaries
201+
uses: actions/download-artifact@v4
202+
with:
203+
name: assemblyscript-testsuite
204+
path: ./tests/assemblyscript/testsuite
205+
206+
- name: Run tests
207+
continue-on-error: true
208+
run: |
209+
python run-tests --verbose --runtime adapters/${{ matrix.runtime }}.py
210+
134211
upload_test_binaries:
135212
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
136213
runs-on: ubuntu-latest

run-tests

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,5 @@ else:
8888
sys.exit(run_tests(runtime_adapters, test_suite,
8989
color=not options.disable_colors,
9090
json_log_file=options.json_output_location,
91+
verbose=options.verbose,
9192
exclude_filters=options.exclude_filter))

test-runner/wasi_test_runner/harness.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@
1212
from .validators import exit_code_validator, stdout_validator, Validator
1313

1414

15+
# too-many-positional-arguments is a post-3.0 pylint message.
16+
# pylint: disable-msg=unknown-option-value
17+
# pylint: disable-msg=too-many-arguments
18+
# pylint: disable-msg=too-many-positional-arguments
1519
def run_tests(runtimes: List[RuntimeAdapter],
1620
test_suite_paths: List[Path],
1721
exclude_filters: List[Path] | None = None,
1822
color: bool = True,
23+
verbose: bool = False,
1924
json_log_file: str | None = None) -> int:
2025
validators: List[Validator] = [exit_code_validator, stdout_validator]
21-
reporters: List[TestReporter] = [ConsoleTestReporter(color)]
26+
reporters: List[TestReporter] = [ConsoleTestReporter(color, verbose=verbose)]
2227
if json_log_file:
2328
reporters.append(JSONTestReporter(json_log_file))
2429
filters: List[TestFilter] = [UnsupportedWasiTestExcludeFilter()]

0 commit comments

Comments
 (0)