github.com/tetratelabs/wazero@v1.2.1/.github/workflows/integration.yaml (about) 1 name: Standard Library Integration Tests 2 on: 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 16 defaults: 17 run: # use bash for all operating systems unless overridden 18 shell: bash 19 20 env: # Update this prior to requiring a higher minor version in go.mod 21 GO_VERSION: "1.20" # 1.xx == latest patch of 1.xx 22 TINYGO_VERSION: "0.28.1" 23 ZIG_VERSION: "0.11.0-dev.3334+cd1417dbd" 24 25 concurrency: 26 # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-concurrency-to-cancel-any-in-progress-job-or-run 27 group: ${{ github.ref }}-${{ github.workflow }}-${{ github.actor }} 28 cancel-in-progress: true 29 30 jobs: 31 # This builds a zig test binary only if the same version tag hasn't been build before. 32 # This saves time as we rarely update the zig version. 33 build_zig_test_binary: 34 name: Build Zig test binary 35 runs-on: ubuntu-22.04 36 env: 37 ZIG_INSTALL: ~/zig-install 38 ZIG_SOURCE: ~/zig-source 39 40 steps: 41 - name: Checkout wazero 42 uses: actions/checkout@v3 43 44 - uses: actions/cache@v3 45 id: binary-cache 46 with: 47 # Use share the cache containing archives across OSes. 48 enableCrossOsArchive: true 49 key: zig-test-binary-${{ env.ZIG_VERSION }} 50 path: 51 ./zigbin/ 52 53 - name: Install Zig build 54 if: steps.binary-cache.outputs.cache-hit != 'true' 55 run: | 56 mkdir -p ${{ env.ZIG_INSTALL }} 57 curl -sSL https://ziglang.org/builds/zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz | tar -xJ --strip-components=1 -C ${{ env.ZIG_INSTALL }} 58 59 - name: Download Zig source code 60 if: steps.binary-cache.outputs.cache-hit != 'true' 61 run: | 62 mkdir -p ${{ env.ZIG_SOURCE }} 63 curl -sSL https://ziglang.org/builds/zig-${{ env.ZIG_VERSION }}.tar.xz | tar -xJ --strip-components=1 -C ${{ env.ZIG_SOURCE }} 64 65 - name: Build Stdlib test binary 66 if: steps.binary-cache.outputs.cache-hit != 'true' 67 # --test-no-exec allows building of the test Wasm binary without executing command. 68 # We use find because the test.wasm will be something like ./zig-cache/o/dd6df1361b2134adc5eee9d027495436/test.wasm 69 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 75 76 zig: 77 needs: build_zig_test_binary 78 name: Zig (${{ matrix.os }}) 79 runs-on: ${{ matrix.os }} 80 strategy: 81 fail-fast: false # don't fail fast as sometimes failures are arch/OS specific 82 matrix: 83 os: [ubuntu-22.04, macos-12, windows-2022] 84 85 steps: 86 - name: Checkout wazero 87 uses: actions/checkout@v3 88 89 - uses: actions/cache@v3 90 id: binary-cache 91 with: 92 # Use share the cache containing archives across OSes. 93 enableCrossOsArchive: true 94 # We need this cache to run tests. 95 fail-on-cache-miss: true 96 key: zig-test-binary-${{ env.ZIG_VERSION }} 97 path: 98 ./zigbin/ 99 100 - uses: actions/setup-go@v3 101 with: 102 go-version: ${{ env.GO_VERSION }} 103 104 - name: Install wazero 105 run: go install ./cmd/wazero 106 107 # This runs the previously compiled Zig tests with wazero. If you need 108 # to troubleshoot one, you can add "-hostlogging=filesystem" after 109 # adding filter argument to the "Build Stdlib test binary" step. 110 # e.g. --test-filter "Dir.Iterator but dir is deleted during iteration" 111 - name: Run the test binary with wazero CLI 112 run: wazero run -mount=:/ ./zigbin/test.wasm 113 114 build_tinygo_test_binary: 115 name: Build TinyGo test binary 116 runs-on: ubuntu-22.04 117 steps: 118 - name: Checkout wazero 119 uses: actions/checkout@v3 120 121 - uses: actions/cache@v3 122 id: binary-cache 123 with: 124 # Use share the cache containing archives across OSes. 125 enableCrossOsArchive: true 126 key: tinygo-test-binaries-${{ env.TINYGO_VERSION }} 127 path: 128 ./tinygobin/ 129 130 - name: Install TinyGo 131 if: steps.binary-cache.outputs.cache-hit != 'true' 132 run: | # installing via curl so commands are similar on OS/x 133 tinygo_version=${{ env.TINYGO_VERSION }} 134 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 - 135 echo "TINYGOROOT=/usr/local/tinygo" >> $GITHUB_ENV 136 echo "/usr/local/tinygo/bin" >> $GITHUB_PATH 137 138 - uses: actions/setup-go@v3 139 if: steps.binary-cache.outputs.cache-hit != 'true' 140 with: 141 go-version: ${{ env.GO_VERSION }} 142 143 - name: Build Test Binaries 144 if: steps.binary-cache.outputs.cache-hit != 'true' 145 # The following list of packages is derived from: 146 # https://github.com/tinygo-org/tinygo/blob/v0.28.1/Makefile#L281-L322 147 # Note: 148 # - index/suffixarray is extremely slow, so skip it. 149 # - 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 150 # - 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 151 run: | 152 mkdir ./tinygobin 153 for value in container/heap \ 154 container/list \ 155 container/ring \ 156 crypto/des \ 157 crypto/md5 \ 158 crypto/rc4 \ 159 crypto/sha1 \ 160 crypto/sha256 \ 161 crypto/sha512 \ 162 embed/internal/embedtest \ 163 encoding \ 164 encoding/ascii85 \ 165 encoding/base32 \ 166 encoding/csv \ 167 encoding/hex \ 168 go/scanner \ 169 hash \ 170 hash/adler32 \ 171 hash/crc64 \ 172 hash/fnv \ 173 html \ 174 internal/itoa \ 175 internal/profile \ 176 math \ 177 math/cmplx \ 178 net \ 179 net/http/internal/ascii \ 180 net/mail \ 181 os \ 182 path \ 183 reflect \ 184 sync \ 185 testing \ 186 testing/iotest \ 187 text/scanner \ 188 unicode \ 189 unicode/utf16 \ 190 unicode/utf8 191 do 192 tinygo test -target wasi -c -o ./tinygobin/${value/\//_}.test $value 193 done 194 195 tinygo: 196 needs: build_tinygo_test_binary 197 name: TinyGo (${{ matrix.os }}) 198 runs-on: ${{ matrix.os }} 199 strategy: 200 fail-fast: false # don't fail fast as sometimes failures are arch/OS specific 201 matrix: 202 os: [ubuntu-22.04, macos-12, windows-2022] 203 204 steps: 205 - name: Checkout wazero 206 uses: actions/checkout@v3 207 208 - uses: actions/cache@v3 209 id: binary-cache 210 with: 211 # Use share the cache containing archives across OSes. 212 enableCrossOsArchive: true 213 # We need this cache to run tests. 214 fail-on-cache-miss: true 215 key: tinygo-test-binaries-${{ env.TINYGO_VERSION }} 216 path: 217 ./tinygobin/ 218 219 - uses: actions/setup-go@v3 220 with: 221 go-version: ${{ env.GO_VERSION }} 222 223 - name: Install wazero 224 run: go install ./cmd/wazero 225 226 # This runs the previously compiled TinyGo tests with wazero. If you need 227 # to troubleshoot one, you can add "-hostlogging=filesystem" and also a 228 # trailing argument narrowing which test to execute. 229 # e.g. "-test.run '^TestStatBadDir$'" 230 - name: Run standard library tests 231 run: | 232 cd ./tinygobin 233 for bin in *.test; do 234 echo $bin 235 wazero run -mount=:/ -mount=:/tmp $bin -- -test.v 236 done 237 238 wasi-testsuite: 239 name: wasi-testsuite 240 runs-on: ${{ matrix.os }} 241 strategy: 242 fail-fast: false # don't fail fast as sometimes failures are arch/OS specific 243 matrix: 244 os: [ubuntu-22.04, macos-12, windows-2022] 245 246 steps: 247 - uses: actions/cache@v3 248 id: cache 249 with: 250 path: 251 ~/go/pkg/mod 252 key: integration-test-wasi-testsuite-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }} 253 254 - uses: actions/setup-go@v3 255 with: 256 go-version: ${{ env.GO_VERSION }} 257 258 - name: Checkout wazero 259 uses: actions/checkout@v3 260 261 - name: Install wazero 262 run: | 263 go install ./cmd/wazero 264 shell: bash 265 266 - name: Checkout wasi-testsuite 267 uses: actions/checkout@v3 268 with: 269 repository: WebAssembly/wasi-testsuite 270 ref: prod/testsuite-base 271 path: wasi-testsuite 272 273 - name: Initialize Python environment 274 uses: actions/setup-python@v4 275 with: 276 python-version: '3.11' # latest version of python 3 277 cache: pip 278 279 - name: Install dependencies 280 working-directory: wasi-testsuite/test-runner 281 run: | 282 python3 -m pip install -r requirements.txt 283 284 - name: Run all wasi-testsuite 285 working-directory: wasi-testsuite 286 run: | 287 python3 test-runner/wasi_test_runner.py \ 288 -t ./tests/assemblyscript/testsuite/ \ 289 ./tests/c/testsuite/ \ 290 ./tests/rust/testsuite/ \ 291 -f ../.github/wasi_testsuite_skip.json \ 292 -r ../.github/wasi_testsuite_adapter.py 293 294 build_gojs_test_binaries: 295 name: Build Go (js) test binary 296 runs-on: ubuntu-22.04 297 298 steps: 299 - uses: actions/cache@v3 300 id: binary-cache 301 with: 302 # Use share the cache containing archives across OSes. 303 enableCrossOsArchive: true 304 key: gojs-test-binary-${{ env.GO_VERSION }} 305 path: 306 ~/bin/ 307 308 - uses: actions/setup-go@v3 309 if: steps.binary-cache.outputs.cache-hit != 'true' 310 with: 311 go-version: ${{ env.GO_VERSION }} 312 313 - name: Build gojs test binaries 314 if: steps.binary-cache.outputs.cache-hit != 'true' 315 env: 316 GOOS: js 317 GOARCH: wasm 318 run: | # TODO: add more packages? 319 mkdir ~/bin && cd ~/bin 320 go test -c -o os.wasm os 321 322 gojs_stdlib: 323 name: Go (js) (${{ matrix.os }}) 324 needs: build_gojs_test_binaries 325 runs-on: ${{ matrix.os }} 326 strategy: 327 fail-fast: false # don't fail fast as sometimes failures are arch/OS specific 328 matrix: 329 os: [ubuntu-22.04, macos-12] # GOOS=js isn't supposed to work on windows. See #1222 330 331 steps: 332 - uses: actions/cache@v3 333 id: binary-cache 334 with: 335 # Use share the cache containing archives across OSes. 336 enableCrossOsArchive: true 337 # We need this cache to run tests. 338 fail-on-cache-miss: true 339 key: gojs-test-binary-${{ env.GO_VERSION }} 340 path: 341 ~/bin/ 342 343 - uses: actions/setup-go@v3 344 with: 345 go-version: ${{ env.GO_VERSION }} 346 347 - name: Checkout wazero 348 uses: actions/checkout@v3 349 350 - name: Install wazero 351 run: go install ./cmd/wazero 352 shell: bash 353 354 - name: Run tests 355 run: | 356 cd $(go env GOROOT)/src/os; wazero run -mount=/:/ ~/bin/os.wasm -test.v 357 358 go_tests: 359 # Due to the embedding of the GOROOT of the building env(https://github.com/golang/go/blob/3c59639b902fada0a2e5a6a35bafd10fc9183b89/src/os/os_test.go#L112), 360 # we have to build and cache on each OS unlike others in this file. 361 name: Go (${{ matrix.os }}) 362 runs-on: ${{ matrix.os }} 363 strategy: 364 fail-fast: false # don't fail fast as sometimes failures are arch/OS specific 365 matrix: 366 os: [ubuntu-22.04, macos-12, windows-2022] 367 368 steps: 369 - name: Install Go 370 uses: actions/setup-go@v3 371 with: 372 go-version: ${{ env.GO_VERSION }} 373 374 - name: Cache Go test binaries 375 id: cache-go-test-binaries 376 uses: actions/cache@v3 377 with: 378 path: ~/sdk 379 key: gotip-test-binaries-${{ env.GO_VERSION }}-${{ matrix.os }} 380 381 - if: ${{ steps.cache-go-test-binaries.outputs.cache-hit != 'true' }} 382 name: Install and download Go tip 383 run: | 384 go install golang.org/dl/gotip@latest 385 echo "$GOPATH/bin:$PATH" >> $GITHUB_PATH 386 gotip download 387 388 - if: ${{ steps.cache-go-test-binaries.outputs.cache-hit != 'true' }} 389 name: Build Test Binaries 390 run: | 391 cd $(gotip env GOROOT) 392 # Choose important packages to limit execution time. 393 for value in src/archive/tar \ 394 src/bufio \ 395 src/bytes \ 396 src/context \ 397 src/encoding/ascii85 \ 398 src/encoding/asn1 \ 399 src/encoding/base32 \ 400 src/encoding/base64 \ 401 src/encoding/binary \ 402 src/encoding/csv \ 403 src/encoding/gob \ 404 src/encoding/hex \ 405 src/encoding/json \ 406 src/encoding/pem \ 407 src/encoding/xml \ 408 src/errors \ 409 src/expvar \ 410 src/flag \ 411 src/fmt \ 412 src/hash \ 413 src/hash/adler32 \ 414 src/hash/crc32 \ 415 src/hash/crc64 \ 416 src/hash/fnv \ 417 src/hash/maphash \ 418 src/io \ 419 src/io/fs \ 420 src/io/ioutil \ 421 src/log \ 422 src/log/syslog \ 423 src/maps \ 424 src/math \ 425 src/math/big \ 426 src/math/bits \ 427 src/math/cmplx \ 428 src/math/rand \ 429 src/mime \ 430 src/mime/multipart \ 431 src/mime/quotedprintable \ 432 src/os \ 433 src/os/exec \ 434 src/os/signal \ 435 src/os/user \ 436 src/path \ 437 src/reflect \ 438 src/regexp \ 439 src/regexp/syntax \ 440 src/runtime \ 441 src/runtime/internal/atomic \ 442 src/runtime/internal/math \ 443 src/runtime/internal/sys \ 444 src/slices \ 445 src/sort \ 446 src/strconv \ 447 src/strings \ 448 src/sync \ 449 src/sync/atomic \ 450 src/syscall \ 451 src/testing \ 452 src/testing/fstest \ 453 src/testing/iotest \ 454 src/testing/quick \ 455 src/time 456 do 457 GOOS=wasip1 GOARCH=wasm gotip test -v -c -o ~/sdk/tests/${value//\//_}.test ./$value 458 done 459 460 - name: Checkout wazero 461 uses: actions/checkout@v3 462 463 - name: Install wazero 464 run: go install ./cmd/wazero 465 466 - if: ${{ runner.os != 'Windows' }} 467 name: Run standard library tests 468 run: | 469 echo "Running $(find ~/sdk/tests -name *.test | wc -l) test binaries" 470 471 # Go tests often look for files relative to the source. Change to the corresponding directory. 472 for bin in ~/sdk/tests/*.test; do 473 dir=$(basename $bin); dir=${dir%.test}; dir=${dir//_/\/} 474 pushd ~/sdk/gotip/$dir 475 wazero run -mount=/:/ -env PWD=$PWD $bin -- -test.short -test.v 476 popd 477 done 478 479 - if: ${{ runner.os == 'Windows' }} 480 name: Run standard library tests 481 # Ack failures on Windows. https://github.com/tetratelabs/wazero/issues/1410 482 continue-on-error: true 483 run: | 484 GOOS=$(go env GOOS) 485 echo "Running $(find ~/sdk/tests -name *.test | wc -l) test binaries" 486 487 GOROOT=~/sdk/gotip 488 489 MOUNT=c:\\:/ 490 SCRIPT="$HOME/sdk/tests.cmd" 491 # Trim `/c` from the in-Wasm GOROOT. 492 GOROOT=$(cygpath -u $GOROOT | cut -c 3-) 493 # Append early exit on cmd. 494 POSTFIX="if %errorlevel% neq 0 exit /b %errorlevel%" 495 RUNNER="cmd //c %USERPROFILE%\sdk\tests.cmd" 496 EXTRAPARAMS="-mount=%TEMP%:/tmp" 497 498 # Go tests often look for files relative to the source. Change to the corresponding directory. 499 for bin in ~/sdk/tests/*.test; do 500 dir=$(basename $bin); dir=${dir%.test}; dir=${dir//_/\/} 501 pushd ~/sdk/gotip/$dir 502 503 # Trim `/c` from the in-Wasm pwd. 504 IN_WASM_PWD=$(pwd | cut -c 3-) 505 # Convert to a Windows path. 506 bin=`cygpath -w $bin` 507 508 # Create a script with all the tests (do not run yet). 509 echo ${MOUNT} ${IN_WASM_PWD} ~/sdk/gotip/$dir 510 COMMAND="wazero run -mount=${MOUNT} ${EXTRAPARAMS} -hostlogging=filesystem -env PWD=${IN_WASM_PWD} -env GOROOT=${GOROOT} -env GOOS=wasip1 $bin -- -test.short -test.v" 511 echo $COMMAND >> $SCRIPT 512 # Uncomment the following line for early exit on error on Windows. 513 # Otherwise the tests will report are successful evne on failure. 514 # echo $POSTFIX >> $SCRIPT 515 popd 516 done 517 518 # Run all the tests in their own shell. 519 $RUNNER