0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 12:21:02 +01:00
posthog/.github/workflows/benchmark.yml
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

185 lines
7.6 KiB
YAML

name: Benchmark
on:
pull_request:
branches: ['*']
schedule:
- cron: '0 4 * * 1-5' # Mon-Fri 4AM UTC
workflow_dispatch: {}
concurrency: 'benchmarks' # Ensure only one of this runs at a time
jobs:
run-benchmarks:
name: Clickhouse queries
runs-on: ubuntu-20.04
environment: clickhouse-benchmarks
# Benchmarks are expensive to run so we only run them (periodically) against master branch and for PRs labeled `performance`
if: ${{ github.ref == 'refs/heads/master' || contains(github.event.pull_request.labels.*.name, 'performance') }}
env:
SAML_DISABLED: '1'
DATABASE_URL: 'postgres://posthog:posthog@localhost:5432/posthog_test'
REDIS_URL: 'redis://localhost'
DEBUG: '1'
CLICKHOUSE_DATABASE: posthog
CLICKHOUSE_HOST: ${{ secrets.BENCHMARKS_CLICKHOUSE_HOST }}
CLICKHOUSE_USER: ${{ secrets.BENCHMARKS_CLICKHOUSE_USER }}
CLICKHOUSE_PASSWORD: ${{ secrets.BENCHMARKS_CLICKHOUSE_PASSWORD }}
CLICKHOUSE_SECURE: 'false'
CLICKHOUSE_VERIFY: 'false'
SECRET_KEY: '6b01eee4f945ca25045b5aab440b953461faf08693a9abbf1166dc7c6b9772da' # unsafe - for testing only
BENCHMARK: '1'
services:
postgres:
image: postgres:12
env:
POSTGRES_USER: posthog
POSTGRES_PASSWORD: posthog
POSTGRES_DB: posthog_test
ports:
# Maps port 5432 on service container to the host
# Needed because `postgres` host is not discoverable for some reason
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis
ports:
# Maps port 6379 on service container to the host
# Needed because `redis` host is not discoverable for some reason
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
with:
# Checkout repo with full history
fetch-depth: 0
- name: Check out PostHog/benchmarks-results repo
uses: actions/checkout@v2
with:
path: ee/benchmarks/results
repository: PostHog/benchmark-results
token: ${{ secrets.POSTHOG_BOT_GITHUB_TOKEN }}
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: syphar/restore-virtualenv@v1.2
id: cache-benchmark-tests
- uses: syphar/restore-pip-download-cache@v1
if: steps.cache-benchmark-tests.outputs.cache-hit != 'true'
- name: Install python dependencies
if: steps.cache-benchmark-tests.outputs.cache-hit != 'true'
run: |
python -m pip install -r requirements-dev.txt
python -m pip install -r requirements.txt
- name: Install asv
run: python -m pip install pip install git+https://github.com/airspeed-velocity/asv.git virtualenv
- name: Set up PostHog
run: |
python manage.py migrate & wait
python manage.py setup_dev --no-data
- name: Configure benchmarks
run: asv machine --config ee/benchmarks/asv.conf.json --yes --machine ci-benchmarks
- name: Run benchmarks
run: asv run --config ee/benchmarks/asv.conf.json --show-stderr --strict
- name: Compare results
run: |
asv compare $(cat ee/benchmarks/results/last-master-commit) HEAD --config ee/benchmarks/asv.conf.json --factor 1.2 | tee pr_vs_master.txt
asv compare $(cat ee/benchmarks/results/last-master-commit) HEAD --config ee/benchmarks/asv.conf.json --factor 1.2 --only-changed | tee pr_vs_master_changed.txt
- name: Save last benchmarked commit
if: ${{ github.ref == 'refs/heads/master' }}
run: echo "${{ github.sha }}" | tee ee/benchmarks/results/last-master-commit
- name: Generate HTML report of results
if: ${{ github.ref == 'refs/heads/master' }}
run: asv publish --config ee/benchmarks/asv.conf.json
- name: Commit update for benchmark results
if: ${{ github.repository == 'PostHog/posthog' && github.ref == 'refs/heads/master' }}
uses: stefanzweifel/git-auto-commit-action@v4
with:
repository: ee/benchmarks/results
branch: master
commit_message: 'Save benchmark results'
commit_user_name: PostHog Bot
commit_user_email: hey@posthog.com
commit_author: PostHog Bot <hey@posthog.com>
- name: Upload results as artifacts
uses: actions/upload-artifact@v2
with:
name: benchmarks
path: |
pr_vs_master.txt
pr_vs_master_changed.txt
- name: Read benchmark output
if: ${{ github.event_name == 'pull_request' }}
id: pr_vs_master_changed
uses: juliangruber/read-file-action@v1.0.0
with:
path: pr_vs_master_changed.txt
- name: Read benchmark output (full)
if: ${{ github.event_name == 'pull_request' }}
id: pr_vs_master
uses: juliangruber/read-file-action@v1.0.0
with:
path: pr_vs_master.txt
- name: Find Comment
if: ${{ github.event_name == 'pull_request' }}
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ github.event.number }}
comment-author: 'github-actions[bot]'
body-includes: ClickHouse query benchmark results from GitHub Actions
- name: Create or update comment
if: ${{ github.event_name == 'pull_request' }}
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.number }}
body: |
ClickHouse query benchmark results from GitHub Actions
Lower numbers are good, higher numbers are bad. A ratio less than 1
means a speed up and greater than 1 means a slowdown. Green lines
beginning with `+` are slowdowns (the PR is slower then master or
master is slower than the previous release). Red lines beginning
with `-` are speedups. Blank means no changes.
Significantly changed benchmark results (PR vs master)
```diff
${{ steps.pr_vs_master_changed.outputs.content }}
```
<details>
<summary>Click to view full benchmark results</summary>
```diff
${{ steps.pr_vs_master.outputs.content }}
```
</details>
edit-mode: replace