codecov_per_test_coverage.yml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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-22.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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
  30. - name: Setup sentry env
  31. uses: ./.github/actions/setup-sentry
  32. id: setup
  33. with:
  34. kafka: true
  35. snuba: true
  36. symbolicator: true
  37. # Right now, we run so few bigtable related tests that the
  38. # overhead of running bigtable in all backend tests
  39. # is way smaller than the time it would take to run in its own job.
  40. bigtable: true
  41. pg-version: ${{ matrix.pg-version }}
  42. - name: Run backend test (${{ steps.setup.outputs.matrix-instance-number }} of ${{ steps.setup.outputs.matrix-instance-total }}) with --cov-context=test
  43. id: run_backend_tests
  44. run: |
  45. make test-python-ci COV_ARGS=--cov-context=test
  46. # Separate from the testing step above so that we always create the report
  47. # Even if some tests fail
  48. - name: Create coverage report in JSON format
  49. if: ${{ always() }}
  50. run: |
  51. coverage json --show-contexts -o .artifacts/python.coverage.json
  52. # Upload coverage data even if running the tests step fails since
  53. # it reduces large coverage fluctuations
  54. - name: Upload coverage - special case to test Codecov ATS
  55. if: ${{ always() }}
  56. uses: codecov/codecov-action@v4-beta
  57. env:
  58. CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
  59. with:
  60. files: .artifacts/python.coverage.codecov.json
  61. flags: smart-tests
  62. override_commit: ${{ github.event.pull_request.head.sha }}
  63. plugins: compress-pycoverage
  64. continue-on-error: true