-
Notifications
You must be signed in to change notification settings - Fork 41
261 lines (221 loc) · 7.7 KB
/
compile-tests.yml
File metadata and controls
261 lines (221 loc) · 7.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
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: Run `cargo-fmt`
run: |
cargo fmt --manifest-path ./tests/rust/wasm32-wasip3/Cargo.toml --check
cargo fmt --manifest-path ./tests/rust/wasm32-wasip1/Cargo.toml --check
- name: Build tests
working-directory: tests/rust
run: |
./build.py
- 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: dev
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'
uses: bytecodealliance/actions/wasmtime/setup@v1
with:
version: ${{ env.WASMTIME_VERSION }}
- 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]
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/assemblyscript/testsuite
rm -rf tests/c/testsuite
rm -rf tests/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: Download Rust test binaries
uses: actions/download-artifact@v4
with:
name: rust-testsuite
- name: Untar tests
run: |
tar -xvf rust-testsuite.tar
rm rust-testsuite.tar
- name: Publish changes to consumer branch
shell: bash
run: |
git add -f tests/assemblyscript/testsuite
git add -f tests/c/testsuite
git add -f tests/rust/testsuite
git diff --quiet HEAD || git commit -m "Update prebuilt test binaries after commit ${{ github.sha }}"
git push