Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion scripts/fetch-test-timing.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
// existing CODECOV_TOKEN secret -- that one is an upload-only token and doesn't authenticate this read
// API. Codecov's docs don't publish a numeric rate limit for this endpoint, so this is deliberately run
// on a schedule (test-timing-refresh.yml), not per-PR.
//
// Uses /test-analytics/, not /test-results/: the latter is now deprecated (confirmed by actually
// running this script -- Codecov returns a 301 with "This endpoint has been deprecated. Please use
// /test-analytics/ instead."). Verified via Codecov's live OpenAPI schema (api.codecov.io/api/v2/schema/)
// that /test-analytics/ returns the identical PaginatedTestrunList wrapper and Testrun field shape
// (filename, duration_seconds, commit_sha, etc.) -- a URL rename, not a schema change, so nothing else
// in this file needed to change.

import { writeFileSync } from "node:fs";

Expand Down Expand Up @@ -47,7 +54,7 @@ async function fetchWithRetry(url, maxAttempts = 4) {

async function fetchAllTestRuns() {
const rows = [];
let url = `https://api.codecov.io/api/v2/gh/${owner}/repos/${repoName}/test-results/?branch=main&page_size=100`;
let url = `https://api.codecov.io/api/v2/gh/${owner}/repos/${repoName}/test-analytics/?branch=main&page_size=100`;
let pages = 0;
while (url && pages < MAX_PAGES) {
const body = await fetchWithRetry(url);
Expand Down