name: Codecov

on:
  push:
    branches:
      - '*'
  pull_request:
    branches:
      - 'main'
      - 'release*'

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

permissions:
  contents: read

jobs:
  codecov:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
      - name: Setup build env
        uses: ./.github/actions/setup-build-env
        with:
          build-cache-key: codecov
      - name: Generate Code Coverage Report
        run: make code-cov-report
      - name: Upload Report to Codecov
        uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
        with:
          file: ./coverage.out
          fail_ci_if_error: true
          verbose: true
