acceptance.yml 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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. jobs:
  16. frontend:
  17. name: frontend tests
  18. runs-on: ubuntu-20.04
  19. timeout-minutes: 20
  20. strategy:
  21. matrix:
  22. instance: [0, 1]
  23. env:
  24. VISUAL_HTML_ENABLE: 1
  25. steps:
  26. - uses: actions/checkout@v2
  27. name: Checkout sentry
  28. with:
  29. # Avoid codecov error message related to SHA resolution:
  30. # https://github.com/codecov/codecov-bash/blob/7100762afbc822b91806a6574658129fe0d23a7d/codecov#L891
  31. fetch-depth: '2'
  32. - uses: volta-cli/action@v1
  33. # See https://github.com/actions/cache/blob/master/examples.md#node---yarn for example
  34. - name: Get yarn cache directory path
  35. id: yarn-cache-dir-path
  36. run: echo "::set-output name=dir::$(yarn cache dir)"
  37. - uses: actions/cache@v1 # We are explicitly using v1 due to perf reasons
  38. with:
  39. path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
  40. key: ${{ runner.os }}-v2-yarn-${{ hashFiles('yarn.lock', 'api-docs/yarn.lock') }}
  41. - name: Install dependencies
  42. run: yarn install --frozen-lockfile
  43. - name: Build CSS
  44. run: NODE_ENV=production yarn build-css
  45. - name: jest
  46. env:
  47. GITHUB_PR_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
  48. GITHUB_PR_REF: ${{ github.event.pull_request.head.ref || github.ref }}
  49. CI_NODE_TOTAL: ${{ strategy.job-total }}
  50. CI_NODE_INDEX: ${{ matrix.instance }}
  51. run: |
  52. JEST_TESTS=$(yarn -s jest --listTests --json) yarn test-ci --forceExit
  53. - name: Save HTML artifacts
  54. uses: actions/upload-artifact@v2
  55. with:
  56. retention-days: 14
  57. name: jest-html
  58. path: .artifacts/visual-snapshots/jest
  59. - name: Create Images from HTML
  60. uses: getsentry/action-html-to-image@main
  61. with:
  62. base-path: .artifacts/visual-snapshots/jest
  63. css-path: src/sentry/static/sentry/dist/entrypoints/sentry.css
  64. - name: Save snapshots
  65. if: always()
  66. uses: getsentry/action-visual-snapshot@v2
  67. with:
  68. save-only: true
  69. snapshot-path: .artifacts/visual-snapshots
  70. - name: Handle artifacts
  71. uses: ./.github/actions/artifacts
  72. webpack:
  73. name: create frontend bundle
  74. runs-on: ubuntu-20.04
  75. timeout-minutes: 10
  76. outputs:
  77. dist-path: ${{ steps.config.outputs.dist-path }}
  78. steps:
  79. - uses: actions/checkout@v2
  80. name: Checkout sentry
  81. - uses: volta-cli/action@v1
  82. - name: Step configurations
  83. id: config
  84. run: |
  85. echo "::set-output name=yarn-path::$(yarn cache dir)"
  86. echo "::set-output name=webpack-path::.webpack_cache"
  87. echo "::set-output name=dist-path::src/sentry/static/sentry/dist"
  88. - name: yarn cache
  89. uses: actions/cache@v1 # We are explicitly using v1 due to perf reasons
  90. with:
  91. path: ${{ steps.config.outputs.yarn-path }}
  92. key: ${{ runner.os }}-v2-yarn-${{ hashFiles('yarn.lock', 'api-docs/yarn.lock') }}
  93. - name: webpack cache
  94. uses: actions/cache@v2
  95. with:
  96. path: ${{ steps.config.outputs.webpack-path }}
  97. key: ${{ runner.os }}-v2-webpack-cache-${{ hashFiles('webpack.config.ts') }}
  98. - name: Install Javascript Dependencies
  99. run: |
  100. yarn install --frozen-lockfile
  101. - name: webpack
  102. env:
  103. WEBPACK_CACHE_PATH: ${{ steps.config.outputs.webpack-path }}
  104. SENTRY_INSTRUMENTATION: 1
  105. # this is fine to not have for forks, it shouldn't fail
  106. SENTRY_WEBPACK_WEBHOOK_SECRET: ${{ secrets.SENTRY_WEBPACK_WEBHOOK_SECRET }}
  107. run: |
  108. yarn build-acceptance
  109. # Bundle dist for faster uploading
  110. - name: bundle dist
  111. run: |
  112. tar czf dist.tar.gz ${{ steps.config.outputs.dist-path }}
  113. - name: Save frontend dist
  114. uses: actions/upload-artifact@v2
  115. with:
  116. retention-days: 3
  117. name: frontend-dist
  118. path: dist.tar.gz
  119. acceptance:
  120. name: acceptance
  121. runs-on: ubuntu-20.04
  122. timeout-minutes: 20
  123. strategy:
  124. matrix:
  125. instance: [0, 1, 2, 3]
  126. env:
  127. VISUAL_SNAPSHOT_ENABLE: 1
  128. TEST_GROUP_STRATEGY: roundrobin
  129. steps:
  130. - name: Checkout sentry
  131. uses: actions/checkout@v2
  132. - name: Setup sentry python env
  133. uses: ./.github/actions/setup-sentry
  134. id: setup
  135. with:
  136. pip-cache-version: ${{ secrets.PIP_CACHE_VERSION }}
  137. snuba: true
  138. - name: Wait for frontend build
  139. uses: getsentry/action-wait-for-check@v1.0.0
  140. id: wait-for-frontend
  141. with:
  142. token: ${{ secrets.GITHUB_TOKEN }}
  143. checkName: create frontend bundle
  144. ref: ${{ github.event.pull_request.head.sha || github.sha }}
  145. - name: Download frontend dist
  146. uses: actions/download-artifact@v2
  147. with:
  148. name: frontend-dist
  149. - name: Extract dist
  150. run: |
  151. tar xf dist.tar.gz
  152. - name: Run acceptance tests (#${{ steps.setup.outputs.matrix-instance-number }} of ${{ strategy.job-total }})
  153. if: always()
  154. run: |
  155. mkdir -p ${{ steps.setup.outputs.acceptance-dir }}
  156. mkdir -p ${{ steps.setup.outputs.acceptance-dir }}-mobile
  157. mkdir -p ${{ steps.setup.outputs.acceptance-dir }}-tooltips
  158. make run-acceptance
  159. env:
  160. PYTEST_SNAPSHOTS_DIR: ${{ steps.setup.outputs.acceptance-dir }}
  161. USE_SNUBA: 1
  162. - name: Save snapshots
  163. if: always()
  164. uses: getsentry/action-visual-snapshot@v2
  165. with:
  166. save-only: true
  167. snapshot-path: .artifacts/visual-snapshots
  168. - name: Handle artifacts
  169. uses: ./.github/actions/artifacts
  170. chartcuterie:
  171. name: chartcuterie integration
  172. runs-on: ubuntu-20.04
  173. timeout-minutes: 30
  174. strategy:
  175. matrix:
  176. instance: [0]
  177. env:
  178. VISUAL_SNAPSHOT_ENABLE: 1
  179. steps:
  180. - uses: actions/checkout@v2
  181. with:
  182. # Avoid codecov error message related to SHA resolution:
  183. # https://github.com/codecov/codecov-bash/blob/7100762afbc822b91806a6574658129fe0d23a7d/codecov#L891
  184. fetch-depth: '2'
  185. - name: Setup sentry env
  186. uses: ./.github/actions/setup-sentry
  187. id: setup
  188. with:
  189. pip-cache-version: ${{ secrets.PIP_CACHE_VERSION }}
  190. chartcuterie: true
  191. - name: yarn cache
  192. uses: actions/cache@v1 # We are explicitly using v1 due to perf reasons
  193. with:
  194. path: ${{ steps.setup.outputs.yarn-cache-dir }}
  195. key: ${{ runner.os }}-v2-yarn-${{ hashFiles('yarn.lock', 'api-docs/yarn.lock') }}
  196. - name: Install Javascript Dependencies
  197. run: |
  198. yarn install --frozen-lockfile
  199. - name: Build chartcuterie configuration module
  200. run: |
  201. make build-chartcuterie-config
  202. - name: Run chartcuterie tests (${{ steps.setup.outputs.matrix-instance-number }} of ${{ strategy.job-total }})
  203. run: |
  204. mkdir -p ${{ steps.setup.outputs.acceptance-dir }}
  205. make test-chartcuterie
  206. env:
  207. PYTEST_SNAPSHOTS_DIR: ${{ steps.setup.outputs.acceptance-dir }}
  208. - name: Save snapshots
  209. if: always()
  210. uses: getsentry/action-visual-snapshot@v2
  211. with:
  212. save-only: true
  213. snapshot-path: .artifacts/visual-snapshots
  214. - name: Handle artifacts
  215. uses: ./.github/actions/artifacts