name: Continuous Integration
on:
  pull_request:
    types: [opened, synchronize, reopened]
  push:
    branches:
      - master

jobs:
  report:
    name: Report
    runs-on: ubuntu-latest
    steps:
      - name: ref
        run: echo ${{ github.ref }}
      - name: event_name
        run: echo ${{ github.event_name }}
  build:
    name: Build
    strategy:
      matrix:
        target: [
          # Tier 1
          {arch: amd64, os: linux},   {arch: arm64, os: linux},
          {arch: amd64, os: windows}, {arch: arm64, os: windows},
          {arch: amd64, os: darwin},  {arch: arm64, os: darwin},
          {arch: wasm, os: wasip1},

          # Tier 2 (Best effort)
          {arch: amd64, os: freebsd}, {arch: arm64, os: freebsd},
          {arch: amd64, os: netbsd},  {arch: arm64, os: netbsd},
          {arch: amd64, os: openbsd}, {arch: arm64, os: openbsd},
          {arch: amd64, os: solaris},
          {arch: amd64, os: illumos},
          {arch: ppc64, os: aix},
        ]
    runs-on: ubuntu-latest
    steps:
      - name: checkout
        uses: actions/checkout@v2
      - uses: actions/setup-go@v5
        with:
          go-version-file: 'go.mod'
      - run: go build
        env:
          GOOS: ${{ matrix.target.os }}
          GOARCH: ${{ matrix.target.arch }}
  test:
    name: Test
    strategy:
      matrix:
        os: [macos-latest, windows-latest, ubuntu-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - name: checkout
        uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version: ^1.24
      - run: go build
      - name: vet
        if: matrix.os != 'windows-latest'
        run: make vet
      - name: lint
        if: matrix.os != 'windows-latest'
        run: make lint
      - name: image
        if: matrix.os == 'ubuntu-latest'
        run: make image
      - name: test
        if: matrix.os == 'ubuntu-latest'
        run: make test
