name: Run Tests

on: [push, pull_request]

jobs:
  test:
    name: Test
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]
        goVer: ['1.19', '1.20']
    # Defines the platform for each test run.
    runs-on: ${{ matrix.os }}
    steps:
      # Checks out our code locally so we can work with the files.
      - name: Checkout code
        uses: actions/checkout@v3

      # The steps that will be run through for each version and platform combination.
      - name: Set up Go ${{ matrix.goVer }}
        uses: actions/setup-go@v4
        with:
          go-version: ${{ matrix.goVer }}
          cache: true

      # Runs go test ./...
      - name: Test
        run: go test -v -short ./...

  lint:
    runs-on: ubuntu-latest
    steps:
      # Checks out our code locally so we can work with the files.
      - name: Checkout code
        uses: actions/checkout@v3

      # Installs go using a single version.
      - name: Install Go
        uses: actions/setup-go@v4
        with:
          go-version: '1.20'
          cache: false
      # Runs the default linters provided by golangci-lint plus golint and godot.
      - name: Run linters
        uses: golangci/golangci-lint-action@v3
        with:
          version: v1.52
          args: --enable=golint --enable=godot --timeout=3m
