-
Notifications
You must be signed in to change notification settings - Fork 2
test(app): add PR0.2 perf comparator gate #608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1e02d8e
test(app): add perf comparator rules and tests
Astro-Han f9c26c0
test(app): tag perf runs as base/head and add cooldown
Astro-Han 183108e
ci(app): compare perf baseline between base and head on same runner
Astro-Han 914eaba
ci(app): run base perf with head harness
Astro-Han File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ on: | |
| - "packages/app/e2e/perf/**" | ||
| - "packages/app/e2e/fixtures.ts" | ||
| - "packages/app/package.json" | ||
| - "packages/app/script/compare-perf.ts" | ||
| - "packages/app/script/e2e-local.ts" | ||
| - "packages/app/src/testing/perf-metrics*" | ||
| workflow_dispatch: | ||
|
|
@@ -18,11 +19,20 @@ jobs: | |
| perf-probe-baseline: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| env: | ||
| PERF_ARTIFACT_DIR: ${{ github.workspace }}/perf-artifacts | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # actions/checkout@v6 | ||
| with: | ||
| path: head | ||
| persist-credentials: false | ||
|
|
||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # actions/checkout@v6 | ||
| with: | ||
| path: base | ||
| persist-credentials: false | ||
| ref: ${{ github.event.pull_request.base.sha || github.sha }} | ||
|
|
||
| - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # actions/[email protected] | ||
| with: | ||
| node-version: "24" | ||
|
|
@@ -34,25 +44,52 @@ jobs: | |
| - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # actions/cache@v5 | ||
| with: | ||
| path: ~/.bun/install/cache | ||
| key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }} | ||
| key: bun-${{ runner.os }}-${{ hashFiles('head/bun.lock', 'base/bun.lock') }} | ||
| restore-keys: | | ||
| bun-${{ runner.os }}- | ||
|
|
||
| - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # actions/cache@v5 | ||
| with: | ||
| path: ${{ github.workspace }}/.playwright-browsers | ||
| key: playwright-${{ runner.os }}-${{ hashFiles('packages/app/package.json', 'bun.lock') }} | ||
| key: playwright-${{ runner.os }}-${{ hashFiles('head/packages/app/package.json', 'head/bun.lock', 'base/packages/app/package.json', 'base/bun.lock') }} | ||
|
|
||
| - name: Install head dependencies | ||
| working-directory: head | ||
| run: bun install --frozen-lockfile | ||
|
|
||
| - run: bun install --frozen-lockfile | ||
| - name: Install base dependencies | ||
| working-directory: base | ||
| run: bun install --frozen-lockfile | ||
|
|
||
| - name: Install Playwright browsers | ||
| working-directory: packages/app | ||
| working-directory: head/packages/app | ||
| run: bunx playwright install --with-deps chromium | ||
|
|
||
| - name: Run perf probe baseline | ||
| - name: Sync perf harness into base checkout | ||
| run: | | ||
| rsync -a --delete head/packages/app/e2e/perf/ base/packages/app/e2e/perf/ | ||
| cp head/packages/app/src/testing/perf-metrics.ts base/packages/app/src/testing/perf-metrics.ts | ||
|
|
||
| - name: Run perf probe baseline (base) | ||
| env: | ||
| CI: "true" | ||
| run: bun --cwd packages/app test:e2e:local:perf | ||
| PAWWORK_PERF_BRANCH: base | ||
| PAWWORK_PERF_OUTPUT: ${{ github.workspace }}/perf-artifacts/perf-base.json | ||
| run: bun --cwd base/packages/app test:e2e:local:perf | ||
|
|
||
| - name: Run perf probe baseline (head) | ||
| env: | ||
| CI: "true" | ||
| PAWWORK_PERF_BRANCH: head | ||
| PAWWORK_PERF_OUTPUT: ${{ github.workspace }}/perf-artifacts/perf-head.json | ||
| run: bun --cwd head/packages/app test:e2e:local:perf | ||
|
|
||
| - name: Compare base and head perf baselines | ||
| run: > | ||
| bun head/packages/app/script/compare-perf.ts | ||
| --base "${PERF_ARTIFACT_DIR}/perf-base.json" | ||
| --head "${PERF_ARTIFACT_DIR}/perf-head.json" | ||
| --output "${PERF_ARTIFACT_DIR}/perf-compare.json" | ||
|
|
||
| - name: Upload perf probe artifacts | ||
| if: always() | ||
|
|
@@ -62,6 +99,8 @@ jobs: | |
| if-no-files-found: ignore | ||
| retention-days: 7 | ||
| path: | | ||
| packages/app/e2e/perf-results | ||
| packages/app/e2e/playwright-report | ||
| packages/app/e2e/test-results | ||
| perf-artifacts | ||
| base/packages/app/e2e/playwright-report | ||
| base/packages/app/e2e/test-results | ||
| head/packages/app/e2e/playwright-report | ||
| head/packages/app/e2e/test-results | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import fs from "node:fs/promises" | ||
| import path from "node:path" | ||
| import { comparePerfBaselines, type PerfScenarioSummary } from "../src/testing/perf-metrics" | ||
|
|
||
| function readArg(flag: string) { | ||
| const index = process.argv.indexOf(flag) | ||
| if (index === -1) return undefined | ||
| const value = process.argv[index + 1] | ||
| if (!value || value.startsWith("--")) return undefined | ||
| return value | ||
| } | ||
|
|
||
| async function readPerfFile(filePath: string) { | ||
| const payload = JSON.parse(await fs.readFile(filePath, "utf8")) as PerfScenarioSummary[] | ||
| if (!Array.isArray(payload)) { | ||
| throw new Error(`Expected an array of perf scenarios in ${filePath}`) | ||
| } | ||
| return payload | ||
| } | ||
|
|
||
| async function main() { | ||
| const basePath = readArg("--base") | ||
| const headPath = readArg("--head") | ||
| const outputPath = readArg("--output") | ||
|
|
||
| if (!basePath || !headPath) { | ||
| throw new Error("Usage: bun script/compare-perf.ts --base <perf-base.json> --head <perf-head.json> [--output <path>]") | ||
| } | ||
|
|
||
| const [base, head] = await Promise.all([readPerfFile(basePath), readPerfFile(headPath)]) | ||
| const comparison = comparePerfBaselines({ base, head }) | ||
|
|
||
| if (outputPath) { | ||
| await fs.mkdir(path.dirname(outputPath), { recursive: true }) | ||
| await fs.writeFile(outputPath, `${JSON.stringify(comparison, null, 2)}\n`) | ||
| } | ||
|
|
||
| const summary = { | ||
| pass: comparison.pass, | ||
| failures: comparison.failures, | ||
| warnings: comparison.warnings, | ||
| } | ||
| console.log(JSON.stringify(summary, null, 2)) | ||
|
|
||
| if (!comparison.pass) { | ||
| process.exitCode = 1 | ||
| } | ||
| } | ||
|
|
||
| await main() | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.