codecov_per_test_coverage.yml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. use-new-devservices: true
  35. mode: backend-ci
  36. - name: Run backend test (${{ steps.setup.outputs.matrix-instance-number }} of ${{ steps.setup.outputs.matrix-instance-total }}) with --cov-context=test
  37. id: run_backend_tests
  38. run: |
  39. make test-python-ci COV_ARGS=--cov-context=test
  40. # Separate from the testing step above so that we always create the report
  41. # Even if some tests fail
  42. - name: Create coverage report in JSON format
  43. if: ${{ always() }}
  44. run: |
  45. coverage json --show-contexts -o .artifacts/python.coverage.json
  46. # Upload coverage data even if running the tests step fails since
  47. # it reduces large coverage fluctuations
  48. - name: Upload coverage - special case to test Codecov ATS
  49. if: ${{ always() }}
  50. uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7
  51. env:
  52. CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
  53. with:
  54. files: .artifacts/python.coverage.codecov.json
  55. flags: smart-tests
  56. override_commit: ${{ github.event.pull_request.head.sha }}
  57. plugins: compress-pycoverage
  58. continue-on-error: true