Skip to content
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

fix: log test processing error #12

Merged
merged 1 commit into from
Jan 13, 2025
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
77 changes: 41 additions & 36 deletions src/cli/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,47 +46,52 @@ export async function run(opts_: FileCollectionOptions & StorageOptions & Benchm
process.exit(1);
}

const runner = new BenchmarkRunner({prevBench, benchmarkOpts: opts});
const results = await runner.process(files);
try {
const runner = new BenchmarkRunner({prevBench, benchmarkOpts: opts});
const results = await runner.process(files);

if (results.length === 0) {
throw Error("No benchmark result was produced");
}
if (results.length === 0) {
throw Error("No benchmark result was produced");
}

const currentCommit = await getCurrentCommitInfo();
const currBench: Benchmark = {
commitSha: currentCommit.commitSha,
results,
};
const currentCommit = await getCurrentCommitInfo();
const currBench: Benchmark = {
commitSha: currentCommit.commitSha,
results,
};

// Persist new benchmark data
const currentBranch = await getCurrentBranch();
const shouldPersist = await resolveShouldPersist(opts, currentBranch);
if (shouldPersist === true) {
const branch =
currentCommit.branch ??
parseBranchFromRef(
github.context.ref ?? (await shell("git symbolic-ref HEAD")),
historyProvider.type === HistoryProviderType.Local
);
consoleLog(`Persisting new benchmark data for branch '${branch}' commit '${currBench.commitSha}'`);
// TODO: prune and limit total entries
// appendBenchmarkToHistoryAndPrune(history, currBench, branch, opts);
await historyProvider.writeLatestInBranch(branch, currBench);
await historyProvider.writeToHistory(currBench);
}
// Persist new benchmark data
const currentBranch = await getCurrentBranch();
const shouldPersist = await resolveShouldPersist(opts, currentBranch);
if (shouldPersist === true) {
const branch =
currentCommit.branch ??
parseBranchFromRef(
github.context.ref ?? (await shell("git symbolic-ref HEAD")),
historyProvider.type === HistoryProviderType.Local
);
consoleLog(`Persisting new benchmark data for branch '${branch}' commit '${currBench.commitSha}'`);
// TODO: prune and limit total entries
// appendBenchmarkToHistoryAndPrune(history, currBench, branch, opts);
await historyProvider.writeLatestInBranch(branch, currBench);
await historyProvider.writeToHistory(currBench);
}

const resultsComp = computePerformanceReport(currBench, prevBench, opts.threshold);
const resultsComp = computePerformanceReport(currBench, prevBench, opts.threshold);

if (!opts.skipPostComment && isGaRun()) {
await postGaComment({
commentBody: performanceReportComment(resultsComp),
tag: GithubCommentTag.PerformanceReport,
commentOnPush: resultsComp.someFailed,
});
}
if (!opts.skipPostComment && isGaRun()) {
await postGaComment({
commentBody: performanceReportComment(resultsComp),
tag: GithubCommentTag.PerformanceReport,
commentOnPush: resultsComp.someFailed,
});
}

if (resultsComp.someFailed && !opts.noThrow) {
throw Error("Performance regression");
if (resultsComp.someFailed && !opts.noThrow) {
throw Error("Performance regression");
}
} catch (err) {
consoleLog(`Error processing benchmark files. ${(err as Error).message}`);
throw err;
}
}
Loading