name: Test on: workflow_dispatch: push: branches: [main] pull_request: branches: [main] # Cancel testing of a previous commit for the same branch. concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true permissions: contents: write # To update gh-badges branch. jobs: main: runs-on: ubuntu-latest timeout-minutes: 10 steps: - uses: actions/checkout@v7 - uses: jdx/mise-action@v4 - run: git reset --hard # Work around https://github.com/jdx/mise/discussions/8270. - uses: powerman/.github/.github/actions/cache-go-and-tools@main - run: mise run ci - uses: powerman/.github/.github/actions/coverage-badge@main if: github.ref_name == 'main' with: total_cmd: "mise run -q cover:go:total | tail -n 1 | sed -e 's/.*)//'" # Testing on available native platforms. native: strategy: matrix: include: - {os: ubuntu-24.04-arm} # Linux ARM64 - {os: macos-15-intel} # macOS AMD64 - {os: macos-latest} # macOS ARM64 - {os: windows-latest} # Windows AMD64 - {os: windows-11-arm} # Windows ARM64 runs-on: ${{ matrix.os }} timeout-minutes: 10 steps: - uses: actions/checkout@v7 - uses: actions/setup-go@v6 with: go-version-file: 'go.mod' - run: go test -timeout=60s -race ./... if: matrix.os != 'windows-11-arm' - run: go test -timeout=60s ./... if: matrix.os == 'windows-11-arm' # Testing on available docker QEMU platforms (Linux only). qemu: strategy: matrix: include: - {arch: arm, v: v7} - {arch: ppc64le} - {arch: s390x} - {arch: riscv64} runs-on: ubuntu-latest timeout-minutes: 10 steps: - uses: actions/checkout@v7 - name: Set up QEMU uses: docker/setup-qemu-action@v4 with: platforms: ${{ matrix.arch }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 - uses: powerman/.github/.github/actions/cache-go-and-tools@main with: key: qemu-${{ matrix.arch }}${{ matrix.v && format('-{0}', matrix.v) || '' }} - name: Run tests env: PLATFORM: linux/${{ matrix.arch }}${{ matrix.v && format('/{0}', matrix.v) || '' }} run: | mkdir -p ~/go ~/.cache/go-build V=$(awk '$1=="toolchain"{v=$2}$1=="go"&&!v{v=$2}END{sub(/^go/,"",v);print v}' go.mod) docker run -i --rm --platform "$PLATFORM" \ -w /workspace \ -v "$PWD:/workspace" \ -v "$HOME/.cache/go-build:/root/.cache/go-build" \ -v "$HOME/go:/go" \ "golang:${V}-alpine" go test -timeout=60s ./... # Aggregate job for branch protection. test: needs: [main, native, qemu] runs-on: ubuntu-latest if: always() steps: - name: Fail if any dependency failed, cancelled or skipped if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') run: exit 1