2022-02-22 16:06:04 +01:00
|
|
|
|
# This workflow runs all of our backend django tests.
|
|
|
|
|
#
|
|
|
|
|
# If these tests get too slow, look at increasing concurrency and re-timing the tests by manually dispatching
|
|
|
|
|
# .github/workflows/ci-backend-update-test-timing.yml action
|
2020-08-18 11:08:40 +02:00
|
|
|
|
name: Backend CI
|
|
|
|
|
|
|
|
|
|
on:
|
2021-10-21 09:12:19 +02:00
|
|
|
|
push:
|
|
|
|
|
branches:
|
|
|
|
|
- master
|
|
|
|
|
pull_request:
|
2022-02-22 16:06:04 +01:00
|
|
|
|
workflow_dispatch:
|
|
|
|
|
inputs:
|
|
|
|
|
clickhouseServerVersion:
|
|
|
|
|
description: ClickHouse server version. Leave blank for default
|
|
|
|
|
type: string
|
|
|
|
|
|
2021-02-24 08:32:44 +01:00
|
|
|
|
env:
|
|
|
|
|
SECRET_KEY: '6b01eee4f945ca25045b5aab440b953461faf08693a9abbf1166dc7c6b9772da' # unsafe - for testing only
|
2021-10-01 10:43:50 +02:00
|
|
|
|
DATABASE_URL: 'postgres://posthog:posthog@localhost:5432/posthog'
|
2021-02-24 08:32:44 +01:00
|
|
|
|
REDIS_URL: 'redis://localhost'
|
2021-10-01 10:43:50 +02:00
|
|
|
|
CLICKHOUSE_HOST: 'localhost'
|
|
|
|
|
CLICKHOUSE_SECURE: 'False'
|
|
|
|
|
CLICKHOUSE_VERIFY: 'False'
|
2021-08-25 10:58:09 +02:00
|
|
|
|
TEST: 1
|
2022-02-22 16:06:04 +01:00
|
|
|
|
CLICKHOUSE_SERVER_IMAGE_VERSION: ${{ github.event.inputs.clickhouseServerVersion || '' }}
|
2022-05-20 10:56:50 +02:00
|
|
|
|
OBJECT_STORAGE_ENABLED: 'True'
|
|
|
|
|
OBJECT_STORAGE_ENDPOINT: 'http://localhost:19000'
|
|
|
|
|
OBJECT_STORAGE_ACCESS_KEY_ID: 'object_storage_root_user'
|
|
|
|
|
OBJECT_STORAGE_SECRET_ACCESS_KEY: 'object_storage_root_password'
|
2020-08-18 11:08:40 +02:00
|
|
|
|
|
2022-06-14 11:49:44 +02:00
|
|
|
|
concurrency:
|
|
|
|
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
|
2020-08-18 11:08:40 +02:00
|
|
|
|
jobs:
|
2021-10-13 14:09:40 +02:00
|
|
|
|
# Job to decide if we should run backend ci
|
|
|
|
|
# See https://github.com/dorny/paths-filter#conditional-execution for more details
|
2021-10-12 09:21:10 +02:00
|
|
|
|
changes:
|
|
|
|
|
runs-on: ubuntu-latest
|
2022-06-07 19:56:46 +02:00
|
|
|
|
timeout-minutes: 5
|
2021-10-25 23:59:31 +02:00
|
|
|
|
if: github.repository == 'PostHog/posthog'
|
2021-10-13 14:09:40 +02:00
|
|
|
|
name: Determine need to run backend checks
|
2021-10-12 09:21:10 +02:00
|
|
|
|
# Set job outputs to values from filter step
|
|
|
|
|
outputs:
|
|
|
|
|
backend: ${{ steps.filter.outputs.backend }}
|
|
|
|
|
steps:
|
2021-10-21 09:42:41 +02:00
|
|
|
|
# For pull requests it's not necessary to checkout the code, but we
|
|
|
|
|
# also want this to run on master so we need to checkout
|
2022-10-26 20:40:00 +02:00
|
|
|
|
- uses: actions/checkout@v3
|
2021-10-21 09:42:41 +02:00
|
|
|
|
|
2021-10-12 09:21:10 +02:00
|
|
|
|
- uses: dorny/paths-filter@v2
|
|
|
|
|
id: filter
|
|
|
|
|
with:
|
|
|
|
|
filters: |
|
|
|
|
|
backend:
|
|
|
|
|
# Avoid running backend 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/**/*'
|
2022-12-02 14:52:12 +01:00
|
|
|
|
- 'bin/*.py'
|
2021-10-12 09:21:10 +02:00
|
|
|
|
- requirements.txt
|
|
|
|
|
- requirements-dev.txt
|
|
|
|
|
- mypy.ini
|
|
|
|
|
- pytest.ini
|
2022-03-15 12:19:21 +01:00
|
|
|
|
# Make sure we run if someone is explicitly change the workflow
|
2021-10-12 09:21:10 +02:00
|
|
|
|
- .github/workflows/ci-backend.yml
|
2022-02-22 16:06:04 +01:00
|
|
|
|
- .github/workflows/backend-tests-action/action.yml
|
2022-11-29 21:50:42 +01:00
|
|
|
|
# We use docker compose for tests, make sure we rerun on
|
2022-03-15 12:19:21 +01:00
|
|
|
|
# changes to docker-compose.dev.yml e.g. dependency
|
|
|
|
|
# version changes
|
|
|
|
|
- docker-compose.dev.yml
|
2021-10-12 09:21:10 +02:00
|
|
|
|
|
2021-01-22 15:36:30 +01:00
|
|
|
|
backend-code-quality:
|
2021-10-12 09:21:10 +02:00
|
|
|
|
needs: changes
|
2022-06-07 19:56:46 +02:00
|
|
|
|
timeout-minutes: 5
|
2021-10-12 09:21:10 +02:00
|
|
|
|
# Make sure we only run on backend changes
|
2021-10-25 23:59:31 +02:00
|
|
|
|
if: ${{ needs.changes.outputs.backend == 'true' && github.repository == 'PostHog/posthog' }}
|
2021-10-12 09:21:10 +02:00
|
|
|
|
|
2022-02-22 16:06:04 +01:00
|
|
|
|
name: Python code quality checks
|
2020-08-18 11:08:40 +02:00
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
|
|
steps:
|
2022-10-26 20:40:00 +02:00
|
|
|
|
- uses: actions/checkout@v3
|
2020-08-18 11:08:40 +02:00
|
|
|
|
with:
|
|
|
|
|
fetch-depth: 1
|
|
|
|
|
|
2022-07-06 16:03:01 +02:00
|
|
|
|
- name: Stop/Start stack with Docker Compose
|
|
|
|
|
run: |
|
2022-11-29 21:50:42 +01:00
|
|
|
|
docker compose -f docker-compose.dev.yml down
|
|
|
|
|
docker compose -f docker-compose.dev.yml up -d
|
2022-07-06 16:03:01 +02:00
|
|
|
|
|
|
|
|
|
- name: Set up Python
|
2022-10-26 20:40:00 +02:00
|
|
|
|
uses: actions/setup-python@v4
|
2020-08-18 11:08:40 +02:00
|
|
|
|
with:
|
2022-09-08 12:56:30 +02:00
|
|
|
|
python-version: 3.8.14
|
2020-08-18 11:08:40 +02:00
|
|
|
|
|
2022-10-26 20:40:00 +02:00
|
|
|
|
- uses: syphar/restore-virtualenv@v1
|
2021-11-03 10:33:16 +01:00
|
|
|
|
id: cache-backend-tests
|
|
|
|
|
with:
|
|
|
|
|
custom_cache_key_element: v1-
|
2021-09-13 14:55:13 +02:00
|
|
|
|
|
2021-05-25 18:25:37 +02:00
|
|
|
|
- uses: syphar/restore-pip-download-cache@v1
|
2021-11-03 10:33:16 +01:00
|
|
|
|
if: steps.cache-backend-tests.outputs.cache-hit != 'true'
|
2021-09-13 14:55:13 +02:00
|
|
|
|
|
2022-06-29 13:41:44 +02:00
|
|
|
|
- name: Install SAML (python3-saml) dependencies
|
|
|
|
|
run: |
|
|
|
|
|
sudo apt-get update
|
|
|
|
|
sudo apt-get install libxml2-dev libxmlsec1-dev libxmlsec1-openssl
|
|
|
|
|
|
2021-05-25 18:25:37 +02:00
|
|
|
|
- name: Install python dependencies
|
2021-11-03 10:33:16 +01:00
|
|
|
|
if: steps.cache-backend-tests.outputs.cache-hit != 'true'
|
2020-08-18 11:08:40 +02:00
|
|
|
|
run: |
|
2020-11-10 10:17:48 +01:00
|
|
|
|
python -m pip install -r requirements-dev.txt
|
2021-04-19 21:59:10 +02:00
|
|
|
|
python -m pip install -r requirements.txt
|
2020-08-18 11:08:40 +02:00
|
|
|
|
|
2020-11-02 15:55:20 +01:00
|
|
|
|
- name: Check formatting
|
2020-08-18 11:08:40 +02:00
|
|
|
|
run: |
|
2020-11-02 15:55:20 +01:00
|
|
|
|
black --check .
|
|
|
|
|
isort --check-only .
|
2020-08-18 11:08:40 +02:00
|
|
|
|
|
2022-02-18 11:10:32 +01:00
|
|
|
|
- name: Check for errors and code style violations
|
2020-08-18 11:08:40 +02:00
|
|
|
|
run: |
|
2022-02-18 11:10:32 +01:00
|
|
|
|
flake8 .
|
2020-08-18 11:08:40 +02:00
|
|
|
|
|
2022-02-18 11:10:32 +01:00
|
|
|
|
- name: Check static typing
|
2020-08-18 11:08:40 +02:00
|
|
|
|
run: |
|
2020-11-02 15:55:20 +01:00
|
|
|
|
mypy .
|
2020-08-18 11:08:40 +02:00
|
|
|
|
|
2022-02-22 16:06:04 +01:00
|
|
|
|
check-migrations:
|
2021-10-12 09:21:10 +02:00
|
|
|
|
needs: changes
|
2022-06-07 19:56:46 +02:00
|
|
|
|
timeout-minutes: 5
|
|
|
|
|
|
2021-10-25 23:59:31 +02:00
|
|
|
|
if: ${{ needs.changes.outputs.backend == 'true' && github.repository == 'PostHog/posthog' }}
|
2021-10-12 09:21:10 +02:00
|
|
|
|
|
2022-04-06 11:27:53 +02:00
|
|
|
|
name: Validate Django migrations
|
2022-02-22 16:06:04 +01:00
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
|
|
steps:
|
2022-10-26 20:40:00 +02:00
|
|
|
|
- uses: actions/checkout@v3
|
2022-02-22 16:06:04 +01:00
|
|
|
|
|
2022-05-26 13:36:14 +02:00
|
|
|
|
- name: Stop/Start stack with Docker Compose
|
2022-02-22 16:06:04 +01:00
|
|
|
|
run: |
|
2022-11-29 21:50:42 +01:00
|
|
|
|
docker compose -f docker-compose.dev.yml down
|
|
|
|
|
docker compose -f docker-compose.dev.yml up -d
|
2022-02-22 16:06:04 +01:00
|
|
|
|
|
|
|
|
|
- name: Set up Python
|
2022-10-26 20:40:00 +02:00
|
|
|
|
uses: actions/setup-python@v4
|
2022-02-22 16:06:04 +01:00
|
|
|
|
with:
|
2022-09-08 12:56:30 +02:00
|
|
|
|
python-version: 3.8.14
|
2022-02-22 16:06:04 +01:00
|
|
|
|
|
2022-10-26 20:40:00 +02:00
|
|
|
|
- uses: syphar/restore-virtualenv@v1
|
2022-02-22 16:06:04 +01:00
|
|
|
|
id: cache-backend-tests
|
|
|
|
|
with:
|
|
|
|
|
custom_cache_key_element: v1-
|
|
|
|
|
|
|
|
|
|
- uses: syphar/restore-pip-download-cache@v1
|
|
|
|
|
if: steps.cache-backend-tests.outputs.cache-hit != 'true'
|
|
|
|
|
|
2022-06-29 13:41:44 +02:00
|
|
|
|
- name: Install SAML (python3-saml) dependencies
|
|
|
|
|
run: |
|
|
|
|
|
sudo apt-get update
|
|
|
|
|
sudo apt-get install libxml2-dev libxmlsec1-dev libxmlsec1-openssl
|
|
|
|
|
|
2022-02-22 16:06:04 +01:00
|
|
|
|
- name: Install python dependencies
|
|
|
|
|
if: steps.cache-backend-tests.outputs.cache-hit != 'true'
|
|
|
|
|
run: |
|
|
|
|
|
python -m pip install -r requirements-dev.txt
|
|
|
|
|
python -m pip install -r requirements.txt
|
|
|
|
|
|
2023-01-04 16:49:36 +01:00
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
|
with:
|
|
|
|
|
ref: master
|
|
|
|
|
|
|
|
|
|
- name: Run migrations up to master
|
|
|
|
|
run: |
|
|
|
|
|
python manage.py migrate
|
|
|
|
|
|
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
|
|
2022-02-22 16:06:04 +01:00
|
|
|
|
- name: Check migrations
|
|
|
|
|
run: |
|
|
|
|
|
python manage.py makemigrations --check --dry-run
|
|
|
|
|
git fetch origin master
|
|
|
|
|
# `git diff --name-only` returns a list of files that were changed - added OR deleted OR modified
|
|
|
|
|
# With `--name-status` we get the same, but including a column for status, respectively: A, D, M
|
|
|
|
|
# In this check we exclusively care about files that were added (A) in posthog/migrations/
|
2022-03-11 20:45:31 +01:00
|
|
|
|
git diff --name-status origin/master..HEAD | grep "A\sposthog/migrations/" | awk '{print $2}' | python manage.py test_migrations_are_safe
|
2022-02-22 16:06:04 +01:00
|
|
|
|
|
|
|
|
|
django:
|
|
|
|
|
needs: changes
|
2022-06-07 19:56:46 +02:00
|
|
|
|
timeout-minutes: 30
|
2022-02-22 16:06:04 +01:00
|
|
|
|
if: ${{ needs.changes.outputs.backend == 'true' && github.repository == 'PostHog/posthog' || github.event_name == 'workflow_dispatch' }}
|
|
|
|
|
|
2022-12-01 23:36:45 +01:00
|
|
|
|
name: Django tests – ${{ matrix.segment }} (persons-on-events ${{ matrix.person-on-events && 'on' || 'off' }}), Py ${{ matrix.python-version }}, ${{ matrix.clickhouse-server-image }} (${{matrix.group}}/${{ matrix.concurrency }})
|
2020-08-18 11:08:40 +02:00
|
|
|
|
runs-on: ubuntu-latest
|
2021-03-30 16:12:48 +02:00
|
|
|
|
|
2020-10-26 11:11:02 +01:00
|
|
|
|
strategy:
|
2020-10-28 16:11:45 +01:00
|
|
|
|
fail-fast: false
|
2020-10-26 11:11:02 +01:00
|
|
|
|
matrix:
|
2022-09-08 12:56:30 +02:00
|
|
|
|
python-version: ['3.8.14']
|
2022-05-23 23:44:27 +02:00
|
|
|
|
clickhouse-server-image: ['clickhouse/clickhouse-server:22.3']
|
2022-12-01 23:36:45 +01:00
|
|
|
|
segment: ['FOSS', 'EE']
|
|
|
|
|
person-on-events: [false, true]
|
|
|
|
|
# :NOTE: Keep concurrency and groups in sync
|
2021-11-01 16:23:23 +01:00
|
|
|
|
concurrency: [5]
|
|
|
|
|
group: [1, 2, 3, 4, 5]
|
2022-03-10 14:14:30 +01:00
|
|
|
|
|
2020-08-18 11:08:40 +02:00
|
|
|
|
steps:
|
2022-10-26 20:40:00 +02:00
|
|
|
|
- uses: actions/checkout@v3
|
2020-08-18 11:08:40 +02:00
|
|
|
|
with:
|
|
|
|
|
fetch-depth: 1
|
2022-05-10 13:05:28 +02:00
|
|
|
|
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
|
|
|
|
ref: ${{ github.event.pull_request.head.ref }}
|
2022-06-29 18:26:15 +02:00
|
|
|
|
# Use PostHog Bot token when not on forks to enable proper snapshot updating
|
|
|
|
|
token: ${{ github.event.pull_request.head.repo.full_name == github.repository && secrets.POSTHOG_BOT_GITHUB_TOKEN || github.token }}
|
2021-08-27 16:20:49 +02:00
|
|
|
|
|
2022-02-22 16:06:04 +01:00
|
|
|
|
- uses: ./.github/actions/run-backend-tests
|
2020-08-18 11:08:40 +02:00
|
|
|
|
with:
|
2022-12-01 23:36:45 +01:00
|
|
|
|
segment: ${{ matrix.segment }}
|
|
|
|
|
person-on-events: ${{ matrix.person-on-events }}
|
2020-10-26 11:11:02 +01:00
|
|
|
|
python-version: ${{ matrix.python-version }}
|
2022-05-19 10:50:13 +02:00
|
|
|
|
clickhouse-server-image: ${{ matrix.clickhouse-server-image }}
|
2022-02-22 16:06:04 +01:00
|
|
|
|
concurrency: ${{ matrix.concurrency }}
|
|
|
|
|
group: ${{ matrix.group }}
|
2020-09-01 12:07:48 +02:00
|
|
|
|
|
2022-06-24 17:02:54 +02:00
|
|
|
|
- uses: EndBug/add-and-commit@v9
|
|
|
|
|
# Skip on forks
|
|
|
|
|
# Also skip for persons-on-events runs, as we want to ignore snapshots diverging there
|
|
|
|
|
if: ${{ !matrix.person-on-events && github.event.pull_request.head.repo.full_name == github.repository }}
|
2022-05-10 13:05:28 +02:00
|
|
|
|
with:
|
2022-09-07 12:45:47 +02:00
|
|
|
|
add: '["ee", "posthog/api/test/__snapshots__", "posthog/test/__snapshots__", "posthog/queries/"]'
|
2022-05-10 13:05:28 +02:00
|
|
|
|
message: 'Update snapshots'
|
2022-10-12 11:50:24 +02:00
|
|
|
|
default_author: github_actions
|
2022-06-24 17:02:54 +02:00
|
|
|
|
|
2022-06-23 17:32:14 +02:00
|
|
|
|
- name: Check if any snapshot changes were left uncomitted
|
|
|
|
|
id: changed-files
|
2022-06-24 17:02:54 +02:00
|
|
|
|
if: ${{ !matrix.person-on-events && github.event.pull_request.head.repo.full_name == github.repository }}
|
2022-06-23 17:32:14 +02:00
|
|
|
|
run: |
|
|
|
|
|
if [[ -z $(git status -s | grep -v ".test_durations" | tr -d "\n") ]]
|
|
|
|
|
then
|
2022-10-26 19:28:12 +02:00
|
|
|
|
echo 'files_found=false' >> $GITHUB_OUTPUT
|
2022-06-23 17:32:14 +02:00
|
|
|
|
else
|
2022-10-26 19:28:12 +02:00
|
|
|
|
echo 'diff=$(git status --porcelain)' >> $GITHUB_OUTPUT
|
|
|
|
|
echo 'files_found=true' >> $GITHUB_OUTPUT
|
2022-06-23 17:32:14 +02:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
- name: Fail CI if some snapshots have been updated but not committed
|
|
|
|
|
if: steps.changed-files.outputs.files_found == 'true' && steps.add-and-commit.outcome == 'success'
|
|
|
|
|
run: |
|
|
|
|
|
echo "${{ steps.changed-files.outputs.diff }}"
|
|
|
|
|
exit 1
|
2022-06-24 17:02:54 +02:00
|
|
|
|
|
2022-06-21 18:38:10 +02:00
|
|
|
|
- name: Archive email renders
|
|
|
|
|
uses: actions/upload-artifact@v3
|
2022-06-24 17:02:54 +02:00
|
|
|
|
if: matrix.foss
|
2022-06-21 18:38:10 +02:00
|
|
|
|
with:
|
|
|
|
|
name: email_renders
|
|
|
|
|
path: posthog/tasks/test/__emails__
|
2022-05-10 13:05:28 +02:00
|
|
|
|
|
2020-11-10 08:47:57 +01:00
|
|
|
|
cloud:
|
2021-10-12 09:21:10 +02:00
|
|
|
|
needs: changes
|
2022-06-07 19:56:46 +02:00
|
|
|
|
timeout-minutes: 30
|
2021-10-25 23:59:31 +02:00
|
|
|
|
if: ${{ needs.changes.outputs.backend == 'true' && github.repository == 'PostHog/posthog' }}
|
2021-10-12 09:21:10 +02:00
|
|
|
|
|
2020-11-10 08:47:57 +01:00
|
|
|
|
name: Django tests – Cloud
|
2020-09-01 12:07:48 +02:00
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
steps:
|
2021-02-24 23:20:05 +01:00
|
|
|
|
- name: Fetch posthog-cloud
|
2020-09-01 12:07:48 +02:00
|
|
|
|
run: |
|
2022-05-06 14:17:04 +02:00
|
|
|
|
curl -u posthog-bot:${{ secrets.POSTHOG_BOT_GITHUB_TOKEN }} -L https://github.com/posthog/posthog-cloud/tarball/master | tar --strip-components=1 -xz --
|
2022-05-26 13:36:14 +02:00
|
|
|
|
|
2022-03-22 21:51:18 +01:00
|
|
|
|
- name: Checkout master
|
2022-10-26 20:40:00 +02:00
|
|
|
|
uses: actions/checkout@v3
|
2020-09-01 12:07:48 +02:00
|
|
|
|
with:
|
2022-03-22 21:51:18 +01:00
|
|
|
|
ref: 'master'
|
2022-05-26 13:36:14 +02:00
|
|
|
|
path: 'master/'
|
|
|
|
|
|
2021-02-24 23:20:05 +01:00
|
|
|
|
- name: Link posthog-cloud at master
|
2020-09-01 12:07:48 +02:00
|
|
|
|
run: |
|
2022-05-26 13:36:14 +02:00
|
|
|
|
cp -r multi_tenancy master/
|
|
|
|
|
cp -r messaging master/
|
|
|
|
|
cat multi_tenancy_settings.py > master/posthog/settings/cloud.py
|
|
|
|
|
cat requirements.txt >> master/requirements.txt
|
2022-05-20 10:56:50 +02:00
|
|
|
|
|
2022-05-26 13:36:14 +02:00
|
|
|
|
- name: Stop/Start stack with Docker Compose
|
2021-12-04 00:42:19 +01:00
|
|
|
|
run: |
|
2022-11-29 21:50:42 +01:00
|
|
|
|
docker compose -f master/docker-compose.dev.yml down
|
|
|
|
|
docker compose -f master/docker-compose.dev.yml up -d
|
2022-02-24 17:49:55 +01:00
|
|
|
|
|
2022-07-06 16:03:01 +02:00
|
|
|
|
- name: Set up Python
|
2022-10-26 20:40:00 +02:00
|
|
|
|
uses: actions/setup-python@v4
|
2020-09-01 12:07:48 +02:00
|
|
|
|
with:
|
2022-09-08 12:56:30 +02:00
|
|
|
|
python-version: 3.8.14
|
2021-08-27 16:20:49 +02:00
|
|
|
|
|
2022-10-26 20:40:00 +02:00
|
|
|
|
- uses: syphar/restore-virtualenv@v1
|
2021-05-25 18:25:37 +02:00
|
|
|
|
id: cache-backend-tests
|
2021-09-13 14:55:13 +02:00
|
|
|
|
|
2021-05-25 18:25:37 +02:00
|
|
|
|
- uses: syphar/restore-pip-download-cache@v1
|
|
|
|
|
if: steps.cache-backend-tests.outputs.cache-hit != 'true'
|
2021-09-13 14:55:13 +02:00
|
|
|
|
|
2022-03-10 14:14:30 +01:00
|
|
|
|
- name: Install SAML (python3-saml) dependencies
|
|
|
|
|
run: |
|
|
|
|
|
sudo apt-get update
|
|
|
|
|
sudo apt-get install libxml2-dev libxmlsec1-dev libxmlsec1-openssl
|
|
|
|
|
|
2021-05-25 18:25:37 +02:00
|
|
|
|
- name: Install python dependencies
|
|
|
|
|
if: steps.cache-backend-tests.outputs.cache-hit != 'true'
|
2020-09-01 12:07:48 +02:00
|
|
|
|
run: |
|
2022-05-26 13:36:14 +02:00
|
|
|
|
python -m pip install -r master/requirements-dev.txt
|
|
|
|
|
python -m pip install -r master/requirements.txt
|
2020-09-01 12:07:48 +02:00
|
|
|
|
|
2021-12-15 00:09:16 +01:00
|
|
|
|
- name: Wait for Clickhouse & Kafka
|
2022-05-26 13:36:14 +02:00
|
|
|
|
run: master/bin/check_kafka_clickhouse_up
|
2021-12-15 00:09:16 +01:00
|
|
|
|
|
2020-11-10 08:47:57 +01:00
|
|
|
|
# The 2-step migration process (first master, then current branch) verifies that it'll always
|
|
|
|
|
# be possible to migrate to the new version without problems in production
|
2022-05-26 13:36:14 +02:00
|
|
|
|
- name: Run migration on master branch
|
2020-11-10 08:47:57 +01:00
|
|
|
|
run: |
|
2022-05-26 13:36:14 +02:00
|
|
|
|
python master/manage.py migrate
|
2020-11-10 08:47:57 +01:00
|
|
|
|
|
|
|
|
|
- name: Checkout current branch
|
2022-10-26 20:40:00 +02:00
|
|
|
|
uses: actions/checkout@v3
|
2020-11-10 08:47:57 +01:00
|
|
|
|
with:
|
2022-05-26 13:36:14 +02:00
|
|
|
|
path: 'current/'
|
2020-11-10 08:47:57 +01:00
|
|
|
|
|
2021-04-09 09:04:53 +02:00
|
|
|
|
- name: Install requirements.txt dependencies with pip at current branch
|
|
|
|
|
run: |
|
2022-05-26 13:36:14 +02:00
|
|
|
|
cd current
|
2021-04-09 09:04:53 +02:00
|
|
|
|
python -m pip install --upgrade pip
|
|
|
|
|
python -m pip install -r requirements.txt
|
2021-10-13 16:00:47 +02:00
|
|
|
|
python -m pip install freezegun fakeredis pytest pytest-mock pytest-django syrupy
|
2021-04-09 09:04:53 +02:00
|
|
|
|
|
2021-02-24 23:20:05 +01:00
|
|
|
|
- name: Link posthog-cloud at current branch
|
2020-11-10 08:47:57 +01:00
|
|
|
|
run: |
|
2022-05-26 13:36:14 +02:00
|
|
|
|
cp current/ee/conftest.py multi_tenancy/conftest.py
|
|
|
|
|
cp current/ee/conftest.py messaging/conftest.py
|
|
|
|
|
cp -r multi_tenancy current/
|
|
|
|
|
cp -r messaging current/
|
|
|
|
|
cat multi_tenancy_settings.py > current/posthog/settings/cloud.py
|
|
|
|
|
cat requirements.txt >> current/requirements.txt
|
2020-11-10 08:47:57 +01:00
|
|
|
|
|
2020-09-01 12:07:48 +02:00
|
|
|
|
- name: Check migrations
|
|
|
|
|
run: |
|
2022-05-26 13:36:14 +02:00
|
|
|
|
cd current
|
2020-09-01 12:07:48 +02:00
|
|
|
|
python manage.py makemigrations --check --dry-run
|
2020-11-10 08:47:57 +01:00
|
|
|
|
python manage.py migrate
|
2020-09-01 12:07:48 +02:00
|
|
|
|
|
2021-11-01 16:23:23 +01:00
|
|
|
|
- name: Set up needed files
|
2020-09-01 12:07:48 +02:00
|
|
|
|
run: |
|
2022-05-26 13:36:14 +02:00
|
|
|
|
cd current
|
2020-09-01 12:07:48 +02:00
|
|
|
|
mkdir -p frontend/dist
|
2022-01-12 21:06:40 +01:00
|
|
|
|
python manage.py collectstatic --noinput
|
2020-09-01 12:07:48 +02:00
|
|
|
|
touch frontend/dist/index.html
|
|
|
|
|
touch frontend/dist/layout.html
|
2022-05-27 14:31:17 +02:00
|
|
|
|
touch frontend/dist/exporter.html
|
2020-10-28 09:38:01 +01:00
|
|
|
|
|
2021-02-24 23:20:05 +01:00
|
|
|
|
- name: Run cloud tests (posthog-cloud)
|
2020-10-28 09:38:01 +01:00
|
|
|
|
run: |
|
2021-03-02 22:47:56 +01:00
|
|
|
|
source .env.template
|
2022-05-26 13:36:14 +02:00
|
|
|
|
cd current
|
2022-04-27 14:38:39 +02:00
|
|
|
|
pytest multi_tenancy messaging -m "not skip_on_multitenancy and not async_migrations" --durations=100 --durations-min=1.0
|
2022-12-01 23:36:45 +01:00
|
|
|
|
|
|
|
|
|
async-migrations:
|
|
|
|
|
name: Async migrations tests
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
steps:
|
|
|
|
|
- name: 'Checkout repo'
|
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
with:
|
|
|
|
|
fetch-depth: 1
|
|
|
|
|
|
|
|
|
|
- name: Start stack with Docker Compose
|
|
|
|
|
shell: bash
|
|
|
|
|
run: |
|
|
|
|
|
export CLICKHOUSE_SERVER_IMAGE_VERSION=${{ inputs.clickhouse-server-image-version }}
|
|
|
|
|
docker compose -f docker-compose.dev.yml down
|
|
|
|
|
docker compose -f docker-compose.dev.yml up -d
|
|
|
|
|
|
|
|
|
|
- name: Set up Python
|
|
|
|
|
uses: actions/setup-python@v4
|
|
|
|
|
with:
|
2022-12-05 16:08:31 +01:00
|
|
|
|
python-version: 3.8.14
|
2022-12-01 23:36:45 +01:00
|
|
|
|
|
|
|
|
|
- name: Install SAML (python3-saml) dependencies
|
|
|
|
|
shell: bash
|
|
|
|
|
run: |
|
|
|
|
|
sudo apt-get update
|
|
|
|
|
sudo apt-get install libxml2-dev libxmlsec1-dev libxmlsec1-openssl
|
|
|
|
|
|
|
|
|
|
- uses: syphar/restore-virtualenv@v1
|
|
|
|
|
id: cache-async-migrations-tests
|
|
|
|
|
with:
|
|
|
|
|
custom_cache_key_element: v1-${{ inputs.cache-id }}
|
|
|
|
|
|
|
|
|
|
- uses: syphar/restore-pip-download-cache@v1
|
|
|
|
|
if: steps.cache-backend-tests.outputs.cache-hit != 'true'
|
|
|
|
|
|
|
|
|
|
- name: Install python dependencies
|
|
|
|
|
if: steps.cache-backend-tests.outputs.cache-hit != 'true'
|
|
|
|
|
shell: bash
|
|
|
|
|
run: |
|
|
|
|
|
python -m pip install -r requirements-dev.txt
|
|
|
|
|
python -m pip install -r requirements.txt
|
|
|
|
|
|
|
|
|
|
- name: Add kafka host to /etc/hosts for kafka connectivity
|
|
|
|
|
shell: bash
|
|
|
|
|
run: sudo echo "127.0.0.1 kafka" | sudo tee -a /etc/hosts
|
|
|
|
|
|
|
|
|
|
- name: Set up needed files
|
|
|
|
|
shell: bash
|
|
|
|
|
run: |
|
|
|
|
|
mkdir -p frontend/dist
|
|
|
|
|
touch frontend/dist/index.html
|
|
|
|
|
touch frontend/dist/layout.html
|
|
|
|
|
touch frontend/dist/exporter.html
|
|
|
|
|
|
|
|
|
|
- name: Wait for Clickhouse & Kafka
|
|
|
|
|
shell: bash
|
|
|
|
|
run: bin/check_kafka_clickhouse_up
|
|
|
|
|
|
|
|
|
|
- name: Run async migrations tests
|
|
|
|
|
shell: bash
|
|
|
|
|
run: |
|
|
|
|
|
pytest -m "async_migrations"
|