Skip to content

Mention infra failures and still report results when they occur #107

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 1 commit into from
Apr 3, 2023
Merged
Changes from all commits
Commits
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
29 changes: 20 additions & 9 deletions src/postGithubComments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let newTscResolvedVersion: string | undefined;
let oldTscResolvedVersion: string | undefined;

let somethingChanged = false;
let infrastructureFailed = false;
const infrastructureFailures = new Map<RepoStatus, number>();

for (const path of metadataFilePaths) {
const metadata: Metadata = JSON.parse(fs.readFileSync(path, { encoding: "utf-8" }));
Expand All @@ -38,21 +38,32 @@ for (const path of metadataFilePaths) {
somethingChanged = true;
break;
default:
infrastructureFailed = true;
infrastructureFailures.set(status, (infrastructureFailures.get(status) ?? 0) + 1)
break;
}
}
}

let summary: string;
if (somethingChanged && (isTopReposRun || !infrastructureFailed)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me way too long to understand the meaning of this logic, so I've simplified things down to make it clear that the intent was to not report infra failures for top-repos runs.

summary = `Something interesting changed - please have a look.`;
const summary: string[] = [];

// In a top-repos run, the test set is arbitrary, so we ignore infrastructure failures
// as it's possible that there's a repo that just doesn't work.
if (!isTopReposRun && infrastructureFailures.size) {
summary.push("There were infrastructure failures potentially unrelated to your change:");
summary.push("");
for (const [status, count] of infrastructureFailures) {
summary.push(`- ${count} ${count === 1 ? "instance" : "instances"} of "${status}"`);
}
summary.push("");
summary.push("Otherwise...");
summary.push("");
}
else if (infrastructureFailed && !isTopReposRun) {
summary = `Unfortunately, something went wrong, but it probably wasn't caused by your change.`;

if (somethingChanged) {
summary.push("Something interesting changed - please have a look.");
}
else {
summary = `Everything looks good!`;
summary.push("Everything looks good!");
}

const resultPaths = pu.glob(resultDirPath, `**/*.${resultFileNameSuffix}`).sort((a, b) => path.basename(a).localeCompare(path.basename(b)));
Expand All @@ -61,7 +72,7 @@ const outputs = resultPaths.map(p => fs.readFileSync(p, { encoding: "utf-8" }).r
const suiteDescription = isTopReposRun ? "top-repos" : "user test";
let header = `@${userToTag} Here are the results of running the ${suiteDescription} suite comparing \`${oldTscResolvedVersion}\` and \`${newTscResolvedVersion}\`:

${summary}`;
${summary.join("\n")}`;

if (!outputs.length) {
git.createComment(+prNumber, +commentNumber, postResult, [header]);
Expand Down