Skip to content

Commit 8567cbe

Browse files
authored
Mention infra failures and still report results when they occur (#107)
1 parent dd74c5f commit 8567cbe

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

src/postGithubComments.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ let newTscResolvedVersion: string | undefined;
2121
let oldTscResolvedVersion: string | undefined;
2222

2323
let somethingChanged = false;
24-
let infrastructureFailed = false;
24+
const infrastructureFailures = new Map<RepoStatus, number>();
2525

2626
for (const path of metadataFilePaths) {
2727
const metadata: Metadata = JSON.parse(fs.readFileSync(path, { encoding: "utf-8" }));
@@ -38,21 +38,32 @@ for (const path of metadataFilePaths) {
3838
somethingChanged = true;
3939
break;
4040
default:
41-
infrastructureFailed = true;
41+
infrastructureFailures.set(status, (infrastructureFailures.get(status) ?? 0) + 1)
4242
break;
4343
}
4444
}
4545
}
4646

47-
let summary: string;
48-
if (somethingChanged && (isTopReposRun || !infrastructureFailed)) {
49-
summary = `Something interesting changed - please have a look.`;
47+
const summary: string[] = [];
48+
49+
// In a top-repos run, the test set is arbitrary, so we ignore infrastructure failures
50+
// as it's possible that there's a repo that just doesn't work.
51+
if (!isTopReposRun && infrastructureFailures.size) {
52+
summary.push("There were infrastructure failures potentially unrelated to your change:");
53+
summary.push("");
54+
for (const [status, count] of infrastructureFailures) {
55+
summary.push(`- ${count} ${count === 1 ? "instance" : "instances"} of "${status}"`);
56+
}
57+
summary.push("");
58+
summary.push("Otherwise...");
59+
summary.push("");
5060
}
51-
else if (infrastructureFailed && !isTopReposRun) {
52-
summary = `Unfortunately, something went wrong, but it probably wasn't caused by your change.`;
61+
62+
if (somethingChanged) {
63+
summary.push("Something interesting changed - please have a look.");
5364
}
5465
else {
55-
summary = `Everything looks good!`;
66+
summary.push("Everything looks good!");
5667
}
5768

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

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

0 commit comments

Comments
 (0)