name: "Codecov"

# Enabling on each push is to display the coverage changes in every PR, 
# where each PR needs to be compared against the coverage of the head commit
on: [push, pull_request]

permissions:
  contents: read

jobs:
  code-coverage:
    if: ${{ github.repository == 'redis/redis' }}
    runs-on: ubuntu-latest

    steps:
    - name: Checkout repository
      uses: actions/checkout@v6

    - name: Install lcov and run test
      run: |
        sudo apt-get install lcov
        make lcov

    - name: Upload coverage reports to Codecov
      uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6
      env:
        CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
      with:
        files: ./src/redis.info
        disable_search: true
        fail_ci_if_error: true

