acceptance.yml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. name: acceptance
  2. on:
  3. push:
  4. branches:
  5. - master
  6. pull_request:
  7. jobs:
  8. parse-commit-message:
  9. if: ${{ github.ref != 'refs/heads/master' }}
  10. runs-on: ubuntu-16.04
  11. outputs:
  12. commit: ${{ steps.commit.outputs.message }}
  13. steps:
  14. - uses: actions/checkout@v2
  15. with:
  16. ref: ${{ github.event.pull_request.head.sha }}
  17. - name: Parse commit message
  18. id: commit
  19. run: |
  20. echo "::set-output name=message::$(git show -s --format=%B)"
  21. getsentry:
  22. needs: parse-commit-message
  23. if: ${{ contains(needs.parse-commit-message.outputs.commit, '#test-getsentry') }}
  24. runs-on: ubuntu-16.04
  25. steps:
  26. - name: getsentry token
  27. id: getsentry
  28. uses: getsentry/action-github-app-token@v1
  29. with:
  30. app_id: ${{ secrets.SENTRY_INTERNAL_APP_ID }}
  31. private_key: ${{ secrets.SENTRY_INTERNAL_APP_PRIVATE_KEY }}
  32. # Notify getsentry
  33. - name: Dispatch getsentry tests
  34. uses: actions/github-script@v3
  35. with:
  36. github-token: ${{ steps.getsentry.outputs.token }}
  37. script: |
  38. github.actions.createWorkflowDispatch({
  39. owner: 'getsentry',
  40. repo: 'getsentry',
  41. workflow_id: 'acceptance.yml',
  42. ref: 'master',
  43. inputs: {
  44. sha: '${{ github.event.pull_request.head.sha }}',
  45. }
  46. })
  47. jest:
  48. runs-on: ubuntu-latest
  49. env:
  50. VISUAL_HTML_ENABLE: 1
  51. steps:
  52. # Checkout codebase
  53. - uses: actions/checkout@v2
  54. # Install/setup node
  55. - uses: volta-cli/action@v1
  56. # See https://github.com/actions/cache/blob/master/examples.md#node---yarn for example
  57. - name: Get yarn cache directory path
  58. id: yarn-cache-dir-path
  59. run: echo "::set-output name=dir::$(yarn cache dir)"
  60. # yarn cache
  61. - uses: actions/cache@v1
  62. id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
  63. with:
  64. path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
  65. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  66. restore-keys: |
  67. ${{ runner.os }}-yarn-
  68. - name: Install dependencies
  69. run: yarn install --frozen-lockfile
  70. - name: jest
  71. run: |
  72. NODE_ENV=production yarn build-css
  73. yarn test-ci --forceExit
  74. - name: Save HTML artifacts
  75. uses: actions/upload-artifact@v2
  76. with:
  77. name: jest-html
  78. path: .artifacts/visual-snapshots/jest
  79. - name: Create Images from HTML
  80. uses: getsentry/action-html-to-image@main
  81. with:
  82. base-path: .artifacts/visual-snapshots/jest
  83. css-path: src/sentry/static/sentry/dist/sentry.css
  84. - name: Save snapshots
  85. if: always()
  86. uses: getsentry/action-visual-snapshot@v2
  87. with:
  88. save-only: true
  89. snapshot-path: .artifacts/visual-snapshots
  90. acceptance:
  91. runs-on: ubuntu-16.04
  92. continue-on-error: true
  93. strategy:
  94. matrix:
  95. instance: [0, 1, 2]
  96. env:
  97. PIP_DISABLE_PIP_VERSION_CHECK: on
  98. # PIP_QUIET: 1
  99. SENTRY_LIGHT_BUILD: 1
  100. SENTRY_SKIP_BACKEND_VALIDATION: 1
  101. MIGRATIONS_TEST_MIGRATE: 0
  102. # Node configuration
  103. NODE_OPTIONS: --max-old-space-size=4096
  104. NODE_ENV: development
  105. PYTEST_SENTRY_DSN: https://6fd5cfea2d4d46b182ad214ac7810508@sentry.io/2423079
  106. PYTEST_ADDOPTS: "--reruns 5"
  107. # services configuration
  108. SENTRY_KAFKA_HOSTS: kafka:9093
  109. SENTRY_ZOOKEEPER_HOSTS: zookeeper:2182
  110. SENTRY_REDIS_HOST: redis
  111. # The hostname used to communicate with the PostgreSQL from sentry
  112. DATABASE_URL: postgresql://postgres:postgres@localhost/sentry
  113. # Number of matrix instances
  114. TOTAL_TEST_GROUPS: ${{ strategy.job-total }}
  115. VISUAL_SNAPSHOT_ENABLE: 1
  116. steps:
  117. - name: Install System Dependencies
  118. run: |
  119. sudo apt-get update
  120. sudo apt-get install -y --no-install-recommends \
  121. libxmlsec1-dev \
  122. libmaxminddb-dev
  123. # Checkout codebase
  124. - uses: actions/checkout@v2
  125. # Install node
  126. - uses: volta-cli/action@v1
  127. # Yarn
  128. # - See https://github.com/actions/cache/blob/master/examples.md#node---yarn for example
  129. # Python
  130. # Use `.python-version` to avoid duplication
  131. # XXX: can't actually read from .python-version because GitHub Actions
  132. # does not support our version (2.7.16)
  133. #
  134. # XXX: Using `2.7` as GHA image only seems to keep one minor version around and will break
  135. # CI if we pin it to a specific patch version.
  136. - name: Set up outputs
  137. id: config
  138. env:
  139. MATRIX_INSTANCE: ${{ matrix.instance }}
  140. run: |
  141. echo "::set-output name=yarn-cache-dir::$(yarn cache dir)"
  142. echo "::set-output name=python-version::2.7"
  143. echo "::set-output name=matrix-instance-number::$(($MATRIX_INSTANCE+1))"
  144. echo "::set-output name=acceptance-dir::.artifacts/visual-snapshots/acceptance"
  145. # yarn cache
  146. - uses: actions/cache@v1
  147. id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
  148. with:
  149. path: ${{ steps.config.outputs.yarn-cache-dir }}
  150. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  151. restore-keys: |
  152. ${{ runner.os }}-yarn-
  153. # setup python
  154. - name: Set up Python ${{ steps.config.outputs.python-version }}
  155. uses: actions/setup-python@v1
  156. with:
  157. python-version: ${{ steps.config.outputs.python-version}}
  158. # setup pip
  159. - name: Install pip
  160. run: |
  161. pip install --no-cache-dir --upgrade "pip>=20.0.2"
  162. # pip cache
  163. - name: Get pip cache dir
  164. id: pip-cache
  165. run: |
  166. echo "::set-output name=dir::$(pip cache dir)"
  167. - name: pip cache
  168. uses: actions/cache@v1
  169. with:
  170. path: ${{ steps.pip-cache.outputs.dir }}
  171. key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-*.txt') }}
  172. restore-keys: |
  173. ${{ runner.os }}-pip-
  174. - name: Install Javascript Dependencies
  175. run: |
  176. yarn install --frozen-lockfile
  177. - name: Install Python Dependencies
  178. env:
  179. PGPASSWORD: postgres
  180. run: |
  181. python setup.py install_egg_info
  182. pip install wheel # GitHub Actions does not have this installed by default (unlike Travis)
  183. pip install -U -e ".[dev]"
  184. - name: Start devservices
  185. run: |
  186. sentry init
  187. sentry devservices up postgres redis clickhouse snuba
  188. - name: webpack
  189. run: |
  190. yarn webpack --display errors-only
  191. # Setup custom pytest matcher, see https://github.com/actions/setup-node/issues/97
  192. - name: Add pytest log matcher
  193. if: always()
  194. run: |
  195. echo "::remove-matcher owner=pytest::"
  196. echo "::add-matcher::.github/pytest.json"
  197. - name: Run acceptance tests (#${{ steps.config.outputs.matrix-instance-number }} of ${{ strategy.job-total }})
  198. if: always()
  199. run: |
  200. mkdir -p ${{ steps.config.outputs.acceptance-dir }}
  201. mkdir -p ${{ steps.config.outputs.acceptance-dir }}-mobile
  202. mkdir -p ${{ steps.config.outputs.acceptance-dir }}-tooltips
  203. [ "$GITHUB_REF" = "refs/heads/master" ] && export PYTEST_SENTRY_ALWAYS_REPORT=1
  204. make run-acceptance
  205. env:
  206. PYTEST_SNAPSHOTS_DIR: ${{ steps.config.outputs.acceptance-dir }}
  207. USE_SNUBA: 1
  208. TEST_GROUP: ${{ matrix.instance }}
  209. - name: Save snapshots
  210. if: always()
  211. uses: getsentry/action-visual-snapshot@v2
  212. with:
  213. save-only: true
  214. snapshot-path: .artifacts/visual-snapshots
  215. visual-diff:
  216. if: ${{ github.ref != 'refs/heads/master' }}
  217. needs: [acceptance, jest]
  218. runs-on: ubuntu-16.04
  219. steps:
  220. - name: Diff snapshots
  221. id: visual-snapshots-diff
  222. uses: getsentry/action-visual-snapshot@v2
  223. with:
  224. api-token: ${{ secrets.VISUAL_SNAPSHOT_SECRET }}
  225. github-token: ${{ secrets.GITHUB_TOKEN }}
  226. gcs-bucket: 'sentry-visual-snapshots'
  227. gcp-service-account-key: ${{ secrets.SNAPSHOT_GOOGLE_SERVICE_ACCOUNT_KEY }}