name: Coverage Tests

on: [push, pull_request]

# Cancel any preceding run on the pull request.
concurrency:
  group: gcov-test-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: ${{ github.ref != 'refs/heads/criu-dev' }}

jobs:
  build:
    runs-on: ubuntu-22.04

    steps:
    - uses: actions/checkout@v4
    - name: Run Coverage Tests
      run: sudo -E make -C scripts/ci local GCOV=1
    - name: Run gcov
      run: sudo -E find . -name '*gcda' -type f -print0 | sudo -E xargs --null --max-args 128 --max-procs 4 gcov
    - name: Run Coverage Analysis
      run: sudo -E make codecov
