acceptance.yml 4.9 KB

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