0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 04:12:23 +01:00
posthog/.github/workflows/ci-e2e.yml

251 lines
9.9 KiB
YAML
Raw Normal View History

#
# This workflow runs CI E2E tests with Cypress.
#
# It relies on the container image built by 'container-images-ci.yml'.
#
name: E2E CI
on:
chore(dockerfile): make docker build multistage (#10488) * chore(dockerfile): make docker build multistage The built image is >4GB uncompressed atm, I'm pretty sure there is a lot of cruft. Plan is to split out the django, frontend, plugin-server builds and hopefully get some gains in there to not include build deps. * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix dockerfile lints * cache from branch * add load :true * Update production.Dockerfile Co-authored-by: James Greenhill <fuziontech@gmail.com> * Update production.Dockerfile * update to use compressed size from remote repo * tag with branch and sha * add ref on pull_request events * install python * be a bit more lax with python version * fix image size calc * hardcode lower case image name * use @ * only add sha on master branch, add master tag on master * chore: use docker image in e2e tests This is to try to add some guarantees to the docker image without having to manually test it, so we can be a bit more aggressive with improvements without, e.g. having to push to the playground or run locally. * wip * add to summary * wip * chore: put cypress tests after docker build I couldn't figure out a way to get workflow_run to run without merging in, so I'm just putting after the build. * wip * wip * wip * remove quotes * remove separate cypress install * wip * wip * wip * add gunicorn.config.py * ci: run docker image build on master as well This way we get the caching from the master build. * wip * wip Co-authored-by: James Greenhill <fuziontech@gmail.com>
2022-06-27 19:12:32 +02:00
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
changes:
runs-on: ubuntu-latest
timeout-minutes: 5
if: github.repository == 'PostHog/posthog'
name: Determine need to run E2E checks
steps:
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
shouldTriggerCypress:
# Avoid running E2E tests for irrelevant changes
# NOTE: we are at risk of missing a dependency here. We could make
# the dependencies more clear if we separated the backend/frontend
# code completely
- 'ee/**/*'
- 'posthog/**/*'
- 'bin/*.py'
- requirements.txt
- requirements-dev.txt
- mypy.ini
- pytest.ini
# Make sure we run if someone is explicitly change the workflow
- .github/workflows/ci-e2e.yml
# We use docker compose for tests, make sure we rerun on
# changes to docker-compose.dev.yml e.g. dependency
# version changes
- docker-compose.dev.yml
- frontend/**/*
chore(dockerfile): make docker build multistage (#10488) * chore(dockerfile): make docker build multistage The built image is >4GB uncompressed atm, I'm pretty sure there is a lot of cruft. Plan is to split out the django, frontend, plugin-server builds and hopefully get some gains in there to not include build deps. * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix dockerfile lints * cache from branch * add load :true * Update production.Dockerfile Co-authored-by: James Greenhill <fuziontech@gmail.com> * Update production.Dockerfile * update to use compressed size from remote repo * tag with branch and sha * add ref on pull_request events * install python * be a bit more lax with python version * fix image size calc * hardcode lower case image name * use @ * only add sha on master branch, add master tag on master * chore: use docker image in e2e tests This is to try to add some guarantees to the docker image without having to manually test it, so we can be a bit more aggressive with improvements without, e.g. having to push to the playground or run locally. * wip * add to summary * wip * chore: put cypress tests after docker build I couldn't figure out a way to get workflow_run to run without merging in, so I'm just putting after the build. * wip * wip * wip * remove quotes * remove separate cypress install * wip * wip * wip * add gunicorn.config.py * ci: run docker image build on master as well This way we get the caching from the master build. * wip * wip Co-authored-by: James Greenhill <fuziontech@gmail.com>
2022-06-27 19:12:32 +02:00
# Job that lists and chunks spec file names and caches node modules
cypress_prep:
needs: changes
name: Cypress preparation
runs-on: ubuntu-latest
chore(dockerfile): make docker build multistage (#10488) * chore(dockerfile): make docker build multistage The built image is >4GB uncompressed atm, I'm pretty sure there is a lot of cruft. Plan is to split out the django, frontend, plugin-server builds and hopefully get some gains in there to not include build deps. * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix dockerfile lints * cache from branch * add load :true * Update production.Dockerfile Co-authored-by: James Greenhill <fuziontech@gmail.com> * Update production.Dockerfile * update to use compressed size from remote repo * tag with branch and sha * add ref on pull_request events * install python * be a bit more lax with python version * fix image size calc * hardcode lower case image name * use @ * only add sha on master branch, add master tag on master * chore: use docker image in e2e tests This is to try to add some guarantees to the docker image without having to manually test it, so we can be a bit more aggressive with improvements without, e.g. having to push to the playground or run locally. * wip * add to summary * wip * chore: put cypress tests after docker build I couldn't figure out a way to get workflow_run to run without merging in, so I'm just putting after the build. * wip * wip * wip * remove quotes * remove separate cypress install * wip * wip * wip * add gunicorn.config.py * ci: run docker image build on master as well This way we get the caching from the master build. * wip * wip Co-authored-by: James Greenhill <fuziontech@gmail.com>
2022-06-27 19:12:32 +02:00
timeout-minutes: 30
outputs:
specs: ${{ steps.set-specs.outputs.specs }}
steps:
- name: Wait for the container image to be ready
# these are required checks so, we can't skip entire sections
if: needs.changes.outputs.shouldTriggerCypress == 'true'
uses: lewagon/wait-on-check-action@v1.2.0
with:
check-name: Build PostHog
ref: ${{ github.event.pull_request.head.sha }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
- name: Checkout code
uses: actions/checkout@v3
- name: List cypress/e2e and produce a JSON array of the files, in chunks
id: set-specs
run: echo "specs=$(ls cypress/e2e/* | jq --slurp --raw-input -c 'split("\n")[:-1] | _nwise(3) | join("\n")' | jq --slurp -c .)" >> $GITHUB_OUTPUT
chore(dockerfile): make docker build multistage (#10488) * chore(dockerfile): make docker build multistage The built image is >4GB uncompressed atm, I'm pretty sure there is a lot of cruft. Plan is to split out the django, frontend, plugin-server builds and hopefully get some gains in there to not include build deps. * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix dockerfile lints * cache from branch * add load :true * Update production.Dockerfile Co-authored-by: James Greenhill <fuziontech@gmail.com> * Update production.Dockerfile * update to use compressed size from remote repo * tag with branch and sha * add ref on pull_request events * install python * be a bit more lax with python version * fix image size calc * hardcode lower case image name * use @ * only add sha on master branch, add master tag on master * chore: use docker image in e2e tests This is to try to add some guarantees to the docker image without having to manually test it, so we can be a bit more aggressive with improvements without, e.g. having to push to the playground or run locally. * wip * add to summary * wip * chore: put cypress tests after docker build I couldn't figure out a way to get workflow_run to run without merging in, so I'm just putting after the build. * wip * wip * wip * remove quotes * remove separate cypress install * wip * wip * wip * add gunicorn.config.py * ci: run docker image build on master as well This way we get the caching from the master build. * wip * wip Co-authored-by: James Greenhill <fuziontech@gmail.com>
2022-06-27 19:12:32 +02:00
cypress:
name: Cypress E2E tests (${{ strategy.job-index }})
runs-on: ubuntu-latest
chore(dockerfile): make docker build multistage (#10488) * chore(dockerfile): make docker build multistage The built image is >4GB uncompressed atm, I'm pretty sure there is a lot of cruft. Plan is to split out the django, frontend, plugin-server builds and hopefully get some gains in there to not include build deps. * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix dockerfile lints * cache from branch * add load :true * Update production.Dockerfile Co-authored-by: James Greenhill <fuziontech@gmail.com> * Update production.Dockerfile * update to use compressed size from remote repo * tag with branch and sha * add ref on pull_request events * install python * be a bit more lax with python version * fix image size calc * hardcode lower case image name * use @ * only add sha on master branch, add master tag on master * chore: use docker image in e2e tests This is to try to add some guarantees to the docker image without having to manually test it, so we can be a bit more aggressive with improvements without, e.g. having to push to the playground or run locally. * wip * add to summary * wip * chore: put cypress tests after docker build I couldn't figure out a way to get workflow_run to run without merging in, so I'm just putting after the build. * wip * wip * wip * remove quotes * remove separate cypress install * wip * wip * wip * add gunicorn.config.py * ci: run docker image build on master as well This way we get the caching from the master build. * wip * wip Co-authored-by: James Greenhill <fuziontech@gmail.com>
2022-06-27 19:12:32 +02:00
timeout-minutes: 30
needs: [cypress_prep, changes]
permissions:
packages: read # allow pull from ghcr.io
chore(dockerfile): make docker build multistage (#10488) * chore(dockerfile): make docker build multistage The built image is >4GB uncompressed atm, I'm pretty sure there is a lot of cruft. Plan is to split out the django, frontend, plugin-server builds and hopefully get some gains in there to not include build deps. * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix dockerfile lints * cache from branch * add load :true * Update production.Dockerfile Co-authored-by: James Greenhill <fuziontech@gmail.com> * Update production.Dockerfile * update to use compressed size from remote repo * tag with branch and sha * add ref on pull_request events * install python * be a bit more lax with python version * fix image size calc * hardcode lower case image name * use @ * only add sha on master branch, add master tag on master * chore: use docker image in e2e tests This is to try to add some guarantees to the docker image without having to manually test it, so we can be a bit more aggressive with improvements without, e.g. having to push to the playground or run locally. * wip * add to summary * wip * chore: put cypress tests after docker build I couldn't figure out a way to get workflow_run to run without merging in, so I'm just putting after the build. * wip * wip * wip * remove quotes * remove separate cypress install * wip * wip * wip * add gunicorn.config.py * ci: run docker image build on master as well This way we get the caching from the master build. * wip * wip Co-authored-by: James Greenhill <fuziontech@gmail.com>
2022-06-27 19:12:32 +02:00
strategy:
# when one test fails, DO NOT cancel the other
# containers, as there may be other spec failures
# we want to know about.
fail-fast: false
matrix:
specs: ${{ fromJson(needs.cypress_prep.outputs.specs) }}
steps:
- name: Checkout
if: needs.changes.outputs.shouldTriggerCypress == 'true'
uses: actions/checkout@v3
chore(dockerfile): make docker build multistage (#10488) * chore(dockerfile): make docker build multistage The built image is >4GB uncompressed atm, I'm pretty sure there is a lot of cruft. Plan is to split out the django, frontend, plugin-server builds and hopefully get some gains in there to not include build deps. * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix dockerfile lints * cache from branch * add load :true * Update production.Dockerfile Co-authored-by: James Greenhill <fuziontech@gmail.com> * Update production.Dockerfile * update to use compressed size from remote repo * tag with branch and sha * add ref on pull_request events * install python * be a bit more lax with python version * fix image size calc * hardcode lower case image name * use @ * only add sha on master branch, add master tag on master * chore: use docker image in e2e tests This is to try to add some guarantees to the docker image without having to manually test it, so we can be a bit more aggressive with improvements without, e.g. having to push to the playground or run locally. * wip * add to summary * wip * chore: put cypress tests after docker build I couldn't figure out a way to get workflow_run to run without merging in, so I'm just putting after the build. * wip * wip * wip * remove quotes * remove separate cypress install * wip * wip * wip * add gunicorn.config.py * ci: run docker image build on master as well This way we get the caching from the master build. * wip * wip Co-authored-by: James Greenhill <fuziontech@gmail.com>
2022-06-27 19:12:32 +02:00
chore: use pnpm to manage dependencies (closes #12635) (#13190) * chore: use pnpm to manage dependencies * Fix CI errors * Don't report Docker image size for external PRs * Fix pnpm-lock.yaml formatting * Fix module versions * Ignore pnpm-lock.yaml * Upgrade Cypress action for pnpm support * Set up node and pnpm before Cypress * Fix typescript issues * Include patches directory in Dockerfile * Fix Jest tests in CI * Update lockfile * Update lockfile * Clean up Dockerfile * Update pnpm-lock.yaml to reflect current package.json files * remove yarn-error.log from .gitignore * formatting * update data exploration readme * type jest.config.ts * fix @react-hook issues for jest * fix react-syntax-highlighter issues for jest * fix jest issues from query-selector-shadow-dom * fix transform ignore patterns and undo previous fixes * add missing storybook peer dependencies * fix nullish coalescing operator for storybook * reorder storybook plugins * update editor-update-tsd warning to new npm script * use legacy ssl for chromatic / node 18 compatibility * use pnpm for visual regression testing workflow * use node 16 for chromatic * add @babel/plugin-proposal-nullish-coalescing-operator as direct dependency * try fix for plugin-server * cleanup * fix comment and warning * update more comments * update playwright dockerfile * update plugin source types * conditional image size reporting * revert react-native instructions * less restrictive pnpm verions * use ref component name in line with style guide Co-authored-by: Jacob Gillespie <jacobwgillespie@gmail.com>
2022-12-12 10:28:06 +01:00
- name: Install pnpm
if: needs.changes.outputs.shouldTriggerCypress == 'true'
chore: use pnpm to manage dependencies (closes #12635) (#13190) * chore: use pnpm to manage dependencies * Fix CI errors * Don't report Docker image size for external PRs * Fix pnpm-lock.yaml formatting * Fix module versions * Ignore pnpm-lock.yaml * Upgrade Cypress action for pnpm support * Set up node and pnpm before Cypress * Fix typescript issues * Include patches directory in Dockerfile * Fix Jest tests in CI * Update lockfile * Update lockfile * Clean up Dockerfile * Update pnpm-lock.yaml to reflect current package.json files * remove yarn-error.log from .gitignore * formatting * update data exploration readme * type jest.config.ts * fix @react-hook issues for jest * fix react-syntax-highlighter issues for jest * fix jest issues from query-selector-shadow-dom * fix transform ignore patterns and undo previous fixes * add missing storybook peer dependencies * fix nullish coalescing operator for storybook * reorder storybook plugins * update editor-update-tsd warning to new npm script * use legacy ssl for chromatic / node 18 compatibility * use pnpm for visual regression testing workflow * use node 16 for chromatic * add @babel/plugin-proposal-nullish-coalescing-operator as direct dependency * try fix for plugin-server * cleanup * fix comment and warning * update more comments * update playwright dockerfile * update plugin source types * conditional image size reporting * revert react-native instructions * less restrictive pnpm verions * use ref component name in line with style guide Co-authored-by: Jacob Gillespie <jacobwgillespie@gmail.com>
2022-12-12 10:28:06 +01:00
uses: pnpm/action-setup@v2
with:
2023-04-28 11:35:58 +02:00
version: 8.x.x
chore: use pnpm to manage dependencies (closes #12635) (#13190) * chore: use pnpm to manage dependencies * Fix CI errors * Don't report Docker image size for external PRs * Fix pnpm-lock.yaml formatting * Fix module versions * Ignore pnpm-lock.yaml * Upgrade Cypress action for pnpm support * Set up node and pnpm before Cypress * Fix typescript issues * Include patches directory in Dockerfile * Fix Jest tests in CI * Update lockfile * Update lockfile * Clean up Dockerfile * Update pnpm-lock.yaml to reflect current package.json files * remove yarn-error.log from .gitignore * formatting * update data exploration readme * type jest.config.ts * fix @react-hook issues for jest * fix react-syntax-highlighter issues for jest * fix jest issues from query-selector-shadow-dom * fix transform ignore patterns and undo previous fixes * add missing storybook peer dependencies * fix nullish coalescing operator for storybook * reorder storybook plugins * update editor-update-tsd warning to new npm script * use legacy ssl for chromatic / node 18 compatibility * use pnpm for visual regression testing workflow * use node 16 for chromatic * add @babel/plugin-proposal-nullish-coalescing-operator as direct dependency * try fix for plugin-server * cleanup * fix comment and warning * update more comments * update playwright dockerfile * update plugin source types * conditional image size reporting * revert react-native instructions * less restrictive pnpm verions * use ref component name in line with style guide Co-authored-by: Jacob Gillespie <jacobwgillespie@gmail.com>
2022-12-12 10:28:06 +01:00
- name: Set up Node.js
if: needs.changes.outputs.shouldTriggerCypress == 'true'
chore: use pnpm to manage dependencies (closes #12635) (#13190) * chore: use pnpm to manage dependencies * Fix CI errors * Don't report Docker image size for external PRs * Fix pnpm-lock.yaml formatting * Fix module versions * Ignore pnpm-lock.yaml * Upgrade Cypress action for pnpm support * Set up node and pnpm before Cypress * Fix typescript issues * Include patches directory in Dockerfile * Fix Jest tests in CI * Update lockfile * Update lockfile * Clean up Dockerfile * Update pnpm-lock.yaml to reflect current package.json files * remove yarn-error.log from .gitignore * formatting * update data exploration readme * type jest.config.ts * fix @react-hook issues for jest * fix react-syntax-highlighter issues for jest * fix jest issues from query-selector-shadow-dom * fix transform ignore patterns and undo previous fixes * add missing storybook peer dependencies * fix nullish coalescing operator for storybook * reorder storybook plugins * update editor-update-tsd warning to new npm script * use legacy ssl for chromatic / node 18 compatibility * use pnpm for visual regression testing workflow * use node 16 for chromatic * add @babel/plugin-proposal-nullish-coalescing-operator as direct dependency * try fix for plugin-server * cleanup * fix comment and warning * update more comments * update playwright dockerfile * update plugin source types * conditional image size reporting * revert react-native instructions * less restrictive pnpm verions * use ref component name in line with style guide Co-authored-by: Jacob Gillespie <jacobwgillespie@gmail.com>
2022-12-12 10:28:06 +01:00
uses: actions/setup-node@v3
with:
node-version: 18
- name: Get pnpm cache directory path
if: needs.changes.outputs.shouldTriggerCypress == 'true'
id: pnpm-cache-dir
run: echo "PNPM_STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Get cypress cache directory path
if: needs.changes.outputs.shouldTriggerCypress == 'true'
id: cypress-cache-dir
run: echo "CYPRESS_BIN_PATH=$(npx cypress cache path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
if: needs.changes.outputs.shouldTriggerCypress == 'true'
id: pnpm-cache
with:
path: |
${{ steps.pnpm-cache-dir.outputs.PNPM_STORE_PATH }}
${{ steps.cypress-cache-dir.outputs.CYPRESS_BIN_PATH }}
key: ${{ runner.os }}-pnpm-cypress-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-cypress-
chore: use pnpm to manage dependencies (closes #12635) (#13190) * chore: use pnpm to manage dependencies * Fix CI errors * Don't report Docker image size for external PRs * Fix pnpm-lock.yaml formatting * Fix module versions * Ignore pnpm-lock.yaml * Upgrade Cypress action for pnpm support * Set up node and pnpm before Cypress * Fix typescript issues * Include patches directory in Dockerfile * Fix Jest tests in CI * Update lockfile * Update lockfile * Clean up Dockerfile * Update pnpm-lock.yaml to reflect current package.json files * remove yarn-error.log from .gitignore * formatting * update data exploration readme * type jest.config.ts * fix @react-hook issues for jest * fix react-syntax-highlighter issues for jest * fix jest issues from query-selector-shadow-dom * fix transform ignore patterns and undo previous fixes * add missing storybook peer dependencies * fix nullish coalescing operator for storybook * reorder storybook plugins * update editor-update-tsd warning to new npm script * use legacy ssl for chromatic / node 18 compatibility * use pnpm for visual regression testing workflow * use node 16 for chromatic * add @babel/plugin-proposal-nullish-coalescing-operator as direct dependency * try fix for plugin-server * cleanup * fix comment and warning * update more comments * update playwright dockerfile * update plugin source types * conditional image size reporting * revert react-native instructions * less restrictive pnpm verions * use ref component name in line with style guide Co-authored-by: Jacob Gillespie <jacobwgillespie@gmail.com>
2022-12-12 10:28:06 +01:00
- name: Install package.json dependencies with pnpm
if: needs.changes.outputs.shouldTriggerCypress == 'true'
run: pnpm install --frozen-lockfile
- name: Stop/Start stack with Docker Compose
# these are required checks so, we can't skip entire sections
if: needs.changes.outputs.shouldTriggerCypress == 'true'
chore(dockerfile): make docker build multistage (#10488) * chore(dockerfile): make docker build multistage The built image is >4GB uncompressed atm, I'm pretty sure there is a lot of cruft. Plan is to split out the django, frontend, plugin-server builds and hopefully get some gains in there to not include build deps. * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix dockerfile lints * cache from branch * add load :true * Update production.Dockerfile Co-authored-by: James Greenhill <fuziontech@gmail.com> * Update production.Dockerfile * update to use compressed size from remote repo * tag with branch and sha * add ref on pull_request events * install python * be a bit more lax with python version * fix image size calc * hardcode lower case image name * use @ * only add sha on master branch, add master tag on master * chore: use docker image in e2e tests This is to try to add some guarantees to the docker image without having to manually test it, so we can be a bit more aggressive with improvements without, e.g. having to push to the playground or run locally. * wip * add to summary * wip * chore: put cypress tests after docker build I couldn't figure out a way to get workflow_run to run without merging in, so I'm just putting after the build. * wip * wip * wip * remove quotes * remove separate cypress install * wip * wip * wip * add gunicorn.config.py * ci: run docker image build on master as well This way we get the caching from the master build. * wip * wip Co-authored-by: James Greenhill <fuziontech@gmail.com>
2022-06-27 19:12:32 +02:00
run: |
docker compose -f docker-compose.dev.yml down
docker compose -f docker-compose.dev.yml up -d
chore(dockerfile): make docker build multistage (#10488) * chore(dockerfile): make docker build multistage The built image is >4GB uncompressed atm, I'm pretty sure there is a lot of cruft. Plan is to split out the django, frontend, plugin-server builds and hopefully get some gains in there to not include build deps. * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix dockerfile lints * cache from branch * add load :true * Update production.Dockerfile Co-authored-by: James Greenhill <fuziontech@gmail.com> * Update production.Dockerfile * update to use compressed size from remote repo * tag with branch and sha * add ref on pull_request events * install python * be a bit more lax with python version * fix image size calc * hardcode lower case image name * use @ * only add sha on master branch, add master tag on master * chore: use docker image in e2e tests This is to try to add some guarantees to the docker image without having to manually test it, so we can be a bit more aggressive with improvements without, e.g. having to push to the playground or run locally. * wip * add to summary * wip * chore: put cypress tests after docker build I couldn't figure out a way to get workflow_run to run without merging in, so I'm just putting after the build. * wip * wip * wip * remove quotes * remove separate cypress install * wip * wip * wip * add gunicorn.config.py * ci: run docker image build on master as well This way we get the caching from the master build. * wip * wip Co-authored-by: James Greenhill <fuziontech@gmail.com>
2022-06-27 19:12:32 +02:00
- name: Wait for ClickHouse
# these are required checks so, we can't skip entire sections
if: needs.changes.outputs.shouldTriggerCypress == 'true'
chore(dockerfile): make docker build multistage (#10488) * chore(dockerfile): make docker build multistage The built image is >4GB uncompressed atm, I'm pretty sure there is a lot of cruft. Plan is to split out the django, frontend, plugin-server builds and hopefully get some gains in there to not include build deps. * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix dockerfile lints * cache from branch * add load :true * Update production.Dockerfile Co-authored-by: James Greenhill <fuziontech@gmail.com> * Update production.Dockerfile * update to use compressed size from remote repo * tag with branch and sha * add ref on pull_request events * install python * be a bit more lax with python version * fix image size calc * hardcode lower case image name * use @ * only add sha on master branch, add master tag on master * chore: use docker image in e2e tests This is to try to add some guarantees to the docker image without having to manually test it, so we can be a bit more aggressive with improvements without, e.g. having to push to the playground or run locally. * wip * add to summary * wip * chore: put cypress tests after docker build I couldn't figure out a way to get workflow_run to run without merging in, so I'm just putting after the build. * wip * wip * wip * remove quotes * remove separate cypress install * wip * wip * wip * add gunicorn.config.py * ci: run docker image build on master as well This way we get the caching from the master build. * wip * wip Co-authored-by: James Greenhill <fuziontech@gmail.com>
2022-06-27 19:12:32 +02:00
run: ./bin/check_kafka_clickhouse_up
- name: Setup env
run: |
cat <<EOT >> .env
SECRET_KEY=6b01eee4f945ca25045b5aab440b953461faf08693a9abbf1166dc7c6b9772da
REDIS_URL=redis://localhost
DATABASE_URL=postgres://posthog:posthog@localhost:5432/posthog
KAFKA_URL=kafka://kafka:9092
chore(dockerfile): make docker build multistage (#10488) * chore(dockerfile): make docker build multistage The built image is >4GB uncompressed atm, I'm pretty sure there is a lot of cruft. Plan is to split out the django, frontend, plugin-server builds and hopefully get some gains in there to not include build deps. * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix dockerfile lints * cache from branch * add load :true * Update production.Dockerfile Co-authored-by: James Greenhill <fuziontech@gmail.com> * Update production.Dockerfile * update to use compressed size from remote repo * tag with branch and sha * add ref on pull_request events * install python * be a bit more lax with python version * fix image size calc * hardcode lower case image name * use @ * only add sha on master branch, add master tag on master * chore: use docker image in e2e tests This is to try to add some guarantees to the docker image without having to manually test it, so we can be a bit more aggressive with improvements without, e.g. having to push to the playground or run locally. * wip * add to summary * wip * chore: put cypress tests after docker build I couldn't figure out a way to get workflow_run to run without merging in, so I'm just putting after the build. * wip * wip * wip * remove quotes * remove separate cypress install * wip * wip * wip * add gunicorn.config.py * ci: run docker image build on master as well This way we get the caching from the master build. * wip * wip Co-authored-by: James Greenhill <fuziontech@gmail.com>
2022-06-27 19:12:32 +02:00
DISABLE_SECURE_SSL_REDIRECT=1
SECURE_COOKIES=0
OPT_OUT_CAPTURE=1
SELF_CAPTURE=0
E2E_TESTING=1
SKIP_SERVICE_VERSION_REQUIREMENTS=1
chore(dockerfile): make docker build multistage (#10488) * chore(dockerfile): make docker build multistage The built image is >4GB uncompressed atm, I'm pretty sure there is a lot of cruft. Plan is to split out the django, frontend, plugin-server builds and hopefully get some gains in there to not include build deps. * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix dockerfile lints * cache from branch * add load :true * Update production.Dockerfile Co-authored-by: James Greenhill <fuziontech@gmail.com> * Update production.Dockerfile * update to use compressed size from remote repo * tag with branch and sha * add ref on pull_request events * install python * be a bit more lax with python version * fix image size calc * hardcode lower case image name * use @ * only add sha on master branch, add master tag on master * chore: use docker image in e2e tests This is to try to add some guarantees to the docker image without having to manually test it, so we can be a bit more aggressive with improvements without, e.g. having to push to the playground or run locally. * wip * add to summary * wip * chore: put cypress tests after docker build I couldn't figure out a way to get workflow_run to run without merging in, so I'm just putting after the build. * wip * wip * wip * remove quotes * remove separate cypress install * wip * wip * wip * add gunicorn.config.py * ci: run docker image build on master as well This way we get the caching from the master build. * wip * wip Co-authored-by: James Greenhill <fuziontech@gmail.com>
2022-06-27 19:12:32 +02:00
EMAIL_HOST=email.test.posthog.net
SITE_URL=http://localhost:8000
NO_RESTART_LOOP=1
CLICKHOUSE_SECURE=0
OBJECT_STORAGE_ENABLED=1
OBJECT_STORAGE_ENDPOINT=http://localhost:19000
OBJECT_STORAGE_ACCESS_KEY_ID=object_storage_root_user
OBJECT_STORAGE_SECRET_ACCESS_KEY=object_storage_root_password
EOT
2023-05-23 14:12:16 +02:00
- name: Lowercase GITHUB_REPOSITORY
id: lowercase
run: |
echo "repository=${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT"
- name: Get the PostHog container image of this PR
if: needs.changes.outputs.shouldTriggerCypress == 'true'
id: meta
uses: docker/metadata-action@v4
with:
2023-05-23 14:12:16 +02:00
images: ghcr.io/${{ steps.lowercase.outputs.repository }}/posthog
- name: Start PostHog
# these are required checks so, we can't skip entire sections
if: needs.changes.outputs.shouldTriggerCypress == 'true'
chore(dockerfile): make docker build multistage (#10488) * chore(dockerfile): make docker build multistage The built image is >4GB uncompressed atm, I'm pretty sure there is a lot of cruft. Plan is to split out the django, frontend, plugin-server builds and hopefully get some gains in there to not include build deps. * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix dockerfile lints * cache from branch * add load :true * Update production.Dockerfile Co-authored-by: James Greenhill <fuziontech@gmail.com> * Update production.Dockerfile * update to use compressed size from remote repo * tag with branch and sha * add ref on pull_request events * install python * be a bit more lax with python version * fix image size calc * hardcode lower case image name * use @ * only add sha on master branch, add master tag on master * chore: use docker image in e2e tests This is to try to add some guarantees to the docker image without having to manually test it, so we can be a bit more aggressive with improvements without, e.g. having to push to the playground or run locally. * wip * add to summary * wip * chore: put cypress tests after docker build I couldn't figure out a way to get workflow_run to run without merging in, so I'm just putting after the build. * wip * wip * wip * remove quotes * remove separate cypress install * wip * wip * wip * add gunicorn.config.py * ci: run docker image build on master as well This way we get the caching from the master build. * wip * wip Co-authored-by: James Greenhill <fuziontech@gmail.com>
2022-06-27 19:12:32 +02:00
run: |
mkdir -p /tmp/logs
echo "Starting PostHog using the container image ${{ steps.meta.outputs.tags }}"
DOCKER_RUN="docker run --rm --network host --add-host kafka:127.0.0.1 --env-file .env ${{ steps.meta.outputs.tags }}"
chore(dockerfile): make docker build multistage (#10488) * chore(dockerfile): make docker build multistage The built image is >4GB uncompressed atm, I'm pretty sure there is a lot of cruft. Plan is to split out the django, frontend, plugin-server builds and hopefully get some gains in there to not include build deps. * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix dockerfile lints * cache from branch * add load :true * Update production.Dockerfile Co-authored-by: James Greenhill <fuziontech@gmail.com> * Update production.Dockerfile * update to use compressed size from remote repo * tag with branch and sha * add ref on pull_request events * install python * be a bit more lax with python version * fix image size calc * hardcode lower case image name * use @ * only add sha on master branch, add master tag on master * chore: use docker image in e2e tests This is to try to add some guarantees to the docker image without having to manually test it, so we can be a bit more aggressive with improvements without, e.g. having to push to the playground or run locally. * wip * add to summary * wip * chore: put cypress tests after docker build I couldn't figure out a way to get workflow_run to run without merging in, so I'm just putting after the build. * wip * wip * wip * remove quotes * remove separate cypress install * wip * wip * wip * add gunicorn.config.py * ci: run docker image build on master as well This way we get the caching from the master build. * wip * wip Co-authored-by: James Greenhill <fuziontech@gmail.com>
2022-06-27 19:12:32 +02:00
$DOCKER_RUN ./bin/migrate
$DOCKER_RUN python manage.py setup_dev
# only starts the plugin server so that the "wait for PostHog" step passes
chore(dockerfile): make docker build multistage (#10488) * chore(dockerfile): make docker build multistage The built image is >4GB uncompressed atm, I'm pretty sure there is a lot of cruft. Plan is to split out the django, frontend, plugin-server builds and hopefully get some gains in there to not include build deps. * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix dockerfile lints * cache from branch * add load :true * Update production.Dockerfile Co-authored-by: James Greenhill <fuziontech@gmail.com> * Update production.Dockerfile * update to use compressed size from remote repo * tag with branch and sha * add ref on pull_request events * install python * be a bit more lax with python version * fix image size calc * hardcode lower case image name * use @ * only add sha on master branch, add master tag on master * chore: use docker image in e2e tests This is to try to add some guarantees to the docker image without having to manually test it, so we can be a bit more aggressive with improvements without, e.g. having to push to the playground or run locally. * wip * add to summary * wip * chore: put cypress tests after docker build I couldn't figure out a way to get workflow_run to run without merging in, so I'm just putting after the build. * wip * wip * wip * remove quotes * remove separate cypress install * wip * wip * wip * add gunicorn.config.py * ci: run docker image build on master as well This way we get the caching from the master build. * wip * wip Co-authored-by: James Greenhill <fuziontech@gmail.com>
2022-06-27 19:12:32 +02:00
$DOCKER_RUN ./bin/docker-worker &> /tmp/logs/worker.txt &
$DOCKER_RUN ./bin/docker-server &> /tmp/logs/server.txt &
- name: Wait for PostHog
# these are required checks so, we can't skip entire sections
if: needs.changes.outputs.shouldTriggerCypress == 'true'
uses: iFaxity/wait-on-action@v1
timeout-minutes: 3
with:
verbose: true
log: true
resource: http://localhost:8000
chore(dockerfile): make docker build multistage (#10488) * chore(dockerfile): make docker build multistage The built image is >4GB uncompressed atm, I'm pretty sure there is a lot of cruft. Plan is to split out the django, frontend, plugin-server builds and hopefully get some gains in there to not include build deps. * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix dockerfile lints * cache from branch * add load :true * Update production.Dockerfile Co-authored-by: James Greenhill <fuziontech@gmail.com> * Update production.Dockerfile * update to use compressed size from remote repo * tag with branch and sha * add ref on pull_request events * install python * be a bit more lax with python version * fix image size calc * hardcode lower case image name * use @ * only add sha on master branch, add master tag on master * chore: use docker image in e2e tests This is to try to add some guarantees to the docker image without having to manually test it, so we can be a bit more aggressive with improvements without, e.g. having to push to the playground or run locally. * wip * add to summary * wip * chore: put cypress tests after docker build I couldn't figure out a way to get workflow_run to run without merging in, so I'm just putting after the build. * wip * wip * wip * remove quotes * remove separate cypress install * wip * wip * wip * add gunicorn.config.py * ci: run docker image build on master as well This way we get the caching from the master build. * wip * wip Co-authored-by: James Greenhill <fuziontech@gmail.com>
2022-06-27 19:12:32 +02:00
- name: Cypress run
# these are required checks so, we can't skip entire sections
if: needs.changes.outputs.shouldTriggerCypress == 'true'
uses: cypress-io/github-action@v5
chore(dockerfile): make docker build multistage (#10488) * chore(dockerfile): make docker build multistage The built image is >4GB uncompressed atm, I'm pretty sure there is a lot of cruft. Plan is to split out the django, frontend, plugin-server builds and hopefully get some gains in there to not include build deps. * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix dockerfile lints * cache from branch * add load :true * Update production.Dockerfile Co-authored-by: James Greenhill <fuziontech@gmail.com> * Update production.Dockerfile * update to use compressed size from remote repo * tag with branch and sha * add ref on pull_request events * install python * be a bit more lax with python version * fix image size calc * hardcode lower case image name * use @ * only add sha on master branch, add master tag on master * chore: use docker image in e2e tests This is to try to add some guarantees to the docker image without having to manually test it, so we can be a bit more aggressive with improvements without, e.g. having to push to the playground or run locally. * wip * add to summary * wip * chore: put cypress tests after docker build I couldn't figure out a way to get workflow_run to run without merging in, so I'm just putting after the build. * wip * wip * wip * remove quotes * remove separate cypress install * wip * wip * wip * add gunicorn.config.py * ci: run docker image build on master as well This way we get the caching from the master build. * wip * wip Co-authored-by: James Greenhill <fuziontech@gmail.com>
2022-06-27 19:12:32 +02:00
with:
config-file: cypress.e2e.config.ts
config: retries=2
chore(dockerfile): make docker build multistage (#10488) * chore(dockerfile): make docker build multistage The built image is >4GB uncompressed atm, I'm pretty sure there is a lot of cruft. Plan is to split out the django, frontend, plugin-server builds and hopefully get some gains in there to not include build deps. * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix dockerfile lints * cache from branch * add load :true * Update production.Dockerfile Co-authored-by: James Greenhill <fuziontech@gmail.com> * Update production.Dockerfile * update to use compressed size from remote repo * tag with branch and sha * add ref on pull_request events * install python * be a bit more lax with python version * fix image size calc * hardcode lower case image name * use @ * only add sha on master branch, add master tag on master * chore: use docker image in e2e tests This is to try to add some guarantees to the docker image without having to manually test it, so we can be a bit more aggressive with improvements without, e.g. having to push to the playground or run locally. * wip * add to summary * wip * chore: put cypress tests after docker build I couldn't figure out a way to get workflow_run to run without merging in, so I'm just putting after the build. * wip * wip * wip * remove quotes * remove separate cypress install * wip * wip * wip * add gunicorn.config.py * ci: run docker image build on master as well This way we get the caching from the master build. * wip * wip Co-authored-by: James Greenhill <fuziontech@gmail.com>
2022-06-27 19:12:32 +02:00
spec: ${{ matrix.specs }}
install: false
chore(dockerfile): make docker build multistage (#10488) * chore(dockerfile): make docker build multistage The built image is >4GB uncompressed atm, I'm pretty sure there is a lot of cruft. Plan is to split out the django, frontend, plugin-server builds and hopefully get some gains in there to not include build deps. * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix dockerfile lints * cache from branch * add load :true * Update production.Dockerfile Co-authored-by: James Greenhill <fuziontech@gmail.com> * Update production.Dockerfile * update to use compressed size from remote repo * tag with branch and sha * add ref on pull_request events * install python * be a bit more lax with python version * fix image size calc * hardcode lower case image name * use @ * only add sha on master branch, add master tag on master * chore: use docker image in e2e tests This is to try to add some guarantees to the docker image without having to manually test it, so we can be a bit more aggressive with improvements without, e.g. having to push to the playground or run locally. * wip * add to summary * wip * chore: put cypress tests after docker build I couldn't figure out a way to get workflow_run to run without merging in, so I'm just putting after the build. * wip * wip * wip * remove quotes * remove separate cypress install * wip * wip * wip * add gunicorn.config.py * ci: run docker image build on master as well This way we get the caching from the master build. * wip * wip Co-authored-by: James Greenhill <fuziontech@gmail.com>
2022-06-27 19:12:32 +02:00
- name: Archive test screenshots
uses: actions/upload-artifact@v3
with:
name: screenshots
path: cypress/screenshots
if: ${{ failure() }}
- name: Archive test downloads
uses: actions/upload-artifact@v3
with:
name: downloads
path: cypress/downloads
if: ${{ failure() }}
- name: Archive test videos
uses: actions/upload-artifact@v3
with:
name: videos
path: cypress/videos
if: ${{ failure() }}
- name: Archive accessibility violations
if: needs.changes.outputs.shouldTriggerCypress == 'true'
uses: actions/upload-artifact@v3
with:
name: accessibility-violations
path: '**/a11y/'
if-no-files-found: 'ignore'
chore(dockerfile): make docker build multistage (#10488) * chore(dockerfile): make docker build multistage The built image is >4GB uncompressed atm, I'm pretty sure there is a lot of cruft. Plan is to split out the django, frontend, plugin-server builds and hopefully get some gains in there to not include build deps. * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix dockerfile lints * cache from branch * add load :true * Update production.Dockerfile Co-authored-by: James Greenhill <fuziontech@gmail.com> * Update production.Dockerfile * update to use compressed size from remote repo * tag with branch and sha * add ref on pull_request events * install python * be a bit more lax with python version * fix image size calc * hardcode lower case image name * use @ * only add sha on master branch, add master tag on master * chore: use docker image in e2e tests This is to try to add some guarantees to the docker image without having to manually test it, so we can be a bit more aggressive with improvements without, e.g. having to push to the playground or run locally. * wip * add to summary * wip * chore: put cypress tests after docker build I couldn't figure out a way to get workflow_run to run without merging in, so I'm just putting after the build. * wip * wip * wip * remove quotes * remove separate cypress install * wip * wip * wip * add gunicorn.config.py * ci: run docker image build on master as well This way we get the caching from the master build. * wip * wip Co-authored-by: James Greenhill <fuziontech@gmail.com>
2022-06-27 19:12:32 +02:00
- name: Show logs on failure
# use artefact here, as I think the output will be too large for display in an action
uses: actions/upload-artifact@v3
with:
name: logs
path: /tmp/logs
if: ${{ failure() }}