acceptance.yml 7.0 KB

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