name: Tests

concurrency:
  group: "tests-${{ github.ref }}"
  cancel-in-progress: true

on:
  push: 
    branches:
      - main
      - dev
    tags:
  pull_request:
  workflow_dispatch:

jobs:
  lint:
    name: Lint
    runs-on: ubuntu-latest
    steps:
      - name: Clone
        uses: actions/checkout@v4
      - name: Set up Go
        uses: actions/setup-go@v5
        with:
          go-version: ^1.21
      - name: golangci-lint
        uses: golangci/golangci-lint-action@v3
        with:
          version: v1.54
  unit-tests:
    name: Unit Tests
    runs-on: ubuntu-latest
    steps:
      - name: Clone
        uses: actions/checkout@v4
      - name: Set up Go
        uses: actions/setup-go@v5
        with:
          go-version: ^1.21
      - name: Unit Tests
        run: |
          make unit-tests
          
      - name: Codecov
        uses: codecov/codecov-action@v4
        with:
          files: ./coverage.txt
          flags: Unit-Tests
          verbose: true
        env:
          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}