github.com/tetratelabs/wazero@v1.7.1/.github/workflows/commit.yaml (about)

     1  name: Test
     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  env:  # Update this prior to requiring a higher minor version in go.mod
    17    GO_VERSION: "1.22"
    18  
    19  defaults:
    20    run:  # use bash for all operating systems unless overridden
    21      shell: bash
    22  
    23  concurrency:
    24    # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-concurrency-to-cancel-any-in-progress-job-or-run
    25    group: ${{ github.ref }}-${{ github.workflow }}-${{ github.actor }}
    26    cancel-in-progress: true
    27  
    28  jobs:
    29    check:
    30      name: Pre-commit check
    31      # wabt requires a later version of libc than what's installed on ubuntu-22.04.
    32      runs-on: ubuntu-latest
    33      steps:
    34        - name: Install latest wast2json
    35          run: |  # Needed for build.spectest. wabt includes wast2json.
    36            wabt_version=1.0.34
    37            wabt_url=https://github.com/WebAssembly/wabt/releases/download/${wabt_version}/wabt-${wabt_version}-ubuntu.tar.gz
    38            curl -sSL ${wabt_url} | tar --strip-components 2 -C /usr/local/bin -xzf - wabt-${wabt_version}/bin/wast2json
    39  
    40        - uses: actions/checkout@v3
    41  
    42        - uses: actions/setup-go@v4
    43          with:  # not cache: true as we also need to cache golint
    44            cache: false
    45            go-version: ${{ env.GO_VERSION }}
    46  
    47        - uses: actions/cache@v3
    48          with:
    49            path: |
    50              ~/.cache/go-build
    51              ~/.cache/golangci-lint
    52              ~/go/pkg/mod
    53              ~/go/bin
    54            key: check-${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum', 'Makefile') }}
    55  
    56        - run: make build.spectest
    57  
    58        - run: make check
    59  
    60    test:
    61      name: ${{ matrix.platform.arch }}, ${{ matrix.platform.os }}, Go-${{ matrix.go-version }}
    62      runs-on: ${{ matrix.platform.os }}
    63      strategy:
    64        fail-fast: false  # don't fail fast as sometimes failures are arch/OS specific
    65        matrix:  # Use versions consistent with wazero's Go support policy.
    66          platform:
    67          - os: ubuntu-22.04
    68            arch: amd64
    69          - os: macos-12
    70            arch: amd64
    71          - os: windows-2022
    72            arch: amd64
    73          - os: macos-14
    74            arch: arm64
    75          go-version:
    76            - "1.22"  # Current Go version
    77            - "1.20"  # Floor Go version of wazero (current - 2)
    78  
    79      steps:
    80  
    81        - uses: actions/checkout@v3
    82  
    83        - uses: actions/setup-go@v4
    84          with:
    85            go-version: ${{ matrix.go-version }}
    86  
    87        # Ensure the pagefile is large enough to execute tests like TestStore_hammer_close on Windows.
    88        - name: configure Pagefile
    89          uses: al-cheb/configure-pagefile-action@v1.2
    90          if: runner.os == 'Windows'
    91          with:
    92            minimum-size: 8GB
    93            maximum-size: 16GB
    94            disk-root: "D:"
    95  
    96        # Run -race could be really slow without -short, so run them together on this workflow.
    97        # Since -short is not added in the scratch tests, all the tests are run in CI in practice.
    98        - run: make test go_test_options='-timeout 20m -race -short'
    99  
   100        - name: "Generate coverage report"  # only once (not per OS)
   101          if: runner.os == 'Linux'
   102          run: make coverage
   103  
   104        - name: "Upload coverage report"  # only on main push and only once (not per OS)
   105          if: github.event_name == 'push' && github.ref == 'refs/heads/main' && runner.os == 'Linux'
   106          env:
   107            CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
   108          run: bash <(curl -s https://codecov.io/bash)
   109  
   110    test_scratch:
   111      name: ${{ matrix.arch }}, Linux (scratch), Go-${{ matrix.go-version }}
   112      runs-on: ubuntu-22.04
   113      strategy:
   114        fail-fast: false  # don't fail fast as sometimes failures are arch/OS specific
   115        matrix:  # Use versions consistent with wazero's Go support policy.
   116          go-version:
   117            - "1.22"  # Current Go version
   118            - "1.20"  # Floor Go version of wazero (current - 2)
   119          arch:
   120            - "amd64"
   121            - "arm64"
   122            - "riscv64"
   123  
   124      steps:
   125  
   126        - uses: actions/checkout@v3
   127  
   128        - uses: actions/setup-go@v4
   129          with:
   130            go-version: ${{ matrix.go-version }}
   131  
   132        - name: Build test binaries
   133          # Exclude benchmarks as we don't run those in Docker
   134          run: |
   135            go list -f '{{.Dir}}' ./... | egrep -v '(bench|vs|spectest)' | xargs -Ipkg go test pkg -c -o pkg.test
   136            go build -o wazerocli ./cmd/wazero
   137          env:
   138            GOARCH: ${{ matrix.arch }}
   139            CGO_ENABLED: 0
   140  
   141        - name: Set up QEMU
   142          if: ${{ matrix.arch != 'amd64' }}
   143          uses: docker/setup-qemu-action@v2
   144          with:  # Avoid docker.io rate-limits; built with internal-images.yml
   145            image: ghcr.io/tetratelabs/wazero/internal-binfmt
   146            platforms: ${{ matrix.arch }}
   147  
   148        - name: Build scratch container
   149          run: |
   150            echo 'FROM scratch' >> Dockerfile
   151            echo 'CMD ["/test"]' >> Dockerfile
   152            docker buildx build -t wazero:test --platform linux/${{ matrix.arch }} .
   153  
   154        - name: Run built test binaries
   155          # This runs all tests compiled above in sequence. Note: This mounts /tmp to allow t.TempDir() in tests.
   156          run: find . -name "*.test" | xargs -Itestbin docker run --platform linux/${{ matrix.arch }} -v $(pwd)/testbin:/test -v $(pwd)/wazerocli:/wazero -e WAZEROCLI=/wazero --tmpfs /tmp --rm -t wazero:test
   157  
   158    test_tinygo:
   159      name: "TinyGo on Ubuntu"
   160      runs-on: ubuntu-latest
   161      steps:
   162        - uses: actions/checkout@v2
   163        - uses: actions/setup-go@v2
   164          with:
   165            go-version: "1.22"
   166        - uses: acifani/setup-tinygo@v2
   167          with:
   168            tinygo-version: "0.31.2"
   169        - run: tinygo build ./cmd/wazero
   170        - run: tinygo build -size short -target pico -stack-size=8kb ./cmd/wazero
   171  
   172    bench:
   173      name: Benchmark
   174      runs-on: ubuntu-22.04
   175  
   176      steps:
   177        # Unlike the other CGO libraries, WasmEdge requires offline installation.
   178        - name: Install WasmEdge
   179          run: |
   180            wget -qO- https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | sudo bash -s -- -p /usr/local -v ${WASMEDGE_VERSION}
   181          # The version here is coupled to internal/integration_test/go.mod, but it
   182          # isn't always the same as sometimes the Go layer has a broken release.
   183          env:
   184            WASMEDGE_VERSION: 0.12.1
   185  
   186        - uses: actions/checkout@v3
   187  
   188        - uses: actions/setup-go@v4
   189          with:
   190            go-version: ${{ env.GO_VERSION }}
   191  
   192        - run: make bench
   193  
   194    # This ensures that internal/integration_test/fuzz is runnable, and is not intended to
   195    # run full-length fuzzing while trying to find low-hanging frontend bugs.
   196    fuzz:
   197      name: Minimal Fuzzing (${{ matrix.platform.os }}, ${{ matrix.platform.arch }} )
   198      runs-on: ${{ matrix.platform.os }}
   199      strategy:
   200        fail-fast: false  # don't fail fast as sometimes failures are arch/OS specific
   201        matrix:  # Use versions consistent with wazero's Go support policy.
   202          platform:
   203            - os: ubuntu-22.04
   204              arch: amd64
   205            - os: macos-14
   206              arch: arm64
   207  
   208      steps:
   209        - uses: actions/checkout@v3
   210        - uses: actions/setup-go@v4
   211          with:
   212            go-version: ${{ env.GO_VERSION }}
   213  
   214        - uses: actions/cache@v3
   215          id: cache
   216          with:
   217            # Cache corpus and artifacts so that we don't start from scratch but rather with a meaningful corpus
   218            # in the subsequent CI jobs.
   219            path: |
   220              ~/.cargo
   221              ~/.cache/go-build
   222              ~/go/pkg/mod
   223              ~/.rustup/toolchains/
   224              internal/integration_test/fuzz/target
   225              internal/integration_test/fuzz/fuzz/artifacts
   226              internal/integration_test/fuzz/fuzz/corpus
   227            key: build-fuzz-${{ matrix.platform.os }}-${{ matrix.platform.arch }}-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum', 'Makefile', '**/Cargo.lock', '**/Cargo.toml', '**/*.rs') }}
   228  
   229        - run: cargo install cargo-fuzz
   230          if: steps.cache.outputs.cache-hit != 'true'
   231        # Run fuzzing only for a minute, not a full-length intensive one, but 60 seconds seems enough to find minor "front-end"
   232        # bugs which might exist in binary parser, validation, or instantiation phase while not pressuring CI jobs.
   233        - run: make fuzz fuzz_timeout_seconds=60
   234          if: ${{ github.event_name  == 'pull_request' }}
   235        # Run a bit longer on main branch push!
   236        - run: make fuzz fuzz_timeout_seconds=180
   237          if: ${{ github.event_name  == 'push' }}