name: Go

on: [pull_request]

jobs:
  test:
    strategy:
      matrix:
        go:
        - 1.17.x
        - 1.18.x
        os:
        - [self-hosted, linux, arm64, segment]
        - ubuntu-latest

    runs-on: ${{ matrix.os }}

    steps:
    - uses: actions/checkout@v2

    - name: Setup Go ${{ matrix.go }}
      uses: actions/setup-go@v2
      with:
        go-version: ${{ matrix.go }}

    - name: Download Dependencies
      run: go mod download

    - name: Vet
      run: go vet ./...

    - name: Test
      run: go test -race -v ./...

    - name: Test (purego)
      run: go test -race -tags purego -v ./...

  gen:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - name: Setup Go
      uses: actions/setup-go@v2
      with:
        go-version: 1.18.x

    - name: Ensure generated assembler code is up to date
      run: |
        go install github.com/kevinburke/differ@1.2
        differ make --always-make build
