Skip to content
Merged
Show file tree
Hide file tree
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
15 changes: 8 additions & 7 deletions src/utils/roll-spec-weights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,19 @@ export async function computeRefresh(
const runs: Weights[] = [];
const usedRunIds: number[] = [];
for (const runId of runIds) {
let jobs: JobTimings[];
let run: Weights;
try {
jobs = await fetchRunTimings(octokit, runId);
const jobs = await fetchRunTimings(octokit, runId);
if (!jobs.length) {
d(`run ${runId} has no timing artifacts (expired?) - ignoring`);
continue;
}
run = aggregateRun(jobs);
} catch (e) {
d(`run ${runId}: could not read its timing artifacts (${e.message}) - ignoring`);
continue;
}
if (!jobs.length) {
d(`run ${runId} has no timing artifacts (expired?) - ignoring`);
continue;
}
runs.push(aggregateRun(jobs));
runs.push(run);
usedRunIds.push(runId);
}
if (!runs.length) {
Expand Down
6 changes: 5 additions & 1 deletion src/utils/spec-weights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,11 @@ export function timingsFromArtifactZip(zip: Buffer): SpecTimings[] {
const data = zip.subarray(dataStart, dataStart + compressedSize);
const raw = method === 0 ? data : method === 8 ? inflateRawSync(data) : null;
if (!raw) throw new Error(`unsupported zip compression method ${method} for ${name}`);
found.push(JSON.parse(raw.toString('utf8')));
const timings = JSON.parse(raw.toString('utf8'));
if (!timings || typeof timings.files !== 'object' || timings.files === null) {
throw new Error(`${name} carries no per-file timings`);
}
found.push(timings);
}
return found;
}
Binary file not shown.
5 changes: 5 additions & 0 deletions tests/utils/spec-weights.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ describe('spec-weights', () => {
expect(timings[0].files['spec/api-browser-window-spec.ts']).toBeCloseTo(364.971, 3);
});

it('rejects a timings file with no per-file data', () => {
const zip = readFileSync(join(fixtures, 'test_artifacts_truncated_1.zip'));
expect(() => timingsFromArtifactZip(zip)).toThrow(/no per-file timings/);
});

it('rejects something that is not a zip', () => {
expect(() => timingsFromArtifactZip(Buffer.from('nope'))).toThrow(/not a zip/);
});
Expand Down