...

Text file src/github.com/tetratelabs/wazero/.github/workflows/commit.yaml

Documentation: github.com/tetratelabs/wazero/.github/workflows

     1name: Test
     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
    16env:  # Update this prior to requiring a higher minor version in go.mod
    17  GO_VERSION: "1.21"  # 1.xx == latest patch of 1.xx
    18
    19defaults:
    20  run:  # use bash for all operating systems unless overridden
    21    shell: bash
    22
    23concurrency:
    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
    28jobs:
    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.33
    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_amd64:
    61    name: amd64, ${{ matrix.os }}, Go-${{ matrix.go-version }}
    62    runs-on: ${{ matrix.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        os: [ubuntu-22.04, macos-12, windows-2022]
    67        go-version:
    68          - "1.21"  # Current Go version
    69          - "1.19"  # Floor Go version of wazero (current - 2)
    70
    71    steps:
    72
    73      - uses: actions/checkout@v3
    74
    75      - uses: actions/setup-go@v4
    76        with:
    77          go-version: ${{ matrix.go-version }}
    78
    79      # Ensure the pagefile is large enough to execute tests like TestStore_hammer_close on Windows.
    80      - name: configure Pagefile
    81        uses: al-cheb/configure-pagefile-action@v1.2
    82        if: runner.os == 'Windows'
    83        with:
    84          minimum-size: 8GB
    85          maximum-size: 16GB
    86          disk-root: "D:"
    87
    88      # Run -race could be really slow without -short, so run them together on this workflow.
    89      # Since -short is not added in the scratch tests, all the tests are run in CI in practice.
    90      - run: make test go_test_options='-timeout 10m -race -short'
    91
    92      - name: "Generate coverage report"  # only once (not per OS)
    93        if: runner.os == 'Linux'
    94        run: make coverage
    95
    96      - name: "Upload coverage report"  # only on main push and only once (not per OS)
    97        if: github.event_name == 'push' && github.ref == 'refs/heads/main' && runner.os == 'Linux'
    98        env:
    99          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
   100        run: bash <(curl -s https://codecov.io/bash)
   101
   102  test_scratch:
   103    name: ${{ matrix.arch }}, Linux (scratch), Go-${{ matrix.go-version }}
   104    runs-on: ubuntu-22.04
   105    strategy:
   106      fail-fast: false  # don't fail fast as sometimes failures are arch/OS specific
   107      matrix:  # Use versions consistent with wazero's Go support policy.
   108        go-version:
   109          - "1.21"  # Current Go version
   110          - "1.19"  # Floor Go version of wazero (current - 2)
   111        arch:
   112          - "amd64"
   113          - "arm64"
   114          - "riscv64"
   115
   116    steps:
   117
   118      - uses: actions/checkout@v3
   119
   120      - uses: actions/setup-go@v4
   121        with:
   122          go-version: ${{ matrix.go-version }}
   123
   124      - name: Build test binaries
   125        # Exclude benchmarks as we don't run those in Docker
   126        run: |
   127          go list -f '{{.Dir}}' ./... | egrep -v '(bench|vs|spectest)' | xargs -Ipkg go test pkg -c -o pkg.test
   128          go build -o wazerocli ./cmd/wazero
   129        env:
   130          GOARCH: ${{ matrix.arch }}
   131          CGO_ENABLED: 0
   132
   133      - name: Set up QEMU
   134        if: ${{ matrix.arch != 'amd64' }}
   135        uses: docker/setup-qemu-action@v2
   136        with:  # Avoid docker.io rate-limits; built with internal-images.yml
   137          image: ghcr.io/tetratelabs/wazero/internal-binfmt
   138          platforms: ${{ matrix.arch }}
   139
   140      - name: Build scratch container
   141        run: |
   142          echo 'FROM scratch' >> Dockerfile
   143          echo 'CMD ["/test"]' >> Dockerfile
   144          docker buildx build -t wazero:test --platform linux/${{ matrix.arch }} .
   145
   146      - name: Run built test binaries
   147        # This runs all tests compiled above in sequence. Note: This mounts /tmp to allow t.TempDir() in tests.
   148        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
   149
   150  bench:
   151    name: Benchmark
   152    runs-on: ubuntu-22.04
   153
   154    steps:
   155      # Unlike the other CGO libraries, WasmEdge requires offline installation.
   156      - name: Install WasmEdge
   157        run: |
   158          wget -qO- https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | sudo bash -s -- -p /usr/local -v ${WASMEDGE_VERSION}
   159        # The version here is coupled to internal/integration_test/go.mod, but it
   160        # isn't always the same as sometimes the Go layer has a broken release.
   161        env:
   162          WASMEDGE_VERSION: 0.12.1
   163
   164      - uses: actions/checkout@v3
   165
   166      - uses: actions/setup-go@v4
   167        with:
   168          go-version: ${{ env.GO_VERSION }}
   169
   170      - run: make bench
   171
   172  # This ensures that internal/integration_test/fuzz is runnable, and is not intended to
   173  # run full-length fuzzing while trying to find low-hanging frontend bugs.
   174  fuzz:
   175    name: Minimal Fuzzing
   176    runs-on: ubuntu-22.04
   177
   178    steps:
   179      - uses: actions/checkout@v3
   180      - uses: actions/setup-go@v4
   181        with:
   182          go-version: ${{ env.GO_VERSION }}
   183
   184      - uses: actions/cache@v3
   185        id: cache
   186        with:
   187          # Cache corpus and artifacts so that we don't start from scratch but rather with a meaningful corpus
   188          # in the subsequent CI jobs.
   189          path: |
   190            ~/.cargo
   191            ~/.cache/go-build
   192            ~/go/pkg/mod
   193            ~/.rustup/toolchains/
   194            internal/integration_test/fuzz/target
   195            internal/integration_test/fuzz/fuzz/artifacts
   196            internal/integration_test/fuzz/fuzz/corpus
   197          key: build-fuzzer-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum', 'Makefile', '**/Cargo.lock', '**/Cargo.toml', '**/*.rs') }}
   198
   199      # Fuzzer requires nightly rustc.
   200      - run: rustup default nightly
   201      - run: cargo install cargo-fuzz
   202        if: steps.cache.outputs.cache-hit != 'true'
   203      # Run fuzzing only for a minute, not a full-length intensive one, but 60 seconds seems enough to find minor "front-end"
   204      # bugs which might exist in binary parser, validation, or instantiation phase while not pressuring CI jobs.
   205      - run: make fuzz fuzz_timeout_seconds=60
   206        if: ${{ github.event_name  == 'pull_request' }}
   207      # Run a bit longer on main branch push!
   208      - run: make fuzz fuzz_timeout_seconds=180
   209        if: ${{ github.event_name  == 'push' }}

View as plain text