123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- # TODO(billy): this workflow has not been re-named from `acceptance` because
- # Visual Snapshots compares against artifacts from the same workflow name (on main branch)
- # We should rename this when we have a more finalized naming scheme.
- #
- # Also note that this name *MUST* match the filename because GHA
- # only provides the workflow name (https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables#default-environment-variables)
- # and GH APIs only support querying by workflow *FILENAME* (https://developer.github.com/v3/actions/workflows/#get-a-workflow)
- name: acceptance
- on:
- push:
- branches:
- - master
- - releases/**
- pull_request:
- jobs:
- files-changed:
- name: detect what files changed
- runs-on: ubuntu-20.04
- timeout-minutes: 3
- # Map a step output to a job output
- outputs:
- acceptance: ${{ steps.changes.outputs.acceptance }}
- backend: ${{ steps.changes.outputs.backend }}
- steps:
- - uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # v2
- - name: Check for backend file changes
- uses: getsentry/paths-filter@66f7f1844185eb7fb6738ea4ea59d74bb99199e5 # v2
- id: changes
- with:
- token: ${{ github.token }}
- filters: .github/file-filters.yml
- frontend:
- if: needs.files-changed.outputs.acceptance == 'true'
- needs: files-changed
- name: frontend tests
- runs-on: ubuntu-20.04
- timeout-minutes: 20
- strategy:
- # This helps not having to run multiple jobs because one fails, thus, reducing resource usage
- # and reducing the risk that one of many runs would turn red again (read: intermittent tests)
- fail-fast: false
- matrix:
- # XXX: When updating this, make sure you also update CI_NODE_TOTAL.
- instance: [0, 1, 2, 3]
- env:
- VISUAL_HTML_ENABLE: 1
- steps:
- - uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # v2
- name: Checkout sentry
- with:
- # Avoid codecov error message related to SHA resolution:
- # https://github.com/codecov/codecov-bash/blob/7100762afbc822b91806a6574658129fe0d23a7d/codecov#L891
- fetch-depth: '2'
- - uses: ./.github/actions/setup-volta
- - name: Install dependencies
- run: yarn install --frozen-lockfile
- - name: Build CSS
- run: NODE_ENV=production yarn build-css
- - name: jest
- env:
- GITHUB_PR_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
- GITHUB_PR_REF: ${{ github.event.pull_request.head.ref || github.ref }}
- # XXX: CI_NODE_TOTAL must be hardcoded to the length of strategy.matrix.instance.
- # Otherwise, if there are other things in the matrix, using strategy.job-total
- # wouldn't be correct.
- CI_NODE_TOTAL: 4
- CI_NODE_INDEX: ${{ matrix.instance }}
- run: |
- JEST_TESTS=$(yarn -s jest --listTests --json) yarn test-ci --forceExit
- - name: Save HTML artifacts
- uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2 # v2
- with:
- retention-days: 14
- name: jest-html
- path: .artifacts/visual-snapshots/jest
- - name: Create Images from HTML
- uses: getsentry/action-html-to-image@dc153dae538e6e1138f77156d8e62e3b2b897f41 # main
- with:
- base-path: .artifacts/visual-snapshots/jest
- css-path: src/sentry/static/sentry/dist/entrypoints/sentry.css
- - name: Save snapshots
- uses: getsentry/action-visual-snapshot@e832d70549c14886ddc2ab809b436ba72e30e19b # main
- with:
- save-only: true
- snapshot-path: .artifacts/visual-snapshots
- - name: Handle artifacts
- uses: ./.github/actions/artifacts
- with:
- files: .artifacts/coverage/*
- type: frontend
- acceptance:
- if: needs.files-changed.outputs.acceptance == 'true'
- needs: files-changed
- name: acceptance
- runs-on: ubuntu-20.04
- timeout-minutes: 25
- strategy:
- # This helps not having to run multiple jobs because one fails, thus, reducing resource usage
- # and reducing the risk that one of many runs would turn red again (read: intermittent tests)
- fail-fast: false
- matrix:
- # XXX: When updating this, make sure you also update MATRIX_INSTANCE_TOTAL.
- instance: [0, 1, 2, 3]
- pg-version: ['9.6']
- env:
- # XXX: MATRIX_INSTANCE_TOTAL must be hardcoded to the length of strategy.matrix.instance.
- MATRIX_INSTANCE_TOTAL: 4
- VISUAL_SNAPSHOT_ENABLE: 1
- TEST_GROUP_STRATEGY: roundrobin
- steps:
- - uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # v2
- name: Checkout sentry
- - uses: ./.github/actions/setup-volta
- - name: Step configurations
- id: config
- run: echo "::set-output name=webpack-path::.webpack_cache"
- - name: webpack cache
- uses: actions/cache@0865c47f36e68161719c5b124609996bb5c40129 # v3
- with:
- path: ${{ steps.config.outputs.webpack-path }}
- key: ${{ runner.os }}-v2-webpack-cache-${{ hashFiles('webpack.config.ts') }}
- - name: Install Javascript Dependencies
- run: |
- yarn install --frozen-lockfile
- - name: webpack
- env:
- WEBPACK_CACHE_PATH: ${{ steps.config.outputs.webpack-path }}
- SENTRY_INSTRUMENTATION: 1
- # this is fine to not have for forks, it shouldn't fail
- SENTRY_WEBPACK_WEBHOOK_SECRET: ${{ secrets.SENTRY_WEBPACK_WEBHOOK_SECRET }}
- run: |
- yarn build-acceptance
- - name: Setup sentry env
- uses: ./.github/actions/setup-sentry
- id: setup
- with:
- snuba: true
- pg-version: ${{ matrix.pg-version }}
- - name: Run acceptance tests (#${{ steps.setup.outputs.matrix-instance-number }} of ${{ steps.setup.outputs.matrix-instance-total }})
- run: |
- mkdir -p ${{ steps.setup.outputs.acceptance-dir }}
- mkdir -p ${{ steps.setup.outputs.acceptance-dir }}-mobile
- mkdir -p ${{ steps.setup.outputs.acceptance-dir }}-tooltips
- make run-acceptance
- env:
- PYTEST_SNAPSHOTS_DIR: ${{ steps.setup.outputs.acceptance-dir }}
- USE_SNUBA: 1
- - name: Save snapshots
- uses: getsentry/action-visual-snapshot@e832d70549c14886ddc2ab809b436ba72e30e19b # main
- with:
- save-only: true
- snapshot-path: .artifacts/visual-snapshots
- - name: Handle artifacts
- uses: ./.github/actions/artifacts
- if: needs.files-changed.outputs.backend == 'true'
- chartcuterie:
- if: needs.files-changed.outputs.acceptance == 'true'
- needs: files-changed
- name: chartcuterie integration
- runs-on: ubuntu-20.04
- timeout-minutes: 30
- strategy:
- # This helps not having to run multiple jobs because one fails, thus, reducing resource usage
- # and reducing the risk that one of many runs would turn red again (read: intermittent tests)
- fail-fast: false
- matrix:
- # XXX: When updating this, make sure you also update MATRIX_INSTANCE_TOTAL.
- instance: [0]
- env:
- # XXX: MATRIX_INSTANCE_TOTAL must be hardcoded to the length of strategy.matrix.instance.
- MATRIX_INSTANCE_TOTAL: 1
- TEST_GROUP_STRATEGY: roundrobin
- VISUAL_SNAPSHOT_ENABLE: 1
- steps:
- - uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # v2
- with:
- # Avoid codecov error message related to SHA resolution:
- # https://github.com/codecov/codecov-bash/blob/7100762afbc822b91806a6574658129fe0d23a7d/codecov#L891
- fetch-depth: '2'
- - name: Setup sentry env
- uses: ./.github/actions/setup-sentry
- id: setup
- with:
- chartcuterie: true
- - name: yarn cache
- uses: actions/cache@0865c47f36e68161719c5b124609996bb5c40129 # v3
- with:
- path: ${{ steps.setup.outputs.yarn-cache-dir }}
- key: ${{ runner.os }}-v2-yarn-${{ hashFiles('yarn.lock', 'api-docs/yarn.lock') }}
- - name: Install Javascript Dependencies
- run: |
- yarn install --frozen-lockfile
- - name: Build chartcuterie configuration module
- run: |
- make build-chartcuterie-config
- - name: Run chartcuterie tests (${{ steps.setup.outputs.matrix-instance-number }} of ${{ steps.setup.outputs.matrix-instance-total }})
- run: |
- mkdir -p ${{ steps.setup.outputs.acceptance-dir }}
- make test-chartcuterie
- env:
- PYTEST_SNAPSHOTS_DIR: ${{ steps.setup.outputs.acceptance-dir }}
- - name: Save snapshots
- uses: getsentry/action-visual-snapshot@e832d70549c14886ddc2ab809b436ba72e30e19b # main
- with:
- save-only: true
- snapshot-path: .artifacts/visual-snapshots
- - name: Handle artifacts
- uses: ./.github/actions/artifacts
- if: needs.files-changed.outputs.backend == 'true'
- visual-diff:
- if: always()
- # This guarantees that we will only schedule Visual Snapshots if all
- # workflows that generate artifacts succeed
- needs: [acceptance, frontend, chartcuterie, files-changed]
- name: triggers visual snapshot
- runs-on: ubuntu-20.04
- timeout-minutes: 20
- steps:
- # If any jobs we depend on fail, we will fail since this checks triggers Visual Snapshots which is a required check
- # NOTE: A timeout is considered a failure
- - name: Check for failures
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
- run: |
- echo "One of the dependent jobs have failed. You may need to re-run it." && exit 1
- - name: Diff snapshots
- uses: getsentry/action-visual-snapshot@e832d70549c14886ddc2ab809b436ba72e30e19b # main
- # Run this step only if there are acceptance related code changes
- # Forks are handled in visual-diff.yml
- if: needs.files-changed.outputs.acceptance == 'true' && github.event.pull_request.head.repo.full_name == 'getsentry/sentry'
- with:
- api-token: ${{ secrets.VISUAL_SNAPSHOT_SECRET }}
- gcs-bucket: 'sentry-visual-snapshots'
- gcp-service-account-key: ${{ secrets.SNAPSHOT_GOOGLE_SERVICE_ACCOUNT_KEY }}
- # Since Visual Snapshot is a required check we need to pretend to have run
- fake-visual-snapshot:
- name: Visual Snapshot
- needs: [files-changed]
- # Opposite condition to "triggers visual snapshot" required check
- if: needs.files-changed.outputs.acceptance != 'true'
- runs-on: ubuntu-20.04
- steps:
- - name: Sentaur attack
- run: |
- echo "This check pretends to be the Visual Snapshot to satisfy Github required checks"
|