backend-test.yml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. name: backend
  2. on:
  3. push:
  4. branches:
  5. - master
  6. - releases/**
  7. pull_request:
  8. jobs:
  9. test:
  10. name: backend test
  11. runs-on: ubuntu-20.04
  12. timeout-minutes: 30
  13. strategy:
  14. matrix:
  15. instance: [0, 1]
  16. env:
  17. MIGRATIONS_TEST_MIGRATE: 1
  18. steps:
  19. - uses: actions/checkout@v2
  20. with:
  21. # Avoid codecov error message related to SHA resolution:
  22. # https://github.com/codecov/codecov-bash/blob/7100762afbc822b91806a6574658129fe0d23a7d/codecov#L891
  23. fetch-depth: '2'
  24. # If we make these jobs "required" to merge on GH, then on every PR, GitHub automatically
  25. # creates a status check in the "pending" state. This means that the workflow needs to run
  26. # for every PR in order to update the status checks.
  27. #
  28. # In order to optimize CI usage, we want the tests to only run when python files change,
  29. # since frontend changes should have no effect on these test suites. We cannot use GH workflow
  30. # path filters because entire workflow would be skipped vs skipping individual jobs which
  31. # would still allow this status check to pass.
  32. - name: Check for python file changes
  33. uses: getsentry/paths-filter@v2
  34. id: changes
  35. with:
  36. token: ${{ github.token }}
  37. filters: .github/file-filters.yml
  38. - name: Set python version output
  39. id: python-version
  40. if: steps.changes.outputs.backend == 'true'
  41. run: |
  42. echo "::set-output name=python-version::$(cat .python-version)"
  43. # Until GH composite actions can use `uses`, we need to setup python here
  44. - uses: actions/setup-python@v2
  45. if: steps.changes.outputs.backend == 'true'
  46. with:
  47. python-version: ${{ steps.python-version.outputs.python-version }}
  48. - name: Setup pip
  49. uses: ./.github/actions/setup-pip
  50. if: steps.changes.outputs.backend == 'true'
  51. id: pip
  52. - name: pip cache
  53. uses: actions/cache@v2
  54. if: steps.changes.outputs.backend == 'true'
  55. with:
  56. path: ${{ steps.pip.outputs.pip-cache-dir }}
  57. key: |
  58. ${{ runner.os }}-py${{ steps.python-version.outputs.python-version }}-pip${{ steps.pip.outputs.pip-version }}-${{ secrets.PIP_CACHE_VERSION }}-${{ hashFiles('requirements-*.txt', '!requirements-pre-commit.txt') }}
  59. - name: Setup sentry env
  60. uses: ./.github/actions/setup-sentry
  61. if: steps.changes.outputs.backend == 'true'
  62. id: setup
  63. with:
  64. snuba: true
  65. - name: Run backend test (${{ steps.setup.outputs.matrix-instance-number }} of ${{ strategy.job-total }})
  66. if: steps.changes.outputs.backend == 'true'
  67. run: |
  68. # Note: `USE_SNUBA` is not used for backend tests because there are a few failing tests with Snuba enabled.
  69. unset USE_SNUBA
  70. make test-python-ci
  71. - name: Handle artifacts
  72. uses: ./.github/actions/artifacts