Repository navigation
ci: duration-balanced integration shards, warm desktop-live, CI on every PR #8763
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
3 commits
Select commit
Hold shift + click to select a range
cdb34e8
ci: duration-balanced integration shards, warm desktop-live, CI on ev…
waleedlatif1 d521bda
ci: clear the dev cache by absolute path, always run session cleanup,…
waleedlatif1 74af417
ci: a malformed durations file names its fix, and non-finite weights …
waleedlatif1 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
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,79 @@ | ||
| #!/usr/bin/env bun | ||
| /** | ||
| * Rewrites `vitest.integration-durations.json`, the per-file weights the integration shards are | ||
| * balanced by (`DurationBalancedSequencer` in `vitest.shared.ts`), from a CI run's integration reports. | ||
| * | ||
| * gh run download <run-id> -p 'integration-reports-*' -D /tmp/integration-reports | ||
| * bun run scripts/update-integration-durations.ts /tmp/integration-reports | ||
| * | ||
| * A file's weight is its wall time including the import and collection that precede its first | ||
| * test (the gap since the previous file in the same shard ended), averaged across the push and | ||
| * migrate provisioning runs. apps/sim runs its files one at a time, so those gaps are real shard | ||
| * time; where files overlap, a file counts only its own time. Weights only steer balance; a stale | ||
| * file never changes what runs. | ||
| */ | ||
| import { readdir, readFile, writeFile } from 'node:fs/promises' | ||
| import path from 'node:path' | ||
| import { createLogger } from '@sim/logger' | ||
|
|
||
| interface JsonReport { | ||
| testResults: { name: string; startTime: number; endTime: number }[] | ||
| } | ||
|
|
||
| const logger = createLogger('UpdateIntegrationDurations') | ||
| const REPORT_NAME = 'integration.json' | ||
| const ROOT = path.resolve(import.meta.dir, '..') | ||
| const OUTPUT = path.join(ROOT, 'vitest.integration-durations.json') | ||
|
|
||
| async function findReports(dir: string): Promise<string[]> { | ||
| const entries = await readdir(dir, { withFileTypes: true, recursive: true }) | ||
| return entries | ||
| .filter((entry) => entry.isFile() && entry.name === REPORT_NAME) | ||
| .map((entry) => path.join(entry.parentPath, entry.name)) | ||
| } | ||
|
|
||
| /** `/home/runner/_work/sim/sim/apps/sim/lib/x.integration.ts` → `apps/sim/lib/x.integration.ts` */ | ||
| function repoPath(absolute: string): string | null { | ||
| const match = absolute.match(/\/((?:apps|packages)\/.+)$/) | ||
| return match ? match[1] : null | ||
| } | ||
|
|
||
| const source = process.argv[2] | ||
| if (!source) { | ||
| logger.error('Usage: bun run scripts/update-integration-durations.ts <downloaded-reports-dir>') | ||
| process.exit(1) | ||
| } | ||
|
|
||
| const samples = new Map<string, number[]>() | ||
| const reports = await findReports(path.resolve(source)) | ||
| for (const reportPath of reports) { | ||
| const report = JSON.parse(await readFile(reportPath, 'utf8')) as JsonReport | ||
| const files = [...report.testResults].sort((a, b) => a.startTime - b.startTime) | ||
| let previousEnd = Number.NEGATIVE_INFINITY | ||
| for (const file of files) { | ||
| const key = repoPath(file.name) | ||
| // The gap before a file is its import time only when nothing else was running: in a run | ||
| // with file parallelism (packages/db) files overlap, and a file then counts its own time. | ||
| const start = | ||
| previousEnd > Number.NEGATIVE_INFINITY && previousEnd <= file.startTime | ||
| ? previousEnd | ||
| : file.startTime | ||
| if (key) samples.set(key, [...(samples.get(key) ?? []), (file.endTime - start) / 1000]) | ||
| previousEnd = Math.max(previousEnd, file.endTime) | ||
| } | ||
| } | ||
|
|
||
| if (samples.size === 0) { | ||
| logger.error(`No ${REPORT_NAME} reports with test results under ${source}`) | ||
| process.exit(1) | ||
| } | ||
|
|
||
| const durations = Object.fromEntries( | ||
| [...samples.keys()].sort().map((key) => { | ||
| const values = samples.get(key) ?? [] | ||
| const mean = values.reduce((sum, value) => sum + value, 0) / values.length | ||
| return [key, Math.round(mean * 10) / 10] | ||
| }) | ||
| ) | ||
| await writeFile(OUTPUT, `${JSON.stringify(durations, null, 2)}\n`) | ||
| logger.info(`Wrote ${samples.size} file weights from ${reports.length} reports to ${OUTPUT}`) |
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.