acceptance.yml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. # Also note that this name *MUST* match the filename because GHA
  2. # only provides the workflow name (https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables#default-environment-variables)
  3. # and GH APIs only support querying by workflow *FILENAME* (https://developer.github.com/v3/actions/workflows/#get-a-workflow)
  4. name: acceptance
  5. on:
  6. push:
  7. branches:
  8. - master
  9. - releases/**
  10. pull_request:
  11. # Cancel in progress workflows on pull_requests.
  12. # https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
  13. concurrency:
  14. group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  15. cancel-in-progress: true
  16. # hack for https://github.com/actions/cache/issues/810#issuecomment-1222550359
  17. env:
  18. SEGMENT_DOWNLOAD_TIMEOUT_MINS: 3
  19. NODE_OPTIONS: '--max-old-space-size=4096'
  20. CHARTCUTERIE_CONFIG_PATH: ${{ github.workspace }}/config/chartcuterie
  21. SNUBA_NO_WORKERS: 1
  22. jobs:
  23. files-changed:
  24. name: detect what files changed
  25. runs-on: ubuntu-24.04
  26. timeout-minutes: 3
  27. # Map a step output to a job output
  28. outputs:
  29. acceptance: ${{ steps.changes.outputs.acceptance }}
  30. backend_all: ${{ steps.changes.outputs.backend_all }}
  31. frontend_all: ${{ steps.changes.outputs.frontend_all }}
  32. steps:
  33. - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  34. - name: Check for backend file changes
  35. uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd # v3.0.0
  36. id: changes
  37. with:
  38. token: ${{ github.token }}
  39. filters: .github/file-filters.yml
  40. acceptance:
  41. if: needs.files-changed.outputs.acceptance == 'true'
  42. needs: files-changed
  43. name: acceptance
  44. runs-on: ubuntu-24.04
  45. timeout-minutes: 30
  46. permissions:
  47. contents: read
  48. id-token: write
  49. strategy:
  50. # This helps not having to run multiple jobs because one fails, thus, reducing resource usage
  51. # and reducing the risk that one of many runs would turn red again (read: intermittent tests)
  52. fail-fast: false
  53. matrix:
  54. # XXX: When updating this, make sure you also update MATRIX_INSTANCE_TOTAL.
  55. instance: [0, 1, 2, 3, 4]
  56. pg-version: ['14']
  57. env:
  58. # XXX: MATRIX_INSTANCE_TOTAL must be hardcoded to the length of strategy.matrix.instance.
  59. MATRIX_INSTANCE_TOTAL: 5
  60. TEST_GROUP_STRATEGY: roundrobin
  61. steps:
  62. - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  63. name: Checkout sentry
  64. - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
  65. id: setup-node
  66. with:
  67. node-version-file: '.volta.json'
  68. - name: Step configurations
  69. id: config
  70. run: |
  71. echo "webpack-path=.webpack_cache" >> "$GITHUB_OUTPUT"
  72. echo "WEBPACK_CACHE_PATH=.webpack_cache" >> "$GITHUB_ENV"
  73. - name: webpack cache
  74. uses: actions/cache@v4.2.0
  75. with:
  76. path: ${{ steps.config.outputs.webpack-path }}
  77. key: ${{ runner.os }}-v2-webpack-cache-${{ hashFiles('webpack.config.ts') }}
  78. - name: node_modules cache
  79. uses: actions/cache@v4.2.0
  80. id: nodemodulescache
  81. with:
  82. path: node_modules
  83. key: ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock', 'api-docs/yarn.lock', '.volta.json') }}
  84. - name: Install Javascript Dependencies
  85. if: steps.nodemodulescache.outputs.cache-hit != 'true'
  86. run: yarn install --frozen-lockfile
  87. - name: webpack
  88. env:
  89. CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
  90. # should set value either as `true` or `false`
  91. CODECOV_ENABLE_BA: ${{ needs.files-changed.outputs.frontend_all == 'true'}}
  92. GH_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
  93. run: |
  94. yarn build-acceptance
  95. - name: Build chartcuterie configuration module
  96. run: |
  97. make build-chartcuterie-config
  98. - name: Setup sentry env
  99. uses: ./.github/actions/setup-sentry
  100. id: setup
  101. with:
  102. mode: acceptance-ci
  103. - name: Run acceptance tests (#${{ steps.setup.outputs.matrix-instance-number }} of ${{ steps.setup.outputs.matrix-instance-total }})
  104. run: make run-acceptance
  105. - name: Inspect failure
  106. if: failure()
  107. run: |
  108. if command -v devservices; then
  109. devservices logs
  110. fi
  111. - name: Collect test data
  112. uses: ./.github/actions/collect-test-data
  113. if: ${{ !cancelled() }}
  114. with:
  115. artifact_path: .artifacts/pytest.acceptance.json
  116. gcs_bucket: ${{ secrets.COLLECT_TEST_DATA_GCS_BUCKET }}
  117. gcp_project_id: ${{ secrets.COLLECT_TEST_DATA_GCP_PROJECT_ID }}
  118. workload_identity_provider: ${{ secrets.SENTRY_GCP_DEV_WORKLOAD_IDENTITY_POOL }}
  119. service_account_email: ${{ secrets.COLLECT_TEST_DATA_SERVICE_ACCOUNT_EMAIL }}
  120. matrix_instance_number: ${{ steps.setup.outputs.matrix-instance-number }}
  121. # This job runs when FE or BE changes happen, however, we only upload coverage data for
  122. # BE changes since it conflicts with codecov's carry forward functionality
  123. # Upload coverage data even if running the tests step fails since
  124. # it reduces large coverage fluctuations
  125. - name: Handle artifacts
  126. uses: ./.github/actions/artifacts
  127. if: ${{ always() && needs.files-changed.outputs.backend_all == 'true' }}
  128. with:
  129. token: ${{ secrets.CODECOV_TOKEN }}
  130. commit_sha: ${{ github.event.pull_request.head.sha }}
  131. acceptance-required-checks:
  132. # this is a required check so we need this job to always run and report a status.
  133. if: always()
  134. name: Acceptance
  135. needs: [acceptance, files-changed]
  136. runs-on: ubuntu-24.04
  137. timeout-minutes: 3
  138. steps:
  139. - name: Check for failures
  140. if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
  141. run: |
  142. echo "One of the dependent jobs have failed. You may need to re-run it." && exit 1