codecov_per_test_coverage.yml 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. name: Codecov - per test coverage
  2. # This workflow generates pytest coverage with the flag --cov-context=test
  3. # This coverage is used as input for Codecov Automated Test Selection (see .github/workflows/codecov_ats.yml)
  4. # However there's a performance toll in running tests with this flag.
  5. # So we will not be running the test suite on every commit
  6. on: [workflow_dispatch, workflow_call]
  7. jobs:
  8. # Same as 'backend' in .github/workflows/backed.yml
  9. # Except for run_backend_tests step (which includes the extra --cov-context=test flag)
  10. # And the coverage generation and handling
  11. backend-test-with-cov-context:
  12. if: github.ref == 'refs/heads/master'
  13. name: backend test
  14. runs-on: ubuntu-24.04
  15. timeout-minutes: 120
  16. strategy:
  17. # This helps not having to run multiple jobs because one fails, thus, reducing resource usage
  18. # and reducing the risk that one of many runs would turn red again (read: intermittent tests)
  19. fail-fast: false
  20. matrix:
  21. # XXX: When updating this, make sure you also update MATRIX_INSTANCE_TOTAL.
  22. instance: [0, 1, 2, 3, 4, 5, 6]
  23. pg-version: ['14']
  24. env:
  25. # XXX: `MATRIX_INSTANCE_TOTAL` must be hardcoded to the length of `strategy.matrix.instance`.
  26. # If this increases, make sure to also increase `flags.backend.after_n_builds` in `codecov.yml`.
  27. MATRIX_INSTANCE_TOTAL: 7
  28. steps:
  29. - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  30. - name: Setup sentry env
  31. uses: ./.github/actions/setup-sentry
  32. id: setup
  33. with:
  34. mode: backend-ci
  35. - name: Run backend test (${{ steps.setup.outputs.matrix-instance-number }} of ${{ steps.setup.outputs.matrix-instance-total }}) with --cov-context=test
  36. id: run_backend_tests
  37. run: |
  38. make test-python-ci COV_ARGS=--cov-context=test
  39. # Separate from the testing step above so that we always create the report
  40. # Even if some tests fail
  41. - name: Create coverage report in JSON format
  42. if: ${{ always() }}
  43. run: |
  44. coverage json --show-contexts -o .artifacts/python.coverage.json
  45. # Upload coverage data even if running the tests step fails since
  46. # it reduces large coverage fluctuations
  47. - name: Upload coverage - special case to test Codecov ATS
  48. if: ${{ always() }}
  49. uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7
  50. env:
  51. CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
  52. with:
  53. files: .artifacts/python.coverage.codecov.json
  54. flags: smart-tests
  55. override_commit: ${{ github.event.pull_request.head.sha }}
  56. plugins: compress-pycoverage
  57. continue-on-error: true