acceptance.yml 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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. run: |
  47. CI_NODE_TOTAL=${{ strategy.job-total }} CI_NODE_INDEX=${{ matrix.instance }} JEST_TESTS=$(yarn -s jest --listTests --json) yarn test-ci --forceExit
  48. - name: Save HTML artifacts
  49. uses: actions/upload-artifact@v2
  50. with:
  51. retention-days: 14
  52. name: jest-html
  53. path: .artifacts/visual-snapshots/jest
  54. - name: Create Images from HTML
  55. uses: getsentry/action-html-to-image@main
  56. with:
  57. base-path: .artifacts/visual-snapshots/jest
  58. css-path: src/sentry/static/sentry/dist/entrypoints/sentry.css
  59. - name: Save snapshots
  60. if: always()
  61. uses: getsentry/action-visual-snapshot@v2
  62. with:
  63. save-only: true
  64. snapshot-path: .artifacts/visual-snapshots
  65. - name: Handle artifacts
  66. uses: ./.github/actions/artifacts
  67. webpack:
  68. name: create frontend bundle
  69. runs-on: ubuntu-20.04
  70. timeout-minutes: 10
  71. outputs:
  72. dist-path: ${{ steps.config.outputs.dist-path }}
  73. steps:
  74. - uses: actions/checkout@v2
  75. name: Checkout sentry
  76. - uses: volta-cli/action@v1
  77. - name: Step configurations
  78. id: config
  79. run: |
  80. echo "::set-output name=yarn-path::$(yarn cache dir)"
  81. echo "::set-output name=webpack-path::.webpack_cache"
  82. echo "::set-output name=dist-path::src/sentry/static/sentry/dist"
  83. - name: yarn cache
  84. uses: actions/cache@v1 # We are explicitly using v1 due to perf reasons
  85. with:
  86. path: ${{ steps.config.outputs.yarn-path }}
  87. key: ${{ runner.os }}-v2-yarn-${{ hashFiles('yarn.lock', 'api-docs/yarn.lock') }}
  88. - name: webpack cache
  89. uses: actions/cache@v2
  90. with:
  91. path: ${{ steps.config.outputs.webpack-path }}
  92. key: ${{ runner.os }}-v2-webpack-cache-${{ hashFiles('webpack.config.ts') }}
  93. - name: Install Javascript Dependencies
  94. run: |
  95. yarn install --frozen-lockfile
  96. - name: webpack
  97. env:
  98. WEBPACK_CACHE_PATH: ${{ steps.config.outputs.webpack-path }}
  99. SENTRY_INSTRUMENTATION: 1
  100. # this is fine to not have for forks, it shouldn't fail
  101. SENTRY_WEBPACK_WEBHOOK_SECRET: ${{ secrets.SENTRY_WEBPACK_WEBHOOK_SECRET }}
  102. run: |
  103. yarn build-acceptance
  104. # Bundle dist for faster uploading
  105. - name: bundle dist
  106. run: |
  107. tar czf dist.tar.gz ${{ steps.config.outputs.dist-path }}
  108. - name: Save frontend dist
  109. uses: actions/upload-artifact@v2
  110. with:
  111. retention-days: 3
  112. name: frontend-dist
  113. path: dist.tar.gz
  114. acceptance:
  115. name: acceptance
  116. runs-on: ubuntu-20.04
  117. timeout-minutes: 20
  118. strategy:
  119. matrix:
  120. instance: [0, 1, 2, 3]
  121. env:
  122. VISUAL_SNAPSHOT_ENABLE: 1
  123. TEST_GROUP_STRATEGY: roundrobin
  124. steps:
  125. - uses: actions/checkout@v2
  126. name: Checkout sentry
  127. - name: Set python version output
  128. id: python-version
  129. run: |
  130. echo "::set-output name=python-version::$(cat .python-version)"
  131. # Until GH composite actions can use `uses`, we need to setup python here
  132. - uses: actions/setup-python@v2
  133. with:
  134. python-version: ${{ steps.python-version.outputs.python-version }}
  135. - name: Setup pip
  136. uses: ./.github/actions/setup-pip
  137. id: pip
  138. - name: pip cache
  139. uses: actions/cache@v2
  140. with:
  141. path: ${{ steps.pip.outputs.pip-cache-dir }}
  142. key: |
  143. ${{ runner.os }}-py${{ steps.python-version.outputs.python-version }}-pip${{ steps.pip.outputs.pip-version }}-${{ secrets.PIP_CACHE_VERSION }}-${{ hashFiles('requirements-*.txt', '!requirements-pre-commit.txt') }}
  144. - name: Setup sentry python env
  145. uses: ./.github/actions/setup-sentry
  146. id: setup
  147. with:
  148. snuba: true
  149. - name: Wait for frontend build
  150. uses: getsentry/action-wait-for-check@v1.0.0
  151. id: wait-for-frontend
  152. with:
  153. token: ${{ secrets.GITHUB_TOKEN }}
  154. checkName: create frontend bundle
  155. ref: ${{ github.event.pull_request.head.sha || github.sha }}
  156. - name: Download frontend dist
  157. uses: actions/download-artifact@v2
  158. with:
  159. name: frontend-dist
  160. - name: Extract dist
  161. run: |
  162. tar xf dist.tar.gz
  163. - name: Run acceptance tests (#${{ steps.setup.outputs.matrix-instance-number }} of ${{ strategy.job-total }})
  164. if: always()
  165. run: |
  166. mkdir -p ${{ steps.setup.outputs.acceptance-dir }}
  167. mkdir -p ${{ steps.setup.outputs.acceptance-dir }}-mobile
  168. mkdir -p ${{ steps.setup.outputs.acceptance-dir }}-tooltips
  169. make run-acceptance
  170. env:
  171. PYTEST_SNAPSHOTS_DIR: ${{ steps.setup.outputs.acceptance-dir }}
  172. USE_SNUBA: 1
  173. - name: Save snapshots
  174. if: always()
  175. uses: getsentry/action-visual-snapshot@v2
  176. with:
  177. save-only: true
  178. snapshot-path: .artifacts/visual-snapshots
  179. - name: Handle artifacts
  180. uses: ./.github/actions/artifacts
  181. chartcuterie:
  182. name: chartcuterie integration
  183. runs-on: ubuntu-20.04
  184. timeout-minutes: 30
  185. strategy:
  186. matrix:
  187. instance: [0]
  188. env:
  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: Set python version output
  197. id: python-version
  198. run: |
  199. echo "::set-output name=python-version::$(cat .python-version)"
  200. # Until GH composite actions can use `uses`, we need to setup python here
  201. - uses: actions/setup-python@v2
  202. with:
  203. python-version: ${{ steps.python-version.outputs.python-version }}
  204. - name: Setup pip
  205. uses: ./.github/actions/setup-pip
  206. id: pip
  207. - name: pip cache
  208. uses: actions/cache@v2
  209. with:
  210. path: ${{ steps.pip.outputs.pip-cache-dir }}
  211. key: |
  212. ${{ runner.os }}-py${{ steps.python-version.outputs.python-version }}-pip${{ steps.pip.outputs.pip-version }}-${{ secrets.PIP_CACHE_VERSION }}-${{ hashFiles('requirements-*.txt', '!requirements-pre-commit.txt') }}
  213. - name: Setup sentry env
  214. uses: ./.github/actions/setup-sentry
  215. id: setup
  216. with:
  217. chartcuterie: true
  218. - name: yarn cache
  219. uses: actions/cache@v1 # We are explicitly using v1 due to perf reasons
  220. with:
  221. path: ${{ steps.setup.outputs.yarn-cache-dir }}
  222. key: ${{ runner.os }}-v2-yarn-${{ hashFiles('yarn.lock', 'api-docs/yarn.lock') }}
  223. - name: Install Javascript Dependencies
  224. run: |
  225. yarn install --frozen-lockfile
  226. - name: Build chartcuterie configuration module
  227. run: |
  228. make build-chartcuterie-config
  229. - name: Run chartcuterie tests (${{ steps.setup.outputs.matrix-instance-number }} of ${{ strategy.job-total }})
  230. run: |
  231. mkdir -p ${{ steps.setup.outputs.acceptance-dir }}
  232. make test-chartcuterie
  233. env:
  234. PYTEST_SNAPSHOTS_DIR: ${{ steps.setup.outputs.acceptance-dir }}
  235. - name: Save snapshots
  236. if: always()
  237. uses: getsentry/action-visual-snapshot@v2
  238. with:
  239. save-only: true
  240. snapshot-path: .artifacts/visual-snapshots
  241. - name: Handle artifacts
  242. uses: ./.github/actions/artifacts