name: Code Coverage
on:
  pull_request:
  push:
    branches: [ master ]
concurrency: 
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
jobs:
  tests:
    name: Code Coverage Tests
    runs-on: ubuntu-latest
    steps:
    - name: Check out repository
      uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
      with:
        fetch-depth: 0
    - name: Set up Go
      uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
      with:
        go-version-file: 'go.mod'
        check-latest: true
      id: go
    - name: Run Tests
      run: make test-with-coverage
    - name: Upload Coverage
      uses: codecov/codecov-action@54bcd8715eee62d40e33596ef5e8f0f48dbbccab # v4.1.0
      with:
        files: coverage.txt
    - name: Upload Logs
      uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
      with:
        name: logs
        path: .logs/**/*.log
        if-no-files-found: ignore
      if: ${{ always() }}