From 42d1f542508b6a899d3df156642f1e8de83fe7a9 Mon Sep 17 00:00:00 2001 From: Marius Andra Date: Wed, 9 Dec 2020 23:35:02 +0100 Subject: [PATCH 1/2] split tests and benchmarks --- .github/workflows/ci.yml | 6 ++++++ tests/worker.test.ts => benchmarks/worker.benchmark.ts | 4 ++-- jest.config.js | 2 +- package.json | 3 ++- 4 files changed, 11 insertions(+), 4 deletions(-) rename tests/worker.test.ts => benchmarks/worker.benchmark.ts (97%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 43dd50f5..9debc564 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,3 +51,9 @@ jobs: DATABASE_URL: 'postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres' REDIS_URL: 'redis://localhost' run: yarn task:db-init && yarn test + + - name: Run Benchmarks + env: + DATABASE_URL: 'postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres' + REDIS_URL: 'redis://localhost' + run: yarn task:db-init && yarn benchmark diff --git a/tests/worker.test.ts b/benchmarks/worker.benchmark.ts similarity index 97% rename from tests/worker.test.ts rename to benchmarks/worker.benchmark.ts index 5df88d36..d73ff48f 100644 --- a/tests/worker.test.ts +++ b/benchmarks/worker.benchmark.ts @@ -2,7 +2,7 @@ import { makePiscina } from '../src/worker/piscina' import { defaultConfig } from '../src/config' import { PluginEvent } from 'posthog-plugins/src/types' import { performance } from 'perf_hooks' -import { mockJestWithIndex } from './helpers/plugins' +import { mockJestWithIndex } from '../tests/helpers/plugins' import * as os from 'os' import { LogLevel } from '../src/types' @@ -71,7 +71,7 @@ function setupPiscina(workers: number, code: string, tasksPerWorker: number) { }) } -test('piscina worker test', async () => { +test('piscina worker benchmark', async () => { // Uncomment this to become a 10x developer and make the test run just as fast! // Reduces events by 10x and limits threads to max 8 for quicker development const isLightDevRun = false diff --git a/jest.config.js b/jest.config.js index 6dcc4105..c7b202e5 100644 --- a/jest.config.js +++ b/jest.config.js @@ -4,5 +4,5 @@ module.exports = { clearMocks: true, coverageProvider: 'v8', setupFilesAfterEnv: ['./jest.setup.pg-mock.js', './jest.setup.redis-mock.js', './jest.setup.fetch-mock.js'], - testMatch: ['/tests/**/*.test.ts'], + testMatch: ['/tests/**/*.test.ts', '/benchmarks/**/*.benchmark.ts'], } diff --git a/package.json b/package.json index 74bf706f..bd84941b 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "types": "dist/src/index.d.ts", "main": "dist/src/index.js", "scripts": { - "test": "jest --runInBand", + "test": "jest --testPathIgnorePatterns='benchmarks/'", + "benchmark": "jest --runInBand benchmarks/", "start": "yarn start:dev", "start:dist": "node dist/src/index.js --base-dir ../posthog", "start:dev": "ts-node-dev --exit-child src/index.ts --base-dir ../posthog", From 10cd66902c04d4120d6e980051b031c495672fd0 Mon Sep 17 00:00:00 2001 From: Michael Matloka Date: Thu, 10 Dec 2020 07:22:27 +0100 Subject: [PATCH 2/2] Use Sentence case in step name --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9debc564..90c40a50 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,7 +52,7 @@ jobs: REDIS_URL: 'redis://localhost' run: yarn task:db-init && yarn test - - name: Run Benchmarks + - name: Run benchmarks env: DATABASE_URL: 'postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres' REDIS_URL: 'redis://localhost'