name: Test
on: [push, pull_request]
jobs:
  test:
    strategy:
      matrix:
        go-version: [1.11.x, 1.x]
        os: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
    - name: Install Go
      uses: actions/setup-go@v2
      with:
        go-version: ${{ matrix.go-version }}
    - name: Checkout code
      uses: actions/checkout@v2
    - name: Build GOARCH=386
      if: ${{ matrix.os != 'macos-latest' }}
      env:
        GOARCH: "386"
      run: go build
    - name: Test
      run: go test ./... -race -coverprofile=coverage.txt -covermode=atomic
    - name: Upload coverage to Codecov
      if: ${{ matrix.os == 'ubuntu-latest' }}
      run: bash <(curl -s https://codecov.io/bash)
