Skip to content

Commit fc1452c

Browse files
authored
[summarize-checks] Only set status=success if requirementsMet=true (#36609)
- add a new test case for completed FYI, incomplete required, no assessment - we shouldn't acccidentally set to SUCCESS when dealing with only completed FYI, when we don't yet know the target branch
1 parent ba99bee commit fc1452c

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

.github/workflows/src/summarize-checks/summarize-checks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ function getCommentBody(
10111011

10121012
if (anyFyiPresent) {
10131013
bodyProper += getFyiPresentBody(failingFyiChecksInfo);
1014-
if (!anyBlockerPresent) {
1014+
if (!anyBlockerPresent && requirementsMet) {
10151015
bodyProper += `If you still want to proceed merging this PR without addressing the above failures, ${diagramTsg(4, false)}.`;
10161016
summaryData =
10171017
`⚠️ Some important automated merging requirements have failed. As of today you can still merge this PR, ` +

.github/workflows/test/summarize-checks/summarize-checks.test.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,65 @@ describe("Summarize Checks Unit Tests", () => {
704704
expect(output).toEqual(expectedOutput);
705705
});
706706

707+
it("should generate pending summary when checks there are no required checks blocking or completed, but successful FYI checks", async () => {
708+
const repo = "azure-rest-api-specs";
709+
const targetBranch = "main";
710+
const labelNames = [
711+
"ARMReview",
712+
"ARMAutoSignedOff",
713+
"resource-manager",
714+
"TypeSpec",
715+
"RPaaS",
716+
"ARMSignedOff",
717+
"PublishToCustomers",
718+
];
719+
const expectedOutput = [
720+
`<h2>Next Steps to Merge</h2>Important checks have failed. As of today they are not blocking this PR, but in near future they may.<br/>Addressing the following failures is highly recommended:<br/><ul><li>⚠️ The check named <code>Swagger LintDiff</code> has failed. Refer to the check in the PR's 'Checks' tab for details on how to fix it and consult the <a href="https://aka.ms/ci-fix">aka.ms/ci-fix</a> guide</li></ul><br /><br />Comment generated by <a href="http://github.com/a/fake/workflowrun/url">summarize-checks</a> workflow run.`,
721+
{
722+
name: "[TEST-IGNORE] Automated merging requirements met",
723+
result: "pending",
724+
summary: "The requirements for merging this PR are still being evaluated. Please wait.",
725+
},
726+
];
727+
728+
const fyiCheckRuns = [
729+
{
730+
name: "Swagger BreakingChange",
731+
status: "COMPLETED",
732+
conclusion: "SUCCESS",
733+
checkInfo: getCheckInfo("Swagger BreakingChange"),
734+
},
735+
{
736+
name: "Swagger LintDiff",
737+
status: "COMPLETED",
738+
conclusion: "FAILURE",
739+
checkInfo: getCheckInfo("Swagger LintDiff"),
740+
},
741+
];
742+
743+
const requiredCheckRuns = [
744+
{
745+
name: "Summarize PR Impact",
746+
status: "IN_PROGRESS",
747+
conclusion: null,
748+
checkInfo: getCheckInfo("Summarize PR Impact"),
749+
},
750+
];
751+
752+
const output = await createNextStepsComment(
753+
mockCore,
754+
repo,
755+
labelNames,
756+
targetBranch,
757+
requiredCheckRuns,
758+
fyiCheckRuns,
759+
false, // assessmentCompleted
760+
WORKFLOW_URL,
761+
);
762+
763+
expect(output).toEqual(expectedOutput);
764+
});
765+
707766
it("Should generate error summary for a PR scenario with labeling issues", async () => {
708767
const repo = "azure-rest-api-specs";
709768
const targetBranch = "main";

0 commit comments

Comments
 (0)