acceptance.yml 6.2 KB

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