name: "tests"

on:
  push:
    branches: [ "main", "next" ]
  pull_request:
    # The branches below must be a subset of the branches above
    branches: [ "main", "next" ]
  schedule:
    - cron: '26 21 * * 6'

jobs:
  tests:
    runs-on: ubuntu-latest
    timeout-minutes: 5
    strategy:
      matrix:
        # Test against stable, and the oldest supported version.
        go: [ 'stable', '1.21.x' ]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version: ${{ matrix.go }}
          check-latest: true
      - name: test
        run: make test

  coverage:
    needs: tests
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version: 'stable'
          check-latest: true
      - name: coverage tests
        run: ./tests/cover.sh
      - name: upload
        uses: codecov/codecov-action@v4
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          file: .cover-merged.out
