@@ -21,6 +21,8 @@ env: # Update this prior to requiring a higher minor version in go.mod
2121 GO_VERSION : " 1.21" # 1.xx == latest patch of 1.xx
2222 TINYGO_VERSION : " 0.30.0"
2323 ZIG_VERSION : " 0.11.0"
24+ BINARYEN_VERSION : " 116"
25+ STDLIB_TESTS : " internal/integration_test/stdlibs"
2426
2527concurrency :
2628 # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-concurrency-to-cancel-any-in-progress-job-or-run
3638 env :
3739 ZIG_INSTALL : ~/zig-install
3840 ZIG_SOURCE : ~/zig-source
41+ BINARYEN_INSTALL : ~/binaryen-install
3942
4043 steps :
4144 - name : Checkout wazero
4851 enableCrossOsArchive : true
4952 key : zig-stdlib-test-binary-${{ env.ZIG_VERSION }}
5053 path :
51- ./zigbin/
54+ ${{ env.STDLIB_TESTS }}/testdata/zig
5255
5356 - name : Install Zig build
5457 if : steps.binary-cache.outputs.cache-hit != 'true'
@@ -62,16 +65,20 @@ jobs:
6265 mkdir -p ${{ env.ZIG_SOURCE }}
6366 curl -sSL https://ziglang.org/download/${{ env.ZIG_VERSION }}/zig-${{ env.ZIG_VERSION }}.tar.xz | tar -xJ --strip-components=1 -C ${{ env.ZIG_SOURCE }}
6467
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+
6574 - name : Build Stdlib test binary
6675 if : steps.binary-cache.outputs.cache-hit != 'true'
6776 # --test-no-exec allows building of the test Wasm binary without executing command.
6877 # We use find because the test.wasm will be something like ./zig-cache/o/dd6df1361b2134adc5eee9d027495436/test.wasm
6978 run : |
70- mkdir ${{ github.workspace }}/zigbin
71- cd ${{ env.ZIG_SOURCE }}
72- ${{ env.ZIG_INSTALL }}/zig test --test-no-exec -target wasm32-wasi --zig-lib-dir ./lib ./lib/std/std.zig
73- _ZIG_TEST_BINARY_PATH=$(find . -name test.wasm)
74- cp ${_ZIG_TEST_BINARY_PATH} ${{ github.workspace }}/zigbin/test.wasm
79+ PATH=${{ env.ZIG_INSTALL }}:${{ env.BINARYEN_INSTALL }}/bin:$PATH
80+ cd ${{ env.STDLIB_TESTS }}
81+ make build.zig zigroot=${{ env.ZIG_SOURCE }}
7582
7683 zig :
7784 needs : build_zig_test_binary
@@ -101,13 +108,14 @@ jobs:
101108 fail-on-cache-miss : true
102109 key : zig-stdlib-test-binary-${{ env.ZIG_VERSION }}
103110 path :
104- ./zigbin/
111+ ${{ env.STDLIB_TESTS }}/testdata/zig
105112
106113 - uses : actions/setup-go@v4
107114 with :
108115 go-version : ${{ env.GO_VERSION }}
109116
110- - name : Build wazero
117+ - if : ${{ matrix.compiler == 'optimizing' }}
118+ name : Build wazero
111119 run : go build -o ./wazerocli ./cmd/wazero
112120 env :
113121 GOARCH : ${{ matrix.arch }}
@@ -136,12 +144,15 @@ jobs:
136144 - name : Run built test binaries (container)
137145 if : ${{ matrix.compiler == 'optimizing' }}
138146 run : |
139- docker run --platform linux/${{ matrix.arch }} -v $(pwd)/zigbin :/test -v $(pwd)/wazerocli:/wazero -e WAZEROCLI=/wazero --tmpfs /tmp --rm -t wazero:test \
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 \
140148 /wazero run -optimizing-compiler -mount=:/ ./test/test.wasm
141149
142150 - name : Run built test binaries
143151 if : ${{ matrix.compiler != 'optimizing' }}
144- run : ./wazerocli run -mount=:/ ./zigbin/test.wasm
152+ run : |
153+ cd ${{ env.STDLIB_TESTS }}
154+ go test -bench='./zig' -benchtime=1x
155+
145156
146157 build_tinygo_test_binary :
147158 name : Build TinyGo test binary
@@ -157,7 +168,7 @@ jobs:
157168 enableCrossOsArchive : true
158169 key : tinygo-test-binaries-${{ env.TINYGO_VERSION }}
159170 path :
160- ./tinygobin/
171+ ${{ env.STDLIB_TESTS }}/testdata/tinygo
161172
162173 - name : Install TinyGo
163174 if : steps.binary-cache.outputs.cache-hit != 'true'
@@ -181,48 +192,8 @@ jobs:
181192 # - 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
182193 # - 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
183194 run : |
184- mkdir ./tinygobin
185- for value in container/heap \
186- container/list \
187- container/ring \
188- crypto/des \
189- crypto/md5 \
190- crypto/rc4 \
191- crypto/sha1 \
192- crypto/sha256 \
193- crypto/sha512 \
194- embed/internal/embedtest \
195- encoding \
196- encoding/ascii85 \
197- encoding/base32 \
198- encoding/csv \
199- encoding/hex \
200- go/scanner \
201- hash \
202- hash/adler32 \
203- hash/crc64 \
204- hash/fnv \
205- html \
206- internal/itoa \
207- internal/profile \
208- math \
209- math/cmplx \
210- net \
211- net/http/internal/ascii \
212- net/mail \
213- os \
214- path \
215- reflect \
216- sync \
217- testing \
218- testing/iotest \
219- text/scanner \
220- unicode \
221- unicode/utf16 \
222- unicode/utf8
223- do
224- tinygo test -target wasi -c -o ./tinygobin/${value/\//_}.test $value
225- done
195+ cd ${{ env.STDLIB_TESTS }}
196+ make build.tinygo
226197
227198 tinygo :
228199 needs : build_tinygo_test_binary
@@ -252,13 +223,14 @@ jobs:
252223 fail-on-cache-miss : true
253224 key : tinygo-test-binaries-${{ env.TINYGO_VERSION }}
254225 path :
255- ./tinygobin/
226+ ${{ env.STDLIB_TESTS }}/testdata/tinygo
256227
257228 - uses : actions/setup-go@v4
258229 with :
259230 go-version : ${{ env.GO_VERSION }}
260231
261- - name : Build wazero
232+ - if : ${{ matrix.compiler == 'optimizing' }}
233+ name : Build wazero
262234 run : go build -o ~/wazerocli ./cmd/wazero
263235 env :
264236 GOARCH : ${{ matrix.arch }}
@@ -286,7 +258,7 @@ jobs:
286258 if : ${{ matrix.compiler == 'optimizing' }}
287259 # This runs all tests compiled above in sequence. Note: This mounts /tmp to allow t.TempDir() in tests.
288260 run : |
289- cd ./tinygobin
261+ cd ${{ env.STDLIB_TESTS }}/testdata/tinygo
290262 for bin in *.test; do
291263 echo $bin
292264 docker run --platform linux/${{ matrix.arch }} -v $(pwd):/test -v ~/wazerocli:/wazero -e WAZEROCLI=/wazero --tmpfs /tmp --rm -t wazero:test \
@@ -296,11 +268,8 @@ jobs:
296268 - name : Run test binaries
297269 if : ${{ matrix.compiler != 'optimizing' }}
298270 run : |
299- cd ./tinygobin
300- for bin in *.test; do
301- echo $bin
302- ~/wazerocli run -mount=:/ -mount=:/tmp $bin -- -test.v
303- done
271+ cd ${{ env.STDLIB_TESTS }}
272+ go test -bench='./tinygo' -benchtime=1x
304273
305274 wasi-testsuite :
306275 name : wasi-testsuite
@@ -413,96 +382,30 @@ jobs:
413382 with :
414383 go-version : ${{ matrix.go-version }}
415384
385+ - name : Checkout wazero
386+ uses : actions/checkout@v3
387+
416388 - name : Cache Go test binaries
417389 id : cache-go-test-binaries
418390 uses : actions/cache@v3
419391 with :
420- path : ~/tests
392+ path :
393+ ${{ env.STDLIB_TESTS }}/testdata/go
421394 # Use precise Go version from setup-go as patch version differences can effect tests.
422395 key : go-wasip1-binaries-${{ matrix.os }}-${{ steps.setup-go.outputs.go-version }}
423396
424- - if : ${{ steps.cache-go-test-binaries.outputs.cache-hit != 'true' }}
425- name : Build Test Binaries
426- run : |
427- mkdir ~/tests
428- cd $(go env GOROOT)
429- # Choose important packages to limit execution time.
430- for value in src/archive/tar \
431- src/bufio \
432- src/bytes \
433- src/context \
434- src/encoding/ascii85 \
435- src/encoding/asn1 \
436- src/encoding/base32 \
437- src/encoding/base64 \
438- src/encoding/binary \
439- src/encoding/csv \
440- src/encoding/gob \
441- src/encoding/hex \
442- src/encoding/json \
443- src/encoding/pem \
444- src/encoding/xml \
445- src/errors \
446- src/expvar \
447- src/flag \
448- src/fmt \
449- src/hash \
450- src/hash/adler32 \
451- src/hash/crc32 \
452- src/hash/crc64 \
453- src/hash/fnv \
454- src/hash/maphash \
455- src/io \
456- src/io/fs \
457- src/io/ioutil \
458- src/log \
459- src/log/syslog \
460- src/maps \
461- src/math \
462- src/math/big \
463- src/math/bits \
464- src/math/cmplx \
465- src/math/rand \
466- src/mime \
467- src/mime/multipart \
468- src/mime/quotedprintable \
469- src/os \
470- src/os/exec \
471- src/os/signal \
472- src/os/user \
473- src/path \
474- src/reflect \
475- src/regexp \
476- src/regexp/syntax \
477- src/runtime \
478- src/runtime/internal/atomic \
479- src/runtime/internal/math \
480- src/runtime/internal/sys \
481- src/slices \
482- src/sort \
483- src/strconv \
484- src/strings \
485- src/sync \
486- src/sync/atomic \
487- src/syscall \
488- src/testing \
489- src/testing/fstest \
490- src/testing/iotest \
491- src/testing/quick \
492- src/time
493- do
494- echo "GOOS=wasip1 GOARCH=wasm go test -v -c -o ~/tests/${value//\//_}.test ./$value"
495- GOOS=wasip1 GOARCH=wasm go test -v -c -o ~/tests/${value//\//_}.test ./$value
496- done
497-
498- - name : Checkout wazero
499- uses : actions/checkout@v3
500-
501- - name : Build wazero
397+ - if : ${{ matrix.compiler == 'optimizing' }}
398+ name : Build wazero
502399 run : go build -o ~/wazerocli ./cmd/wazero
503400 env :
504401 GOARCH : ${{ matrix.arch }}
505402
403+ - if : ${{ steps.cache-go-test-binaries.outputs.cache-hit != 'true' }}
404+ name : Build Test Binaries
405+ run : |
406+ cd ${{ env.STDLIB_TESTS }}
407+ make build.gowasip1
408+
506409 - name : Set up QEMU
507410 if : ${{ matrix.compiler == 'optimizing' && matrix.arch == 'arm64' }}
508411 uses : docker/setup-qemu-action@v2
@@ -520,12 +423,12 @@ jobs:
520423 - if : ${{ matrix.compiler == 'optimizing' }}
521424 name : Run test binaries (container)
522425 run : |
523- echo "Running $(find ~/tests -name *.test | wc -l) test binaries"
426+ echo "Running $(find ${{ env.STDLIB_TESTS }}/testdata/go -name ' *.test' | wc -l) test binaries"
524427
525428 # Skip tests that are hideously slow (mostly compilation time) for running inside QEMU.
526429 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"
527430 # Go tests often look for files relative to the source. Change to the corresponding directory.
528- for bin in $(find ~/tests -name " *.test" | grep -vE "$skip_targets"); do
431+ for bin in $(find $PWD/${{ env.STDLIB_TESTS }}/testdata/go -name ' *.test' | grep -vE "$skip_targets"); do
529432 dir=$(basename $bin); dir=${dir%.test}; dir=${dir//_/\/}
530433 pushd $(go env GOROOT)/$dir
531434 # Mount / as /ROOT in docker and then remount /ROOT as / in wazero; $bin is now in /ROOT/$bin.
@@ -534,56 +437,8 @@ jobs:
534437 popd
535438 done
536439
537- - if : ${{ matrix.compiler != 'optimizing' && runner.os != 'Windows' }}
538- name : Run test binaries
539- run : |
540- echo "Running $(find ~/tests -name *.test | wc -l) test binaries"
541-
542- # Go tests often look for files relative to the source. Change to the corresponding directory.
543- for bin in ~/tests/*.test; do
544- dir=$(basename $bin); dir=${dir%.test}; dir=${dir//_/\/}
545- pushd $(go env GOROOT)/$dir
546- ~/wazerocli run -mount=/:/ -env PWD=$PWD $bin -- -test.short -test.v
547- popd
548- done
549-
550- - if : ${{ runner.os == 'Windows' }}
551- name : Run test binaries (Windows)
552- # Ack failures on Windows. https://github.com/tetratelabs/wazero/issues/1410
553- continue-on-error : true
440+ - name : Run built test binaries
441+ if : ${{ matrix.compiler != 'optimizing' }}
554442 run : |
555- GOOS=$(go env GOOS)
556- echo "Running $(find ~/tests -name *.test | wc -l) test binaries"
557-
558- MOUNT=c:\\:/
559- SCRIPT="$HOME/tests.cmd"
560- # Trim `/c` from the in-Wasm GOROOT.
561- REAL_GOROOT=$(go env GOROOT)
562- GOROOT=$(cygpath -u $REAL_GOROOT | cut -c 3-)
563- # Append early exit on cmd.
564- POSTFIX="if %errorlevel% neq 0 exit /b %errorlevel%"
565- RUNNER="cmd //c %USERPROFILE%\tests.cmd"
566- EXTRAPARAMS="-mount=%TEMP%:/tmp"
567-
568- # Go tests often look for files relative to the source. Change to the corresponding directory.
569- for bin in ~/tests/*.test; do
570- dir=$(basename $bin); dir=${dir%.test}; dir=${dir//_/\/}
571- pushd $REAL_GOROOT/$dir
572-
573- # Trim `/c` from the in-Wasm pwd.
574- IN_WASM_PWD=$(pwd | cut -c 3-)
575- # Convert to a Windows path.
576- bin=`cygpath -w $bin`
577-
578- # Create a script with all the tests (do not run yet).
579- echo ${MOUNT} ${IN_WASM_PWD} $GOROOT/$dir
580- COMMAND="~/wazerocli run -mount=${MOUNT} ${EXTRAPARAMS} -hostlogging=filesystem -env PWD=${IN_WASM_PWD} -env GOROOT=${GOROOT} -env GOOS=wasip1 $bin -- -test.short -test.v"
581- echo $COMMAND >> $SCRIPT
582- # Uncomment the following line for early exit on error on Windows.
583- # Otherwise the tests will report are successful evne on failure.
584- # echo $POSTFIX >> $SCRIPT
585- popd
586- done
587-
588- # Run all the tests in their own shell.
589- $RUNNER
443+ cd ${{ env.STDLIB_TESTS }}
444+ go test -bench='./wasip1' -benchtime=1x
0 commit comments