acceptance.yml 8.7 KB

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