acceptance.yml 8.9 KB

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