acceptance.yml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. jobs:
  21. files-changed:
  22. name: detect what files changed
  23. runs-on: ubuntu-22.04
  24. timeout-minutes: 3
  25. # Map a step output to a job output
  26. outputs:
  27. acceptance: ${{ steps.changes.outputs.acceptance }}
  28. backend_all: ${{ steps.changes.outputs.backend_all }}
  29. steps:
  30. - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
  31. - name: Check for backend file changes
  32. uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd # v3.0.0
  33. id: changes
  34. with:
  35. token: ${{ github.token }}
  36. filters: .github/file-filters.yml
  37. acceptance:
  38. if: needs.files-changed.outputs.acceptance == 'true'
  39. needs: files-changed
  40. name: acceptance
  41. runs-on: ubuntu-22.04
  42. timeout-minutes: 30
  43. strategy:
  44. # This helps not having to run multiple jobs because one fails, thus, reducing resource usage
  45. # and reducing the risk that one of many runs would turn red again (read: intermittent tests)
  46. fail-fast: false
  47. matrix:
  48. # XXX: When updating this, make sure you also update MATRIX_INSTANCE_TOTAL.
  49. instance: [0, 1, 2, 3, 4]
  50. pg-version: ['14']
  51. env:
  52. # XXX: MATRIX_INSTANCE_TOTAL must be hardcoded to the length of strategy.matrix.instance.
  53. MATRIX_INSTANCE_TOTAL: 5
  54. TEST_GROUP_STRATEGY: roundrobin
  55. steps:
  56. - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
  57. name: Checkout sentry
  58. - uses: getsentry/action-setup-volta@e4939d337b83760d13a9d7030a6f68c9d0ee7581 # v2.0.0
  59. - name: Step configurations
  60. id: config
  61. run: |
  62. echo "webpack-path=.webpack_cache" >> "$GITHUB_OUTPUT"
  63. echo "WEBPACK_CACHE_PATH=.webpack_cache" >> "$GITHUB_ENV"
  64. - name: webpack cache
  65. uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
  66. with:
  67. path: ${{ steps.config.outputs.webpack-path }}
  68. key: ${{ runner.os }}-v2-webpack-cache-${{ hashFiles('webpack.config.ts') }}
  69. - name: node_modules cache
  70. uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
  71. id: nodemodulescache
  72. with:
  73. path: node_modules
  74. key: ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock', 'api-docs/yarn.lock') }}
  75. - name: Install Javascript Dependencies
  76. if: steps.nodemodulescache.outputs.cache-hit != 'true'
  77. run: yarn install --frozen-lockfile
  78. - name: webpack
  79. env:
  80. # this is fine to not have for forks, it shouldn't fail
  81. SENTRY_WEBPACK_WEBHOOK_SECRET: ${{ secrets.SENTRY_WEBPACK_WEBHOOK_SECRET }}
  82. CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
  83. run: |
  84. yarn build-acceptance
  85. - name: Build chartcuterie configuration module
  86. run: |
  87. make build-chartcuterie-config
  88. - name: Setup sentry env
  89. uses: ./.github/actions/setup-sentry
  90. id: setup
  91. with:
  92. snuba: true
  93. chartcuterie: true
  94. pg-version: ${{ matrix.pg-version }}
  95. - name: Run acceptance tests (#${{ steps.setup.outputs.matrix-instance-number }} of ${{ steps.setup.outputs.matrix-instance-total }})
  96. run: make run-acceptance
  97. # This job runs when FE or BE changes happen, however, we only upload coverage data for
  98. # BE changes since it conflicts with codecov's carry forward functionality
  99. # Upload coverage data even if running the tests step fails since
  100. # it reduces large coverage fluctuations
  101. - name: Handle artifacts
  102. uses: ./.github/actions/artifacts
  103. if: ${{ always() && needs.files-changed.outputs.backend_all == 'true' }}
  104. with:
  105. token: ${{ secrets.CODECOV_TOKEN }}
  106. acceptance-required-checks:
  107. # this is a required check so we need this job to always run and report a status.
  108. if: always()
  109. name: Acceptance
  110. needs: [acceptance, files-changed]
  111. runs-on: ubuntu-22.04
  112. timeout-minutes: 3
  113. steps:
  114. - name: Check for failures
  115. if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
  116. run: |
  117. echo "One of the dependent jobs have failed. You may need to re-run it." && exit 1