acceptance.yml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. # TODO(billy): this workflow has not been re-named from `acceptance` because
  2. # Visual Snapshots compares against artifacts from the same workflow name (on main branch)
  3. # We should rename this when we have a more finalized naming scheme.
  4. #
  5. # Also note that this name *MUST* match the filename because GHA
  6. # only provides the workflow name (https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables#default-environment-variables)
  7. # and GH APIs only support querying by workflow *FILENAME* (https://developer.github.com/v3/actions/workflows/#get-a-workflow)
  8. name: acceptance
  9. on:
  10. push:
  11. branches:
  12. - master
  13. - releases/**
  14. pull_request:
  15. # Cancel in progress workflows on pull_requests.
  16. # https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
  17. concurrency:
  18. group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  19. cancel-in-progress: true
  20. # hack for https://github.com/actions/cache/issues/810#issuecomment-1222550359
  21. env:
  22. SEGMENT_DOWNLOAD_TIMEOUT_MINS: 3
  23. jobs:
  24. files-changed:
  25. name: detect what files changed
  26. runs-on: ubuntu-20.04
  27. timeout-minutes: 3
  28. # Map a step output to a job output
  29. outputs:
  30. acceptance: ${{ steps.changes.outputs.acceptance }}
  31. backend_all: ${{ steps.changes.outputs.backend_all }}
  32. steps:
  33. - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
  34. - name: Check for backend file changes
  35. uses: getsentry/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
  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-20.04
  45. timeout-minutes: 25
  46. strategy:
  47. # This helps not having to run multiple jobs because one fails, thus, reducing resource usage
  48. # and reducing the risk that one of many runs would turn red again (read: intermittent tests)
  49. fail-fast: false
  50. matrix:
  51. # XXX: When updating this, make sure you also update MATRIX_INSTANCE_TOTAL.
  52. instance: [0, 1, 2, 3, 4]
  53. pg-version: ['14']
  54. env:
  55. # XXX: MATRIX_INSTANCE_TOTAL must be hardcoded to the length of strategy.matrix.instance.
  56. MATRIX_INSTANCE_TOTAL: 5
  57. VISUAL_SNAPSHOT_ENABLE: 1
  58. TEST_GROUP_STRATEGY: roundrobin
  59. steps:
  60. - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
  61. name: Checkout sentry
  62. - uses: getsentry/action-setup-volta@54775a59c41065f54ecc76d1dd5f2cdc7a1550cb # v1.1.0
  63. - name: Step configurations
  64. id: config
  65. run: echo "webpack-path=.webpack_cache" >> "$GITHUB_OUTPUT"
  66. - name: webpack cache
  67. uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11
  68. with:
  69. path: ${{ steps.config.outputs.webpack-path }}
  70. key: ${{ runner.os }}-v2-webpack-cache-${{ hashFiles('webpack.config.ts') }}
  71. - name: node_modules cache
  72. uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11
  73. id: nodemodulescache
  74. with:
  75. path: node_modules
  76. key: ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock', 'api-docs/yarn.lock') }}
  77. - name: Install Javascript Dependencies
  78. if: steps.nodemodulescache.outputs.cache-hit != 'true'
  79. run: yarn install --frozen-lockfile
  80. - name: webpack
  81. env:
  82. WEBPACK_CACHE_PATH: ${{ steps.config.outputs.webpack-path }}
  83. SENTRY_INSTRUMENTATION: 1
  84. # this is fine to not have for forks, it shouldn't fail
  85. SENTRY_WEBPACK_WEBHOOK_SECRET: ${{ secrets.SENTRY_WEBPACK_WEBHOOK_SECRET }}
  86. run: |
  87. yarn build-acceptance
  88. - name: Build chartcuterie configuration module
  89. run: |
  90. make build-chartcuterie-config
  91. - name: Setup sentry env
  92. uses: ./.github/actions/setup-sentry
  93. id: setup
  94. with:
  95. snuba: true
  96. chartcuterie: true
  97. pg-version: ${{ matrix.pg-version }}
  98. - name: Run acceptance tests (#${{ steps.setup.outputs.matrix-instance-number }} of ${{ steps.setup.outputs.matrix-instance-total }})
  99. run: |
  100. mkdir -p ${{ steps.setup.outputs.acceptance-dir }}
  101. mkdir -p ${{ steps.setup.outputs.acceptance-dir }}-mobile
  102. mkdir -p ${{ steps.setup.outputs.acceptance-dir }}-tooltips
  103. make run-acceptance
  104. env:
  105. PYTEST_SNAPSHOTS_DIR: ${{ steps.setup.outputs.acceptance-dir }}
  106. # This job runs when FE or BE changes happen, however, we only upload coverage data for
  107. # BE changes since it conflicts with codecov's carry forward functionality
  108. # Upload coverage data even if running the tests step fails since
  109. # it reduces large coverage fluctuations
  110. - name: Handle artifacts
  111. uses: ./.github/actions/artifacts
  112. if: ${{ always() && needs.files-changed.outputs.backend_all == 'true' }}
  113. acceptance-required-checks:
  114. # this is a required check so we need this job to always run and report a status.
  115. if: always()
  116. name: Acceptance
  117. needs: [acceptance, files-changed]
  118. runs-on: ubuntu-20.04
  119. timeout-minutes: 20
  120. steps:
  121. # If any jobs we depend on fail, we will fail since this check calls the
  122. # visual snapshot service which creates the "Visual Snapshot" status,
  123. # which is a required check.
  124. # NOTE: A timeout is considered a failure
  125. - name: Check for failures
  126. if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
  127. run: |
  128. echo "One of the dependent jobs have failed. You may need to re-run it." && exit 1