name: PR code coverage measurement on codecov.io

on: [pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    continue-on-error: true
    name: Submit code coverage from Packit tests
    defaults:
      run:
        working-directory: scripts
    steps:
    - uses: actions/checkout@v3
    - name: Wait for Packit tests to finish and download coverage.xml file
      run: ./download_packit_coverage.sh
      env:
        MAX_DURATION: 5400
        SLEEP_DELAY: 120
    - name: List downloaded files
      run: ls coverage*
    - name: Upload coverage.unittests.xml report to Codecov with GitHub Action
      uses: codecov/codecov-action@v2
      with:
        files: scripts/coverage.unittests.xml
        flags: unittests
    - name: Upload coverage.testsuite.xml report to Codecov with GitHub Action
      uses: codecov/codecov-action@v2
      with:
        files: scripts/coverage.testsuite.xml
        flags: testsuite
    - name: Upload coverage.packit.xml report to Codecov with GitHub Action
      uses: codecov/codecov-action@v2
      with:
        files: scripts/coverage.packit.xml
        flags: packit-e2e
