2020-06-08 20:34:39 +02:00
|
|
|
name: E2E
|
|
|
|
|
2020-08-18 11:08:40 +02:00
|
|
|
on:
|
|
|
|
- pull_request
|
2020-06-08 20:34:39 +02:00
|
|
|
|
2020-05-19 20:48:10 +02:00
|
|
|
jobs:
|
2020-08-18 11:08:40 +02:00
|
|
|
cypress:
|
|
|
|
name: Cypress tests
|
2020-06-06 19:13:09 +02:00
|
|
|
runs-on: ubuntu-18.04
|
2020-06-09 13:20:31 +02:00
|
|
|
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 3 copies of the current job in parallel
|
|
|
|
containers: [1, 2, 3, 4]
|
2020-06-06 19:13:09 +02:00
|
|
|
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.7
|
|
|
|
uses: actions/setup-python@v1
|
|
|
|
with:
|
|
|
|
python-version: 3.7
|
|
|
|
- uses: actions/cache@v1
|
|
|
|
name: Cache pip dependencies
|
|
|
|
id: pip-cache
|
|
|
|
with:
|
|
|
|
path: ~/.cache/pip
|
|
|
|
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-pip-
|
|
|
|
- name: Install python dependencies
|
|
|
|
run: |
|
|
|
|
python -m pip install --upgrade pip
|
|
|
|
python -m pip install $(grep -ivE "psycopg2" requirements.txt) --no-cache-dir --compile
|
|
|
|
python -m pip install psycopg2-binary --no-cache-dir --compile
|
|
|
|
- uses: actions/setup-node@v1
|
|
|
|
with:
|
|
|
|
node-version: 12
|
|
|
|
- name: Get yarn cache directory path
|
|
|
|
id: yarn-dep-cache-dir-path
|
|
|
|
run: echo "::set-output name=dir::$(yarn cache dir)"
|
|
|
|
- uses: actions/cache@v1
|
|
|
|
name: Setup Yarn dep cache
|
|
|
|
id: yarn-dep-cache
|
|
|
|
with:
|
|
|
|
path: ${{ steps.yarn-dep-cache-dir-path.outputs.dir }}
|
2020-06-11 00:05:01 +02:00
|
|
|
key: ${{ runner.os }}-yarn-dep-${{ hashFiles('**/yarn.lock') }}
|
2020-06-06 19:13:09 +02:00
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-yarn-dep-
|
|
|
|
- name: Yarn install deps
|
|
|
|
run: |
|
|
|
|
yarn install --frozen-lockfile
|
|
|
|
- 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
|
|
|
|
run: |
|
|
|
|
yarn build
|
|
|
|
if: steps.yarn-build-cache.outputs.cache-hit != 'true'
|
|
|
|
- name: Boot PostHog
|
|
|
|
env:
|
2020-08-14 22:18:21 +02:00
|
|
|
SECRET_KEY: '6b01eee4f945ca25045b5aab440b953461faf08693a9abbf1166dc7c6b9772da' # unsafe - for testing only
|
2020-06-06 19:13:09 +02:00
|
|
|
REDIS_URL: 'redis://localhost'
|
|
|
|
DATABASE_URL: 'postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres'
|
|
|
|
DISABLE_SECURE_SSL_REDIRECT: 1
|
2020-08-11 10:52:43 +02:00
|
|
|
SECURE_COOKIES: 0
|
2020-06-06 19:13:09 +02:00
|
|
|
OPT_OUT_CAPTURE: 1
|
|
|
|
run: |
|
|
|
|
python manage.py collectstatic --noinput
|
|
|
|
mkdir -p cypress/screenshots
|
|
|
|
./bin/docker-migrate
|
|
|
|
./bin/docker-worker &
|
|
|
|
./bin/docker-server &
|
|
|
|
- name: Cypress run
|
|
|
|
uses: cypress-io/github-action@v1
|
|
|
|
with:
|
|
|
|
config-file: cypress.json
|
2020-06-09 13:20:31 +02:00
|
|
|
record: true
|
|
|
|
parallel: true
|
|
|
|
group: 'PostHog Frontend'
|
|
|
|
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 }}
|
2020-06-06 19:13:09 +02:00
|
|
|
- name: Archive test screenshots
|
|
|
|
uses: actions/upload-artifact@v1
|
|
|
|
with:
|
|
|
|
name: screenshots
|
|
|
|
path: cypress/screenshots
|
|
|
|
if: ${{ failure() }}
|