acceptance.yml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. # XXX: We are using `pull_request_target` instead of `pull_request` because we want
  15. # Visual Snapshots to run on forks. It allows forks to access secrets safely by
  16. # only running workflows from the main branch. Prefer to use `pull_request` when possible.
  17. #
  18. # See https://github.com/getsentry/sentry/pull/21600 for more details
  19. pull_request_target:
  20. jobs:
  21. frontend:
  22. name: frontend tests
  23. runs-on: ubuntu-16.04
  24. timeout-minutes: 20
  25. env:
  26. VISUAL_HTML_ENABLE: 1
  27. steps:
  28. - uses: actions/checkout@v2
  29. name: Checkout sentry (pull_request_target)
  30. if: github.event.pull_request.head.ref != ''
  31. with:
  32. # Note this is required because of `pull_request_target`, which allows
  33. # forks to access secrets safely by only running workflows from the main branch.
  34. ref: ${{ github.event.pull_request.head.ref }}
  35. repository: ${{ github.event.pull_request.head.repo.full_name }}
  36. - uses: actions/checkout@v2
  37. name: Checkout sentry (push)
  38. if: github.event.pull_request.head.ref == ''
  39. - uses: volta-cli/action@v1
  40. # See https://github.com/actions/cache/blob/master/examples.md#node---yarn for example
  41. - name: Get yarn cache directory path
  42. id: yarn-cache-dir-path
  43. run: echo "::set-output name=dir::$(yarn cache dir)"
  44. - uses: actions/cache@v2
  45. id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
  46. with:
  47. path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
  48. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  49. restore-keys: |
  50. ${{ runner.os }}-yarn-
  51. - name: Install dependencies
  52. run: yarn install --frozen-lockfile
  53. - name: jest
  54. run: |
  55. NODE_ENV=production yarn build-css
  56. yarn test-ci --forceExit
  57. - name: Save HTML artifacts
  58. uses: actions/upload-artifact@v2
  59. with:
  60. name: jest-html
  61. path: .artifacts/visual-snapshots/jest
  62. - name: Create Images from HTML
  63. uses: getsentry/action-html-to-image@main
  64. with:
  65. base-path: .artifacts/visual-snapshots/jest
  66. css-path: src/sentry/static/sentry/dist/sentry.css
  67. - name: Save snapshots
  68. if: always()
  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. acceptance:
  76. # TODO(joshuarli): Convert to py3 with snapshots. See other TODO as well.
  77. name: python2.7 acceptance
  78. runs-on: ubuntu-16.04
  79. timeout-minutes: 20
  80. strategy:
  81. matrix:
  82. instance: [0, 1, 2]
  83. env:
  84. VISUAL_SNAPSHOT_ENABLE: 1
  85. TEST_GROUP_STRATEGY: roundrobin
  86. steps:
  87. - uses: actions/checkout@v2
  88. name: Checkout sentry (pull_request_target)
  89. if: github.event.pull_request.head.ref != ''
  90. with:
  91. # Note this is required because of `pull_request_target`, which allows
  92. # forks to access secrets safely by only running workflows from the main branch.
  93. ref: ${{ github.event.pull_request.head.ref }}
  94. repository: ${{ github.event.pull_request.head.repo.full_name }}
  95. - uses: actions/checkout@v2
  96. name: Checkout sentry (push)
  97. if: github.event.pull_request.head.ref == ''
  98. - uses: volta-cli/action@v1
  99. # Until GH composite actions can use `uses`, we need to setup python here
  100. - uses: actions/setup-python@v2
  101. with:
  102. python-version: 2.7.17
  103. - name: Setup pip
  104. uses: ./.github/actions/setup-pip
  105. id: pip
  106. - name: pip cache
  107. uses: actions/cache@v2
  108. with:
  109. path: ${{ steps.pip.outputs.pip-cache-dir }}
  110. key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-*.txt') }}
  111. restore-keys: |
  112. ${{ runner.os }}-pip-
  113. - name: Setup sentry env
  114. uses: ./.github/actions/setup-sentry
  115. id: setup
  116. with:
  117. python: 2
  118. snuba: true
  119. - uses: actions/cache@v2
  120. id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
  121. with:
  122. path: ${{ steps.setup.outputs.yarn-cache-dir }}
  123. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  124. restore-keys: |
  125. ${{ runner.os }}-yarn-
  126. - name: Install Javascript Dependencies
  127. run: |
  128. yarn install --frozen-lockfile
  129. - name: webpack
  130. env:
  131. SENTRY_INSTRUMENTATION: 1
  132. SENTRY_WEBPACK_WEBHOOK_SECRET: ${{ secrets.SENTRY_WEBPACK_WEBHOOK_SECRET }}
  133. run: |
  134. yarn webpack --display errors-only
  135. - name: Run acceptance tests (#${{ steps.setup.outputs.matrix-instance-number }} of ${{ strategy.job-total }})
  136. if: always()
  137. run: |
  138. mkdir -p ${{ steps.setup.outputs.acceptance-dir }}
  139. mkdir -p ${{ steps.setup.outputs.acceptance-dir }}-mobile
  140. mkdir -p ${{ steps.setup.outputs.acceptance-dir }}-tooltips
  141. make run-acceptance
  142. env:
  143. PYTEST_SNAPSHOTS_DIR: ${{ steps.setup.outputs.acceptance-dir }}
  144. USE_SNUBA: 1
  145. - name: Save snapshots
  146. if: always()
  147. uses: getsentry/action-visual-snapshot@v2
  148. with:
  149. save-only: true
  150. snapshot-path: .artifacts/visual-snapshots
  151. visual-diff:
  152. # Note: `github.ref` is always `master` for `pull_request_target` event
  153. # `github.head/base_ref` == '' for `push` event, we want to skip it on pushes
  154. if: github.head_ref != ''
  155. needs: [acceptance, frontend]
  156. runs-on: ubuntu-16.04
  157. timeout-minutes: 20
  158. steps:
  159. # We need to checkout the repository so that we can fetch the merge base from git
  160. - uses: actions/checkout@v2
  161. name: Checkout sentry
  162. if: github.event.pull_request.head.ref != ''
  163. with:
  164. ref: ${{ github.event.pull_request.head.ref }}
  165. repository: ${{ github.event.pull_request.head.repo.full_name }}
  166. # fetch all history so we can use `git merge-base`
  167. fetch-depth: 0
  168. # Because of pull_request_target event, `github.event.pull_request.base` will refer to latest
  169. # commit on main branch when opening the PR
  170. - name: Get merge base
  171. if: github.event.pull_request.head.ref != ''
  172. id: merge-base
  173. run: |
  174. echo "::set-output name=sha::$(git merge-base origin/master ${{ github.event.pull_request.head.ref }})"
  175. - name: Diff snapshots
  176. id: visual-snapshots-diff
  177. uses: getsentry/action-visual-snapshot@v2
  178. with:
  179. merge-base: ${{ steps.merge-base.outputs.sha }}
  180. api-token: ${{ secrets.VISUAL_SNAPSHOT_SECRET }}
  181. github-token: ${{ secrets.GITHUB_TOKEN }}
  182. gcs-bucket: 'sentry-visual-snapshots'
  183. gcp-service-account-key: ${{ secrets.SNAPSHOT_GOOGLE_SERVICE_ACCOUNT_KEY }}