mirror of
https://github.com/PostHog/posthog.git
synced 2024-12-01 04:12:23 +01:00
4aa773139c
* Send info on insights query timing + route to posthog This will help with determining the root cause of our problems * Capture information on "timeouts" correctly previously every error on insights was reported as a timeout. * WIP * Solve typing issues within insightslogic * WIP part 2 * Add graphs for insight load times * Add tests for new routes * PR review iteration * Make instance_status POST available for all * Do some cache busting
144 lines
6.2 KiB
YAML
144 lines
6.2 KiB
YAML
name: E2E
|
|
|
|
on:
|
|
- pull_request
|
|
|
|
jobs:
|
|
cypress:
|
|
name: Cypress E2E tests
|
|
runs-on: ubuntu-18.04
|
|
if: ${{ github.actor != 'posthog-contributions-bot[bot]' }}
|
|
|
|
strategy:
|
|
# when one test fails, DO NOT cancel the other
|
|
# containers, because this will kill Cypress processes
|
|
# leaving the Dashboard hanging ...
|
|
# https://github.com/cypress-io/github-action/issues/48
|
|
fail-fast: false
|
|
matrix:
|
|
# run 7 copies of the current job in parallel
|
|
containers: [1, 2, 3, 4, 5, 6, 7]
|
|
services:
|
|
postgres:
|
|
image: postgres:12
|
|
env:
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: postgres
|
|
POSTGRES_DB: postgres
|
|
ports:
|
|
# Maps port 5432 on service container to the host
|
|
# Needed because `postgres` host is not discoverable for some reason
|
|
- 5432:5432
|
|
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
|
redis:
|
|
image: redis
|
|
ports:
|
|
# Maps port 6379 on service container to the host
|
|
# Needed because `redis` host is not discoverable for some reason
|
|
- 6379:6379
|
|
options: >-
|
|
--health-cmd "redis-cli ping"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v1
|
|
- name: Set up Python 3.8
|
|
uses: actions/setup-python@v2
|
|
with:
|
|
python-version: 3.8
|
|
- uses: syphar/restore-virtualenv@v1
|
|
id: cache-virtualenv
|
|
with:
|
|
requirement_files: requirements.txt # this is optional
|
|
- uses: syphar/restore-pip-download-cache@v1
|
|
if: steps.cache-virtualenv.outputs.cache-hit != 'true'
|
|
- name: Install python dependencies
|
|
if: steps.cache-virtualenv.outputs.cache-hit != 'true'
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
python -m pip install $(grep -ivE "psycopg2" requirements.txt | cut -d'#' -f1) --no-cache-dir --compile
|
|
python -m pip install psycopg2-binary --no-cache-dir --compile
|
|
- uses: actions/setup-node@v1
|
|
with:
|
|
node-version: 14
|
|
- uses: actions/cache@v2
|
|
id: cypress-node-modules-cache
|
|
with:
|
|
path: |
|
|
**/node_modules
|
|
key: ${{ runner.os }}-cypress-node-modules-${{ hashFiles('**/yarn.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cypress-node-modules
|
|
- name: Yarn install deps
|
|
if: steps.cypress-node-modules-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
yarn install --frozen-lockfile
|
|
- uses: actions/cache@v2
|
|
id: cypress-cache
|
|
with:
|
|
path: |
|
|
~/.cache/Cypress
|
|
**/node_modules/cypress
|
|
**/node_modules/cypress-terminal-report
|
|
**/node_modules/@cypress
|
|
key: ${{ runner.os }}-cypress-6.7.0-v1
|
|
- name: Install cypress
|
|
if: steps.cypress-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
yarn add cypress@6.7.0 cypress-terminal-report@2.1.0 @cypress/react@4.16.4 @cypress/webpack-preprocessor@5.7.0
|
|
- uses: actions/cache@v1
|
|
name: Setup Yarn build cache
|
|
id: yarn-build-cache
|
|
with:
|
|
path: frontend/dist
|
|
key: ${{ runner.os }}-yarn-build-${{ hashFiles('frontend/src/') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-yarn-build-
|
|
- name: Yarn build
|
|
if: steps.yarn-build-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
yarn build
|
|
- name: Boot PostHog
|
|
env:
|
|
SECRET_KEY: '6b01eee4f945ca25045b5aab440b953461faf08693a9abbf1166dc7c6b9772da' # unsafe - for testing only
|
|
REDIS_URL: 'redis://localhost'
|
|
DATABASE_URL: 'postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres'
|
|
DISABLE_SECURE_SSL_REDIRECT: 1
|
|
SECURE_COOKIES: 0
|
|
OPT_OUT_CAPTURE: 1
|
|
SELF_CAPTURE: 0
|
|
E2E_TESTING: 1
|
|
run: |
|
|
python manage.py collectstatic --noinput &
|
|
./bin/docker-migrate & wait
|
|
python manage.py setup_dev
|
|
mkdir -p cypress/screenshots
|
|
./bin/docker-worker &
|
|
./bin/docker-server &
|
|
- name: Cypress run
|
|
uses: cypress-io/github-action@v2
|
|
with:
|
|
config-file: cypress.e2e.json
|
|
record: true
|
|
parallel: true
|
|
group: 'PostHog Frontend'
|
|
# We're already installing cypress above
|
|
# We have to install it separately otherwise the tests fail.
|
|
install: false
|
|
# We already install cypress separately, we don't need to install it again here
|
|
install-command: echo "no"
|
|
env:
|
|
# pass the Dashboard record key as an environment variable
|
|
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
|
# Recommended: pass the GitHub token lets this action correctly
|
|
# determine the unique run id necessary to re-run the checks
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Archive test screenshots
|
|
uses: actions/upload-artifact@v1
|
|
with:
|
|
name: screenshots
|
|
path: cypress/screenshots
|
|
if: ${{ failure() }}
|