name: Tests
on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]
jobs:
  tests:
    runs-on: ubuntu-24.04
    strategy:
      matrix:
        goversion: [1.19, 1.18]
    steps:
    - name: Set up Go
      uses: actions/setup-go@v2
      with:
        go-version: ${{ matrix.goversion }}
    - name: Checkout code
      uses: actions/checkout@v2
    - name: Cache Go dependencies
      id: cache-go-modules
      uses: actions/cache@v4
      with:
        path: ~/go/pkg/mod
        key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
        restore-keys: |
          ${{ runner.os }}-go-
    - name: Build ARM
      run: GOARCH=arm go build -v -mod=readonly ./...
    - name: Build ARM64
      run: GOARCH=arm64 go build -v -mod=readonly ./...
    - name: Build
      run: go build -v -mod=readonly ./...
    - name: Test
      run: go test -v -mod=readonly ./...
    - name: Build 386
      run: GOARCH=386 go build -v -mod=readonly ./...
    - name: Test 386
      run: GOARCH=386 go test -v -mod=readonly ./...
    - name: Go vet
      run: go vet ./...
