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

323 lines
13 KiB
YAML
Raw Normal View History

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:
push:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build:
name: Docker image build
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
outputs:
docker_image_id: ${{ steps.docker_build.outputs.imageid }}
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
permissions:
contents: read
id-token: write
steps:
- name: Checkout PR branch
uses: actions/checkout@v2
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
# As ghcr.io complains if the image has upper case letters, we use
# this action to ensure we get a lower case version. See
# https://github.com/docker/build-push-action/issues/237#issuecomment-848673650
# for more details
- name: Docker image metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ghcr.io/posthog/posthog/posthog
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
tags: |
type=ref,event=pr
type=sha,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
type=raw,value=master,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Depot CLI
uses: depot/setup-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
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: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build
id: docker_build
uses: depot/build-push-action@v1
with:
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
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: |
type=docker,dest=/tmp/posthog-image.tar
project: 1stsk4xt19 # posthog-cloud project
buildx-fallback: true # if Depot builder is unavailable, fall back to local buildx
- name: Upload docker image
uses: actions/upload-artifact@v2
with:
name: docker-image
path: /tmp/posthog-image.tar
- name: Output image info including size
# Output the size of the local tar file, so give some idea about
# how code changes affect docker image size.
run: |
image_size_bytes=$(stat -c "%s" /tmp/posthog-image.tar)
image_name=$(echo '${{ steps.docker_build.outputs.metadata }}' | jq -r '."image.name"')
echo "### Build info" >> $GITHUB_STEP_SUMMARY
echo "Image size: $(numfmt --to=iec --suffix=B --format="%.2f" $image_size_bytes)" >> $GITHUB_STEP_SUMMARY
echo "Image name: $image_name" >> $GITHUB_STEP_SUMMARY
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
posthog_cloud:
name: PostHog Cloud image build
# Only run on non-external PRs. We could make this work on external PR's
# but that would be an improvement on what we currently do, so I'll
# leave that as a TODO.
# TODO: test Cloud build on external contributions as well.
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == 'PostHog/posthog' }}
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout PR branch
uses: actions/checkout@v2
- uses: actions/download-artifact@v3
with:
name: docker-image
path: /tmp/
- name: Load the non-cloud image
id: load
run: |
docker load < /tmp/posthog-image.tar
echo "docker_image_digest=$(docker image inspect ${{ needs.build.outputs.docker_image_id }} -f '{{ index .RepoTags 0 }}')" >> $GITHUB_OUTPUT
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Fetch posthog-cloud
run: |
mkdir cloud/
cd cloud/
curl -u posthog-bot:${{ secrets.POSTHOG_BOT_GITHUB_TOKEN }} -L https://github.com/posthog/posthog-cloud/tarball/master | tar --strip-components=1 -xz --
- name: Docker image metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ steps.login-ecr.outputs.registry }}/posthog-cloud
tags: |
type=ref,event=pr
type=sha,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
type=raw,value=master,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
type=raw,value=${{ github.sha }},enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
# We also want to use cache-from when building, but we want to also
# include the master tag so we get the master branch image as well.
# This creates a scope similar to the github cache action scoping
- name: Docker cache-from/cache-to metadata
id: meta-for-cache
uses: docker/metadata-action@v3
with:
images: ${{ steps.login-ecr.outputs.registry }}/posthog-cloud
tags: |
type=raw,value=master
type=ref,event=pr
- name: Build
id: docker_build
uses: docker/build-push-action@v2
with:
cache-from: ${{ steps.meta-for-cache.outputs.tags }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
# load: true # NOTE: this option is not compatible with `push: true`
# NOTE: we use inline as suggested here:
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#inline-cache
# It notes that it doesn't support mode=max, but we're not
# removing any layers, soooo, maybe it's fine.
cache-to: type=inline
file: Dockerfile.cloud
context: cloud
# Here we use the non-Cloud image and extend from it with the
# Cloud additions
build-args: |
BASE_IMAGE=${{ steps.load.outputs.docker_image_digest }}
- name: Trigger PostHog Cloud deployment
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
uses: mvasigh/dispatch-action@main
with:
# TODO: find a way to avoid using a personal access token. An
# option: push something to SQS (using WebIdentity) -> lambda
# function to trigger the workflow via webhook
token: ${{ secrets.POSTHOG_CLOUD_ACCESS_TOKEN }}
repo: posthog-cloud-infra
owner: PostHog
event_type: posthog_cloud_build
message: |
{
"image_tag": "${{ github.sha }}",
"context": ${{ toJson(github) }}
}
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:
name: Cypress preparation
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
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
specs: ${{ steps.set-specs.outputs.specs }}
steps:
- uses: actions/checkout@v2
- id: set-specs
# List cypress/e2e and produce a JSON array of the files, in chunks
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 }})
if: ${{ github.ref != 'refs/heads/master' }} # Don't run on master, we only care about node_modules cache
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: [build, cypress_prep]
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
uses: actions/checkout@v2
- name: Stop/Start stack with Docker Compose
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
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
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
- uses: actions/download-artifact@v3
with:
name: docker-image
path: /tmp/
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: Boot PostHog
env:
DOCKER_IMAGE_ID: ${{ needs.build.outputs.docker_image_id }}
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
docker load < /tmp/posthog-image.tar
DOCKER_RUN="docker run --rm --network host --add-host kafka:127.0.0.1 --env-file .env $DOCKER_IMAGE_ID"
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
$DOCKER_RUN ./bin/docker-worker &> /tmp/logs/worker.txt &
$DOCKER_RUN ./bin/docker-server &> /tmp/logs/server.txt &
- name: Cypress run
uses: cypress-io/github-action@v2
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 }}
- 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
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() }}