Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

devops: download the snapshot before updating a missing database (#43514)

Dmitry Gozman91a0fc5301bc
diff --git a/.claude/skills/playwright-test-results/SKILL.md b/.claude/skills/playwright-test-results/SKILL.md
index 0e08d94779..d2bb970d80 100644
--- a/.claude/skills/playwright-test-results/SKILL.md
+++ b/.claude/skills/playwright-test-results/SKILL.md
@@ -12,19 +12,19 @@ refreshed every few hours.
## Get the database
-Download the latest snapshot:
+Download the latest snapshot and top it up with the newest runs:
```bash
npm ci # first time only, from the repo root
-GITHUB_TOKEN=$(gh auth token) node utils/test-results-db/cli.ts download
-```
-
-The snapshot may be missing the newest runs. To top it up locally, run `update`:
-
-```bash
GITHUB_TOKEN=$(gh auth token) node utils/test-results-db/cli.ts update --lookback-days 3
```
+`update` downloads the snapshot first when there is no local database, then
+ingests only the artifacts the snapshot lacks. Never delete the database to
+rebuild it: every artifact costs one GitHub API request, the budget is shared
+by every workflow in the repository, and a rebuild of a few days exhausts it.
+To only refresh the snapshot without ingesting, run `download`.
+
Query it through the bundled `@duckdb/node-api` binding — no separate DuckDB
install needed, it ships in `node_modules` after `npm ci`:
diff --git a/utils/test-results-db/cli.ts b/utils/test-results-db/cli.ts
index 0de09e560a..e96d40e47b 100644
--- a/utils/test-results-db/cli.ts
+++ b/utils/test-results-db/cli.ts
@@ -30,6 +30,7 @@ Commands:
download Fetch the latest maintained database artifact.
Starts a fresh database if none exists yet.
update [options] Ingest parquet artifacts that aren't in the database yet.
+ Downloads the latest database artifact first if there is none locally.
--lookback-days <n> How many days back to scan (default 7).
--concurrency <n> Parallel downloads and listings per batch (default 16).
truncate --max-runs <n> Keep only the newest <n> runs, delete the rest, compact.
diff --git a/utils/test-results-db/update.ts b/utils/test-results-db/update.ts
index 73bd511217..803cc0945e 100644
--- a/utils/test-results-db/update.ts
+++ b/utils/test-results-db/update.ts
@@ -19,6 +19,7 @@ import os from 'os';
import path from 'path';
import { TestResultsDb, fileSize, formatBytes } from './db.ts';
+import { cmdDownload } from './download.ts';
import { GitHubClient, chunk, extractSingle } from './github.ts';
const PARQUET_ARTIFACT_PREFIX = 'parquet-report-';
@@ -38,6 +39,9 @@ export type UpdateOptions = {
// then ingested serially on the single connection and its temp files removed,
// so disk usage stays bounded to one batch.
export async function cmdUpdate(dbPath: string, token: string, options: UpdateOptions): Promise<void> {
+ if (!fs.existsSync(dbPath))
+ await cmdDownload(dbPath, token);
+
const github = new GitHubClient(token);
const db = await TestResultsDb.open(dbPath);
try {