...
1name: Standard Library Integration Tests
2on:
3 pull_request:
4 branches: [main]
5 paths-ignore: # ignore docs as they are built with Netlify.
6 - '**/*.md'
7 - 'site/**'
8 - 'netlify.toml'
9 push:
10 branches: [main]
11 paths-ignore: # ignore docs as they are built with Netlify.
12 - '**/*.md'
13 - 'site/**'
14 - 'netlify.toml'
15
16defaults:
17 run: # use bash for all operating systems unless overridden
18 shell: bash
19
20env: # Update this prior to requiring a higher minor version in go.mod
21 GO_VERSION: "1.21" # 1.xx == latest patch of 1.xx
22 TINYGO_VERSION: "0.30.0"
23 ZIG_VERSION: "0.11.0"
24 BINARYEN_VERSION: "116"
25 STDLIB_TESTS: "internal/integration_test/stdlibs"
26
27concurrency:
28 # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-concurrency-to-cancel-any-in-progress-job-or-run
29 group: ${{ github.ref }}-${{ github.workflow }}-${{ github.actor }}
30 cancel-in-progress: true
31
32jobs:
33 # This builds a zig test binary only if the same version tag hasn't been build before.
34 # This saves time as we rarely update the zig version.
35 build_zig_test_binary:
36 name: Build Zig test binary
37 runs-on: ubuntu-22.04
38 env:
39 ZIG_INSTALL: ~/zig-install
40 ZIG_SOURCE: ~/zig-source
41 BINARYEN_INSTALL: ~/binaryen-install
42
43 steps:
44 - name: Checkout wazero
45 uses: actions/checkout@v3
46
47 - uses: actions/cache@v3
48 id: binary-cache
49 with:
50 # Use share the cache containing archives across OSes.
51 enableCrossOsArchive: true
52 key: zig-stdlib-test-binary-${{ env.ZIG_VERSION }}
53 path:
54 ${{ env.STDLIB_TESTS }}/testdata/zig
55
56 - name: Install Zig build
57 if: steps.binary-cache.outputs.cache-hit != 'true'
58 run: |
59 mkdir -p ${{ env.ZIG_INSTALL }}
60 curl -sSL https://ziglang.org/download/${{ env.ZIG_VERSION }}/zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz | tar -xJ --strip-components=1 -C ${{ env.ZIG_INSTALL }}
61
62 - name: Download Zig source code
63 if: steps.binary-cache.outputs.cache-hit != 'true'
64 run: |
65 mkdir -p ${{ env.ZIG_SOURCE }}
66 curl -sSL https://ziglang.org/download/${{ env.ZIG_VERSION }}/zig-${{ env.ZIG_VERSION }}.tar.xz | tar -xJ --strip-components=1 -C ${{ env.ZIG_SOURCE }}
67
68 - name: Install Binaryen build
69 if: steps.binary-cache.outputs.cache-hit != 'true'
70 run: |
71 mkdir -p ${{ env.BINARYEN_INSTALL }}
72 curl -sSL https://github.com/WebAssembly/binaryen/releases/download/version_${{ env.BINARYEN_VERSION }}/binaryen-version_${{ env.BINARYEN_VERSION }}-x86_64-linux.tar.gz | tar -xz --strip-components=1 -C ${{ env.BINARYEN_INSTALL }}
73
74 - name: Build Stdlib test binary
75 if: steps.binary-cache.outputs.cache-hit != 'true'
76 # --test-no-exec allows building of the test Wasm binary without executing command.
77 # We use find because the test.wasm will be something like ./zig-cache/o/dd6df1361b2134adc5eee9d027495436/test.wasm
78 run: |
79 PATH=${{ env.ZIG_INSTALL }}:${{ env.BINARYEN_INSTALL }}/bin:$PATH
80 cd ${{ env.STDLIB_TESTS }}
81 make build.zig zigroot=${{ env.ZIG_SOURCE }}
82
83 zig:
84 needs: build_zig_test_binary
85 name: Zig (${{ matrix.os }}, ${{ matrix.arch }}, ${{ matrix.compiler }}-compiler)
86 runs-on: ${{ matrix.os }}
87 strategy:
88 fail-fast: false # don't fail fast as sometimes failures are arch/OS specific
89 matrix:
90 os: [ubuntu-22.04, macos-12, windows-2022]
91 compiler: [baseline]
92 arch: [amd64]
93 include:
94 - os: ubuntu-22.04
95 compiler: optimizing
96 arch: "arm64"
97
98 steps:
99 - name: Checkout wazero
100 uses: actions/checkout@v3
101
102 - uses: actions/cache@v3
103 id: binary-cache
104 with:
105 # Use share the cache containing archives across OSes.
106 enableCrossOsArchive: true
107 # We need this cache to run tests.
108 fail-on-cache-miss: true
109 key: zig-stdlib-test-binary-${{ env.ZIG_VERSION }}
110 path:
111 ${{ env.STDLIB_TESTS }}/testdata/zig
112
113 - uses: actions/setup-go@v4
114 with:
115 go-version: ${{ env.GO_VERSION }}
116
117 - if: ${{ matrix.compiler == 'optimizing' }}
118 name: Build wazero
119 run: go build -o ./wazerocli ./cmd/wazero
120 env:
121 GOARCH: ${{ matrix.arch }}
122
123 - name: Set up QEMU
124 if: ${{ matrix.compiler == 'optimizing' && matrix.arch == 'arm64' }}
125 uses: docker/setup-qemu-action@v2
126 with: # Avoid docker.io rate-limits; built with internal-images.yml
127 image: ghcr.io/tetratelabs/wazero/internal-binfmt
128 platforms: ${{ matrix.arch }}
129
130 - name: Build scratch container
131 if: ${{ matrix.compiler == 'optimizing' }}
132 run: |
133 echo 'FROM scratch' >> Dockerfile
134 echo 'CMD ["/test"]' >> Dockerfile
135 docker buildx build -t wazero:test --platform linux/${{ matrix.arch }} .
136
137
138 # The following two steps run the previously compiled Zig tests with wazero.
139 # If you need to troubleshoot any of the test, you can add "-hostlogging=filesystem" after
140 # adding filter argument either to step "Run built test binaries" or
141 # "Run built test binaries (container)".
142 # e.g. --test-filter "Dir.Iterator but dir is deleted during iteration"
143
144 - name: Run built test binaries (container)
145 if: ${{ matrix.compiler == 'optimizing' }}
146 run: |
147 docker run --platform linux/${{ matrix.arch }} -v $(pwd)/${{ env.STDLIB_TESTS }}/testdata/zig:/test -v $(pwd)/wazerocli:/wazero -e WAZEROCLI=/wazero --tmpfs /tmp --rm -t wazero:test \
148 /wazero run -optimizing-compiler -mount=:/ ./test/test.wasm
149
150 - name: Run built test binaries
151 if: ${{ matrix.compiler != 'optimizing' }}
152 run: |
153 cd ${{ env.STDLIB_TESTS }}
154 go test -bench='BenchmarkZig' -benchtime=1x
155
156 build_tinygo_test_binary:
157 name: Build TinyGo test binary
158 runs-on: ubuntu-22.04
159 steps:
160 - name: Checkout wazero
161 uses: actions/checkout@v3
162
163 - uses: actions/cache@v3
164 id: binary-cache
165 with:
166 # Use share the cache containing archives across OSes.
167 enableCrossOsArchive: true
168 key: tinygo-test-binaries-${{ env.TINYGO_VERSION }}
169 path:
170 ${{ env.STDLIB_TESTS }}/testdata/tinygo
171
172 - name: Install TinyGo
173 if: steps.binary-cache.outputs.cache-hit != 'true'
174 run: | # installing via curl so commands are similar on OS/x
175 tinygo_version=${{ env.TINYGO_VERSION }}
176 curl -sSL https://github.com/tinygo-org/tinygo/releases/download/v${tinygo_version}/tinygo${tinygo_version}.linux-amd64.tar.gz | sudo tar -C /usr/local -xzf -
177 echo "TINYGOROOT=/usr/local/tinygo" >> $GITHUB_ENV
178 echo "/usr/local/tinygo/bin" >> $GITHUB_PATH
179
180 - uses: actions/setup-go@v4
181 if: steps.binary-cache.outputs.cache-hit != 'true'
182 with:
183 go-version: ${{ env.GO_VERSION }}
184
185 - name: Build Test Binaries
186 if: steps.binary-cache.outputs.cache-hit != 'true'
187 # The following list of packages is derived from:
188 # https://github.com/tinygo-org/tinygo/blob/v0.28.1/Makefile#L281-L322
189 # Note:
190 # - index/suffixarray is extremely slow, so skip it.
191 # - compress/zlib is skipped as it depends on the local files https://github.com/golang/go/blob/go1.20/src/compress/zlib/writer_test.go#L16-L30
192 # - debug/macho is skipped as it depends on the local files https://github.com/golang/go/blob/go1.20/src/debug/macho/file_test.go#L25
193 run: |
194 cd ${{ env.STDLIB_TESTS }}
195 make build.tinygo
196
197 tinygo:
198 needs: build_tinygo_test_binary
199 name: TinyGo (${{ matrix.os }}, ${{ matrix.arch }}, ${{ matrix.compiler }}-compiler)
200 runs-on: ${{ matrix.os }}
201 strategy:
202 fail-fast: false # don't fail fast as sometimes failures are arch/OS specific
203 matrix:
204 os: [ubuntu-22.04, macos-12, windows-2022]
205 compiler: [baseline]
206 arch: [amd64]
207 include:
208 - os: ubuntu-22.04
209 compiler: optimizing
210 arch: "arm64"
211
212 steps:
213 - name: Checkout wazero
214 uses: actions/checkout@v3
215
216 - uses: actions/cache@v3
217 id: binary-cache
218 with:
219 # Use share the cache containing archives across OSes.
220 enableCrossOsArchive: true
221 # We need this cache to run tests.
222 fail-on-cache-miss: true
223 key: tinygo-test-binaries-${{ env.TINYGO_VERSION }}
224 path:
225 ${{ env.STDLIB_TESTS }}/testdata/tinygo
226
227 - uses: actions/setup-go@v4
228 with:
229 go-version: ${{ env.GO_VERSION }}
230
231 - if: ${{ matrix.compiler == 'optimizing' }}
232 name: Build wazero
233 run: go build -o ~/wazerocli ./cmd/wazero
234 env:
235 GOARCH: ${{ matrix.arch }}
236
237 - name: Set up QEMU
238 if: ${{ matrix.compiler == 'optimizing' && matrix.arch == 'arm64' }}
239 uses: docker/setup-qemu-action@v2
240 with: # Avoid docker.io rate-limits; built with internal-images.yml
241 image: ghcr.io/tetratelabs/wazero/internal-binfmt
242 platforms: ${{ matrix.arch }}
243
244 - name: Build scratch container
245 if: ${{ matrix.compiler == 'optimizing' }}
246 run: |
247 echo 'FROM scratch' >> Dockerfile
248 echo 'CMD ["/test"]' >> Dockerfile
249 docker buildx build -t wazero:test --platform linux/${{ matrix.arch }} .
250
251 # The following steps run the previously compiled TinyGo tests with wazero. If you need
252 # to troubleshoot one, you can add "-hostlogging=filesystem" and also a
253 # trailing argument narrowing which test to execute.
254 # e.g. "-test.run '^TestStatBadDir$'"
255
256 - name: Run test binaries (container)
257 if: ${{ matrix.compiler == 'optimizing' }}
258 # This runs all tests compiled above in sequence. Note: This mounts /tmp to allow t.TempDir() in tests.
259 run: |
260 cd ${{ env.STDLIB_TESTS }}/testdata/tinygo
261 for bin in *.test; do
262 echo $bin
263 docker run --platform linux/${{ matrix.arch }} -v $(pwd):/test -v ~/wazerocli:/wazero -e WAZEROCLI=/wazero --tmpfs /tmp --rm -t wazero:test \
264 /wazero run -optimizing-compiler -mount=:/ /test/$bin -- -test.v
265 done
266
267 - name: Run test binaries
268 if: ${{ matrix.compiler != 'optimizing' }}
269 run: |
270 cd ${{ env.STDLIB_TESTS }}
271 go test -bench='BenchmarkTinyGo' -benchtime=1x
272
273 wasi-testsuite:
274 name: wasi-testsuite
275 runs-on: ${{ matrix.os }}
276 strategy:
277 fail-fast: false # don't fail fast as sometimes failures are arch/OS specific
278 matrix:
279 os: [ubuntu-22.04, macos-12, windows-2022]
280
281 steps:
282 - uses: actions/cache@v3
283 id: cache
284 with:
285 path:
286 ~/go/pkg/mod
287 key: integration-test-wasi-testsuite-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }}
288
289 - uses: actions/setup-go@v4
290 with:
291 go-version: ${{ env.GO_VERSION }}
292
293 - name: Checkout wazero
294 uses: actions/checkout@v3
295
296 - name: Install wazero
297 run: go install ./cmd/wazero
298
299 - name: Checkout wasi-testsuite
300 uses: actions/checkout@v3
301 with:
302 repository: WebAssembly/wasi-testsuite
303 # prod/testsuite-base branch, as of May 12, 2023.
304 # TODO: once the wasi-testsuite is stable, we should use the latest tag instead of a branch.
305 ref: c9c751586fd86b321d595bbef13f2c7403cfdbc5
306 path: wasi-testsuite
307
308 - name: Initialize Python environment
309 uses: actions/setup-python@v4
310 with:
311 python-version: '3.11' # latest version of python 3
312 cache: pip
313
314 - name: Install dependencies
315 working-directory: wasi-testsuite/test-runner
316 run: |
317 python3 -m pip install -r requirements.txt
318
319 - name: Run all wasi-testsuite
320 working-directory: wasi-testsuite
321 run: |
322 python3 test-runner/wasi_test_runner.py \
323 -t ./tests/assemblyscript/testsuite/ \
324 ./tests/c/testsuite/ \
325 ./tests/rust/testsuite/ \
326 -f ../.github/wasi_testsuite_skip.json \
327 -r ../.github/wasi_testsuite_adapter.py
328
329 gojs_stdlib:
330 name: Go (js) (${{ matrix.os }})
331 runs-on: ${{ matrix.os }}
332 strategy:
333 fail-fast: false # don't fail fast as sometimes failures are arch/OS specific
334 matrix:
335 os: [ubuntu-22.04, macos-12] # GOOS=js isn't supposed to work on windows. See #1222
336
337 steps:
338 - uses: actions/setup-go@v4
339 with:
340 go-version: ${{ env.GO_VERSION }}
341
342 - name: Checkout wazero
343 uses: actions/checkout@v3
344
345 - name: Install wazero
346 run: go install ./cmd/wazero
347
348 - name: Build gojs test binaries
349 env:
350 GOOS: js
351 GOARCH: wasm
352 run: | # Only test os package as this is being replaced by GOOS=wasip1
353 mkdir ~/bin && cd ~/bin
354 go test -c -o os.wasm os
355
356 - name: Run tests
357 run: | # skip tests that use functionality not also used in GOOS=wasip1
358 cd $(go env GOROOT)/src/os; wazero run -mount=/:/ ~/bin/os.wasm -test.v -test.skip '^Test(Chmod|Truncate|LongPath|Chown|FileChown).*$'
359
360 go_tests:
361 # Due to the embedding of the GOROOT of the building env(https://github.com/golang/go/blob/3c59639b902fada0a2e5a6a35bafd10fc9183b89/src/os/os_test.go#L112),
362 # we have to build and cache on each OS unlike others in this file.
363 name: Go (${{ matrix.os }}, Go-${{ matrix.go-version }}, ${{ matrix.arch }}, ${{ matrix.compiler }}-compiler)
364 runs-on: ${{ matrix.os }}
365 strategy:
366 fail-fast: false # don't fail fast as sometimes failures are arch/OS specific
367 matrix:
368 os: [ubuntu-22.04, macos-12, windows-2022]
369 compiler: [baseline]
370 arch: [amd64]
371 go-version:
372 - "1.21" # Current Go version && The only version that supports wasip1.
373 include:
374 - os: ubuntu-22.04
375 compiler: optimizing
376 arch: "arm64"
377 go-version: "1.21"
378 steps:
379 - id: setup-go
380 uses: actions/setup-go@v4
381 with:
382 go-version: ${{ matrix.go-version }}
383
384 - name: Checkout wazero
385 uses: actions/checkout@v3
386
387 - name: Cache Go test binaries
388 id: cache-go-test-binaries
389 uses: actions/cache@v3
390 with:
391 path:
392 ${{ env.STDLIB_TESTS }}/testdata/go
393 # Use precise Go version from setup-go as patch version differences can effect tests.
394 key: go-wasip1-binaries-${{ matrix.os }}-${{ steps.setup-go.outputs.go-version }}-${{ matrix.arch }}
395
396 - if: ${{ matrix.compiler == 'optimizing' }}
397 name: Build wazero
398 run: go build -o ~/wazerocli ./cmd/wazero
399 env:
400 GOARCH: ${{ matrix.arch }}
401
402 - if: ${{ steps.cache-go-test-binaries.outputs.cache-hit != 'true' }}
403 name: Build Test Binaries
404 run: |
405 cd ${{ env.STDLIB_TESTS }}
406 make build.gowasip1
407
408 - name: Set up QEMU
409 if: ${{ matrix.compiler == 'optimizing' && matrix.arch == 'arm64' }}
410 uses: docker/setup-qemu-action@v2
411 with: # Avoid docker.io rate-limits; built with internal-images.yml
412 image: ghcr.io/tetratelabs/wazero/internal-binfmt
413 platforms: ${{ matrix.arch }}
414
415 - name: Build scratch container
416 if: ${{ matrix.compiler == 'optimizing' }}
417 run: |
418 echo 'FROM scratch' >> Dockerfile
419 echo 'CMD ["/test"]' >> Dockerfile
420 docker buildx build -t wazero:test --platform linux/${{ matrix.arch }} .
421
422 - if: ${{ matrix.compiler == 'optimizing' }}
423 name: Run test binaries (container)
424 run: |
425 echo "Running $(find ${{ env.STDLIB_TESTS }}/testdata/go -name '*.test' | wc -l) test binaries"
426
427 # Skip tests that are hideously slow (mostly compilation time) for running inside QEMU.
428 skip_targets="src_encoding_json|src_runtime|src_os_exec|src_math_big|src_encoding_gob|src_time|src_archive_tar|src_math_rand|src_expvar|src_testing|src_os"
429 # Go tests often look for files relative to the source. Change to the corresponding directory.
430 for bin in $(find $PWD/${{ env.STDLIB_TESTS }}/testdata/go -name '*.test' | grep -vE "$skip_targets"); do
431 dir=$(basename $bin); dir=${dir%.test}; dir=${dir//_/\/}
432 pushd $(go env GOROOT)/$dir
433 # Mount / as /ROOT in docker and then remount /ROOT as / in wazero; $bin is now in /ROOT/$bin.
434 docker run --platform linux/arm64 -v /:/ROOT -v ~/wazerocli:/wazero -e WAZEROCLI=/wazero --tmpfs /tmp --rm -t wazero:test \
435 /wazero run -optimizing-compiler -mount=/ROOT:/ -mount=/tmp:/tmp -env PWD=$PWD /ROOT/$bin -- -test.short -test.v
436 popd
437 done
438
439 - name: Run built test binaries
440 if: ${{ matrix.compiler != 'optimizing' }}
441 run: |
442 cd ${{ env.STDLIB_TESTS }}
443 go test -bench='BenchmarkWasip1' -benchtime=1x
View as plain text