0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 12:21:02 +01:00
Commit Graph

241 Commits

Author SHA1 Message Date
Karl-Aksel Puulmann
9769ef0b5d
Improve backend CI (update .test_timings, run against different CH version) (#8708)
* Make clickhouse server image version configurable

* Attempt to use a reusable workflow for backend tests

* Try a composite action

* Add missing shell: bash

* Temporarily remove a step

* Cache id parameter

* Include the action when needing to rerun

* Move checking migrations to separate file

This didn't work in composite actions tests and slows down every
parallelized test execution for no reason. This should have been
separate in the first place.

* Rename job

* Improve check-migrations

* Start stack in the new job

* Remove shell

* Solve flaky test

* Remove unused file

* Create a test timings job

* Use checkout@v2 - https://github.com/cds-snc/github-actions/issues/23

* Ignore coverage files

* Save backend test durations

* Install pytest-split

* Clean up ci-backend

* Move actions code around

* wording improvement

* Save backend test durations

* Add a comment

* Make it possible to run tests with a different clickhouse version

* Remove debugging code

* Fix typo

* Boolean inputs please work

Fixes overeager test running as per https://github.com/actions/runner/issues/1483

Co-authored-by: PostHog Bot <hey@posthog.com>
2022-02-22 17:06:04 +02:00
Guido Iaquinti
61e8ffb123
.github/workflows/ci-backend.yml: fix flake8 config (#8676) 2022-02-18 11:10:32 +01:00
Harry Waye
bc43b8685e
feat(healthchecks): add clickhouse and redis health (#8497)
* feat(healthchecks): add clickhouse as a dependency

* feat(healthchecks): add celery broker healthcheck

* feat(healthchecks): add cache healthcheck, plus some misc updates

* add missing typing

* add missing typing

* add role cast

* Add logging for kafka connectivity check

* actually add healthcheck as middleware

* fix postgres failure check

* simplify postgres migration return value

* verboise -> verbose

Co-authored-by: Guido Iaquinti <4038041+guidoiaquinti@users.noreply.github.com>

* put interface validation at top of view

* remove unused imports

* show resp.content on status failures

* test(healthchecks): set log level to debug to pytest displays it

* restore logger level

* Bring up redis for backend ci tests

* up redis in non-cloud tests

Co-authored-by: Guido Iaquinti <4038041+guidoiaquinti@users.noreply.github.com>
2022-02-10 15:20:38 +00:00
James Greenhill
91dfa6897d
Add annotation to grafana on deploy (#8393)
* Add annotation to grafana on deploy

* prettier format yaml
2022-02-01 19:20:14 +00:00
Paul D'Ambra
04001be493
disable FOSS workflows by moving them (#8231) 2022-01-24 16:53:12 +00:00
Paul D'Ambra
52351afcc5
Disable foss sync job without erroring (#8222) 2022-01-24 13:03:50 +00:00
Rick Marron
2b9917a915
Recordings in paths (#8015)
* add recordings to path query

* uncomment cache

* add clarifying comment

* works for start/end paths

* move to extra fields/properties

* add tests

* cleanup

* update ff name

* fix flaky test

* test and handle path_dropoff_key case
2022-01-18 15:29:52 -08:00
James Greenhill
6a5b076f9b
Notify slack at start of deploy with Github Actions (#8123) 2022-01-18 13:46:01 -08:00
James Greenhill
63b4ae812f
Github action notify slack channel on deploy (#8122)
* Add Slack notification for deploys

* update message
2022-01-18 13:37:21 -08:00
Eric Duong
a71e899605
Yeetcode (#7830)
* remove django query tests

* remove funnel and caching check

* remove ee available var

* remove is_clickhouse_enabled

* remove abstract tests

* change primary db

* missing func

* unnecessary test

* try new e2e ci

* func arg

* remove param

* ci

* remove plugins in docker

* background

* change ur;

* add kafka url

* add step

* update docker

* primary docker file

* mount volumes correctly

* one more

* remove postgres tests

* remove foss

* remove all  is_clickhouse_neabled

* remove irrelelvant test

* remove extra arg

* remove var

* arg

* add foss comment

* add foss comment

* plugin server config

* Update posthog/utils.py

Co-authored-by: Karl-Aksel Puulmann <macobo@users.noreply.github.com>

* migrate commands

* comment

* add clickhouse to pg tests

* change script

* change ordering

* deepsource

* restore foss tests

* test remove KAFKA_ENABLED from CI

* always wait

* up proper resources

* use one conftest

* restore

* remove unnecessary tests

* remove more pg

* log event tests

* fix more tests

* more tests

* type

* fix more tests

* last test

* typing

* account for shared class setup

* temp test cloud

* restore cloud master checkout

* adjust contexts

* backwards

Co-authored-by: Karl-Aksel Puulmann <macobo@users.noreply.github.com>
Co-authored-by: yakkomajuri <yakko.majuri@gmail.com>
2022-01-18 14:32:28 -05:00
Paolo D'Amico
5e7ddb43eb
Fix cloud tests on master (#8008) 2022-01-12 14:06:40 -06:00
Karl-Aksel Puulmann
e5ee7b4270
Read from and write to person_distinct_id2 if async migration is done (#7846)
* Run queries against person_distinct_id2 when async migration is done

* Only write to clickhouse_person_unique_id topic if async migration is incomplete

* Update query snapshots

* Update plugin-server

* Adjust caching logic
2022-01-05 13:11:33 +02:00
Tim Glaser
2adc6258d2
Run e2e with clickhouse (#7705)
* Run e2e with clickhouse

* Set kafka to /etc/hosts, and speed up waiting

* fix persons page

* Migrate clickhouse

* Update e2e-test-runner

* Fixes/improvements

* fingers x'ed

* fix

* revert url

* fix demo data

* fix test

* Run Redis in docker

* fix test

* fix redis

* trap

* fix e2e-test-runner

* try localhost instead of kafka

* Revert "try localhost instead of kafka"

This reverts commit 58869c96df.
2022-01-03 14:26:54 +00:00
Karl-Aksel Puulmann
76131a285c
Revert "Revert "Proposal: Clean up settings.py"" (#7669)
* Revert "Revert "Proposal: Clean up settings.py (#7630)" (#7668)"

This reverts commit 704110fe52.

* Handle dynamic settings

* Handle cloud imports differently, fail early

* update flags

* Port async migrations

* Update cloud tests

* Update task definitions

* Revert CI hack
2021-12-16 12:14:21 +02:00
James Greenhill
7733e3e5a1
Fix cloud backend django tests in order to wait for CH to boot (#7716) 2021-12-14 15:50:56 -08:00
Tim Glaser
aab8e43d7d
Load clickhouse/kafka async and wait (#7707)
* Load clickhouse/kafka async and wait

* Change permissions

* Add to cloud tests

* move
2021-12-14 15:09:16 -08:00
Tim Glaser
704110fe52
Revert "Proposal: Clean up settings.py (#7630)" (#7668)
This reverts commit 588192f2d3.
2021-12-13 11:36:39 +00:00
Karl-Aksel Puulmann
588192f2d3
Proposal: Clean up settings.py (#7630)
* Move settings.py under its own folder

* Extract settings utils to own separate file

* Move base variables to base_variables.py

* Move feature flags code to own file

* Move IS_COLLECT_STATIC

* WIP: Move service requirements

* Move initial data store setup settings

* Move DATABASE_URL related code

* Move sentry settings

* Move logging settings

* Move overrides logic from settings

* Move redis code

* Move shell_plus settings

* Remove dead show_toolbar function

* Move celery over - including a bug

* Handle overloads properly

* Fix materialized_columns task

* Move CACHES logic over

* Celery import fixup

* Move EE_AVAILABLE

* Move proxying- and other access/security settings

* Move email-related settings

* Move warning about TEST to base_variables

* Move some web-related settings

* Improve imports

* Move emails, statsd

* move web-related settings

* Fix overrides

* Update tests for cloud

* Temporarily get tests green

* Update BASE_DIR

* overloads => overrides
2021-12-13 10:06:47 +02:00
Harry Waye
235c8f085d
ci(e2e): always run yarn install (#7659) 2021-12-11 13:38:15 +00:00
Harry Waye
a7a83e1aab
ci(e2e): manually split cypress tests to improve speed (#7558)
* ci(e2e): manually split cypress tests to improve speed

This change simply lists the spec dir for e2e tests, chunks them into
5, and passes these specs to cypress explicitly.

I initially tried to use https://github.com/kamilkisiela/split-tests/blob/master/packages/cypress/README.md
but ran into

```
We invoked the function exported by `/home/runner/work/posthog/posthog/cypress/plugins/index.js`, but it threw an error.

 TypeError: Cannot read property 'mochaFile' of null
    at loadReports (/home/runner/work/posthog/posthog/node_modules/dist/cypress/src/index.js:14:44)
    at module.exports (/home/runner/work/posthog/posthog/node_modules/dist/cypress/src/index.js:44:19)
    at module.exports (/home/runner/work/posthog/posthog/cypress/plugins/index.js:27:14)
    at /home/runner/.cache/Cypress/6.7.0/Cypress/resources/app/packages/server/lib/plugins/child/run_plugins.js:96:12
    at tryCatcher (/home/runner/.cache/Cypress/6.7.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (/home/runner/.cache/Cypress/6.7.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/method.js:39:29)
    at load (/home/runner/.cache/Cypress/6.7.0/Cypress/resources/app/packages/server/lib/plugins/child/run_plugins.js:93:7)
    at EventEmitter.<anonymous> (/home/runner/.cache/Cypress/6.7.0/Cypress/resources/app/packages/server/lib/plugins/child/run_plugins.js:204:5)
    at EventEmitter.emit (events.js:315:20)
    at process.<anonymous> (/home/runner/.cache/Cypress/6.7.0/Cypress/resources/app/packages/server/lib/plugins/util.js:19:22)
    at process.emit (events.js:315:20)
    at process.emit (/home/runner/.cache/Cypress/6.7.0/Cypress/resources/app/packages/server/node_modules/source-map-support/source-map-support.js:495:21)
    at emit (internal/child_process.js:876:12)
    at processTicksAndRejections (internal/process/task_queues.js:85:21)
```

And so decided to go for something "simpler"

See for details https://github.com/PostHog/posthog/runs/4443218344?check_suite_focus=true

* run on master, ensures node_modules cache in scope

* run deps install on master

* increase concurrency

* run yarn install in prep section

* move if to job

* still run yarn install

* refactor

* comments

* change name so we don't have to update requirements

* Update e2e.yml

Co-authored-by: Tim Glaser <tim@posthog.com>
2021-12-10 17:30:59 +00:00
Harry Waye
79d02059b9
ci(e2e): improve debug logging for github action workflow (#7629)
* github action artifact cypress videos

* artifact logs

* Fix cypress video export

* Redirect all output

* wait for initial retention load

* specify retry in ci

* use bin/start instead of bin/docker-*

* capture django app output in gunicorn log

* use docker-worker and docker-server again

* Remove gunicorn capture output settings
2021-12-10 12:38:25 +00:00
Karl-Aksel Puulmann
3a4beda2ad
Speed up person_distinct_id queries for select clients (#7577)
* Create a new way to get distinct id queries thats gated by team_id

* Update most cases to use the new query

* Convert EVENT_JOIN_PERSON_SQL to new query

* Mostly convert GET_DISTINCT_IDS_BY_PERSON_ID_FILTER

* Mostly convert GET_DISTINCT_IDS_BY_PROPERTY_SQL

* Convert GET_PERSON_IDS_BY_FILTER

* Flag benchmarks

* Resolve circular imports

* Update a snapshot test

* Add a test for the new query logic
2021-12-08 15:59:41 +02:00
Paolo D'Amico
47a2d72007
Stale events support (#7422)
Co-authored-by: Marius Andra <marius.andra@gmail.com>
2021-12-08 06:48:39 -07:00
Karl-Aksel Puulmann
63b8f12349
Make plugin server CI work with SAML (#7574)
Lifted from https://github.com/PostHog/posthog/pull/7492

Same fix as https://github.com/PostHog/posthog/pull/7506, not sure why
it's needed
2021-12-08 09:59:38 +02:00
Karl-Aksel Puulmann
6d50504e70
Fix cypress trends, paths and retention tests (#7524)
* Fix cypress paths and retention tests

These were broken in https://github.com/PostHog/posthog/pull/7473

* Attempt to fix trends test
2021-12-06 14:34:42 +01:00
James Greenhill
2fab8bfafa
Fix issue blocking clickhouse migrations on new installs (#7516)
Co-authored-by: James Greenhill <fuzionech@gmail.com>
2021-12-03 15:42:19 -08:00
Yakko Majuri
d58b141c58
fix saml tests (#7506) 2021-12-03 14:26:37 +00:00
James Greenhill
77861e4833
correct path to push to s3 to reflect production container location (#7479) 2021-12-01 17:37:57 -08:00
James Greenhill
e4d67d7e95
upload s3 assets from deploy dir for blue green deploys (#7477)
* upload s3 assets from deploy dir for blue green deploys

* the or is never evaluated
2021-12-01 17:11:08 -08:00
James Greenhill
b1347afca4
Upload app from container to s3 (#7476)
* .github/workflows/prod-container.yml: add step to upload to S3

* Change path

Co-authored-by: Guido Iaquinti <guido@posthog.com>
2021-12-01 16:42:40 -08:00
Rick Marron
0f17cb0951
update sentry org to posthog2 (#7443) 2021-12-01 14:34:12 -08:00
Harry Waye
71fa440394
Reimplement codespaces support (#7234)
* dev(codespaces): add "lean in" docker configuration for codespaces

This changes creates a dedicated `docker-compose.yml` and `Dockerfile`
for codespaces and doesn't attempt to have compatability with the
existing docker config files. This is intentional and is designed to be
a close to what codespaces would consider the ideal, so as to understand
what great would look like.

At the moment it doesn't do, but could:

 1. install python and node packages in the image
 2. push this image up to dockerhub
 3. specify this image to be used for caching. There is a "cacheFrom"
    option in the [.devcontainer
    reference](https://code.visualstudio.com/docs/remote/devcontainerjson-reference)
    although I haven't checked how this works with using
    `docker-compose.yml`. Perhaps we just need to add the `image:`
    property to the `app` service :fingerscrossed:
 4. specify default extensions and settings to be used.

* Use python 3.9, not the latest python 3 codespaces supports

* Add some basic python default settings and extensions

* add github codespaces image build workflow

* chore: update docker-compose cache from :cache tag

* chore: use docker cache-to inline

* add codespaces platform comment

* temp run on branch

* chore: fix flatforms format

* chore: update qemu comment

* chore: codespaces build use master image

* chore: target x86_64

* chore: just use image for codespaces, don't try to build

* add in python, node requirements

* install node

* install node

* uncomment node deps install

* use app network stack for all services

* move .env to .dev.env and us in docker-compose

* set WORKDIR to workspace

* pin apt packages

* pin versions, remove apt-key

* add yarn cache clean

* Fix hadolint warnings

* make codespace build on master, or a PR with codespaces-build label

* add missing &&

* dont bother with clickhouse install, its huge

* dont be cute with the networks, just expose explicitly

* fix network

* create container zsh

* correct .env path

* point app to the clickhouse container

* Also install saml deps

* ignore .env again

* libxml already installed

* correct conditional workflow comment
2021-11-23 08:34:51 +00:00
Marius Andra
c546c39bf1
Remove BackTo (#7238)
* remove BackTo

* link only if object present

* e2e cache buster

* rebust the cache
2021-11-22 10:48:00 +01:00
Tim Glaser
31ac831739
Update pull_request_template.md (#6952) 2021-11-16 07:50:51 -06:00
Marius Andra
3d97ddceae
yarn install plugin server deps earlier (#7149) 2021-11-16 09:52:57 +01:00
Yakko Majuri
963c62aaf1
Use monorepo plugin server (#6784)
* use plugin-server in same repo

* remove plugins dir

* update docker files

* clean up docker files:

* visual separation

* run plugin server test stack

* build and push test image

* revert push image

* fix default yarn start

* another fix

* fix some more

* add plugin-server-prod script

* make executable

* update scripts:

* revert prod script

* fixes

* fix tests

* clean

* move build to docker

* build plugin-server in prod dockerfile

* use different entrypoint for e2e test

* fix bugs with ts-node-dev

* restore yarn.lock

* lost a few changes in the rebase

* fix dockerfile

Co-authored-by: James Greenhill <fuziontech@gmail.com>
2021-11-13 11:52:00 -08:00
Yakko Majuri
3f7074fb5a
fix jest tests action (#6986) 2021-11-09 15:00:54 +00:00
Yakko Majuri
e4fd5c5774
Plugin server tests CI (#6897)
* remove workflows from plugin server subdir

* wip plugin server ci tests

* prettier

* add ignore paths

* update paths
2021-11-04 15:03:28 -07:00
Paolo D'Amico
f4fc1b7a25
Disable Cypress parallelization on forks (#6792) 2021-11-03 11:41:37 +00:00
Karl-Aksel Puulmann
9c9930764a Solve weird CI cache issue 2021-11-03 11:33:16 +02:00
Rob Banagale
5a8fab6be4
Grammar nit: write out number, hyphenate for consistency (#6418) 2021-11-02 09:52:31 -06:00
Paolo D'Amico
1e33b081ef
Disable Storybook previews on forks (#6777) 2021-11-01 19:20:34 +00:00
Karl-Aksel Puulmann
e66fbf0278
CI: Run EE tests in 5 minutes (#6759)
* Unify SAML and non-saml tests workflows

* Include matrix name in cache key

* Prettify yaml

* Measure test duration time

* Install pytest-split

* Try out parallelism

* Update name

* Fixup yaml

* Upload artifacts

* Run FOSS tests separately

* Run mark.ee tests only once

* Set up needed files properly

* Run backend tests only on one python version

* Run only cloud tests for cloud repo

* Remove test_durations file for posthog/

* Skip setting up ch on foss tests

* Fixup cloud tests

* Cache .test_durations file

* Fix ternary expression

* Only upload artefacts if needed

* .test_durations change

* Default to 3.8.5 in tests

* Add a note
2021-11-01 17:23:23 +02:00
Guido Iaquinti
70dc55e7f9
Remove .github/workflows/docker-vuln-scan.yml (#6747) 2021-10-29 12:21:02 +00:00
Tim Glaser
97b85b76a4
Revert "Update the docker-compose dev environment to reflect prod better (include pgbouncer) (#6558)" (#6692) 2021-10-27 05:54:48 -07:00
Guido Iaquinti
934a7a58fa
.github/workflows/docker-vuln-scan.yml: don't push the image (#6625) 2021-10-26 10:05:39 +00:00
Paolo D'Amico
ee12a63ff7
GH actions for FOSS (#6645) 2021-10-25 14:59:31 -07:00
Paolo D'Amico
1e2615ee56
Remove DO image generator (#6594) 2021-10-25 13:03:02 -07:00
Michael Matloka
53a58c9d2c
Rename DashboardItem model to Insight and deprecate DashboardItem{Serializer,ViewSet} (#6567)
* Only run `test_migrations_are_null` on new migrations

* Rename `DashboardItem` to `SavedInsight`

* Add explanation to `test_migrations_are_null` script

* Rename `test_dashboard` to `test_saved_insight_model`

* Ditch `DashboardItem{ViewSet,Serializer}` altogether

* Fix refresh via `InsightSerializer`

* "SavedInsight" to just "Insight"

* Update file names

* Update insight.py

* Update dashboardLogic.test.ts

* Update migration

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>
2021-10-25 09:12:37 +02:00
Guido Iaquinti
2cf73969a0
.github/workflows/docker-vuln-scan.yml run on main/master (#6568) 2021-10-21 14:19:47 -07:00