Skip to content

Commit af8eab5

Browse files
authored
[summarize-checks] Switch to GitHub Actions (#36570)
1 parent 5470a13 commit af8eab5

11 files changed

+84
-141
lines changed

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

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
*/
2020

2121
// #region imports/constants
22-
import { extractInputs } from "../context.js";
23-
// import { commentOrUpdate } from "../comment.js";
2422
import { execFile } from "../../../shared/src/exec.js";
2523
import { CheckConclusion, PER_PAGE_MAX } from "../../../shared/src/github.js";
2624
import { intersect } from "../../../shared/src/set.js";
2725
import { byDate, invert } from "../../../shared/src/sort.js";
26+
import { commentOrUpdate } from "../comment.js";
27+
import { extractInputs } from "../context.js";
2828
import {
2929
brChRevApproval,
3030
getViolatedRequiredLabelsRules,
@@ -141,7 +141,8 @@ const FYI_CHECK_NAMES = [
141141
"Swagger BreakingChange",
142142
"Swagger PrettierCheck",
143143
];
144-
const AUTOMATED_CHECK_NAME = "[TEST-IGNORE] Automated merging requirements met";
144+
const AUTOMATED_CHECK_NAME = "Automated merging requirements met";
145+
const IMPACT_CHECK_NAME = "Summarize PR Impact";
145146
const NEXT_STEPS_COMMENT_ID = "NextStepsToMerge";
146147

147148
/** @type {CheckMetadata[]} */
@@ -403,24 +404,24 @@ export async function summarizeChecksImpl(
403404

404405
for (const label of labelContext.toRemove) {
405406
core.info(`Removing label: ${label} from ${owner}/${repo}#${issue_number}.`);
406-
// await github.rest.issues.removeLabel({
407-
// owner: owner,
408-
// repo: repo,
409-
// issue_number: issue_number,
410-
// name: label,
411-
// });
407+
await github.rest.issues.removeLabel({
408+
owner: owner,
409+
repo: repo,
410+
issue_number: issue_number,
411+
name: label,
412+
});
412413
}
413414

414415
if (labelContext.toAdd.size > 0) {
415416
core.info(
416417
`Adding labels: ${Array.from(labelContext.toAdd).join(", ")} to ${owner}/${repo}#${issue_number}.`,
417418
);
418-
// await github.rest.issues.addLabels({
419-
// owner: owner,
420-
// repo: repo,
421-
// issue_number: issue_number,
422-
// labels: Array.from(labelContext.toAdd),
423-
// });
419+
await github.rest.issues.addLabels({
420+
owner: owner,
421+
repo: repo,
422+
issue_number: issue_number,
423+
labels: Array.from(labelContext.toAdd),
424+
});
424425
}
425426

426427
// adjust labelNames based on labelsToAdd/labelsToRemove
@@ -451,20 +452,21 @@ export async function summarizeChecksImpl(
451452
core.summary.write();
452453

453454
// this will remain commented until we're comfortable with the change.
454-
// await commentOrUpdate(
455-
// { github, context, core },
456-
// owner,
457-
// repo,
458-
// issue_number,
459-
// commentName,
460-
// commentBody
461-
// )
455+
await commentOrUpdate(
456+
github,
457+
core,
458+
owner,
459+
repo,
460+
issue_number,
461+
commentBody,
462+
NEXT_STEPS_COMMENT_ID,
463+
);
462464

463465
// finally, update the "Automated merging requirements met" commit status
464466
await updateCommitStatus(github, core, owner, repo, head_sha, automatedChecksMet);
465467

466468
core.info(
467-
`Summarize checks has identified that status of "[TEST-IGNORE] Automated merging requirements met" commit status should be updated to: ${JSON.stringify(automatedChecksMet)}.`,
469+
`Summarize checks has identified that status of "${AUTOMATED_CHECK_NAME}" commit status should be updated to: ${JSON.stringify(automatedChecksMet)}.`,
468470
);
469471
core.summary.addHeading("Automated Checks Met", 2);
470472
core.summary.addCodeBlock(JSON.stringify(automatedChecksMet, null, 2));
@@ -517,9 +519,6 @@ export async function updateCommitStatus(github, core, owner, repo, head_sha, ch
517519
* @param {string} owner
518520
* @param {string} repo
519521
* @param {number} issue_number
520-
* @param {*} owner
521-
* @param {*} repo
522-
* @param {*} issue_number
523522
* @return {Promise<string[]>}
524523
*/
525524
export async function getExistingLabels(github, owner, repo, issue_number) {
@@ -731,10 +730,8 @@ export async function getCheckRunTuple(
731730

732731
const latestCheck = sortedChecks[0];
733732

734-
// just handling both names for ease of integration testing
735733
if (
736-
(latestCheck.name === "[TEST-IGNORE] Summarize PR Impact" ||
737-
latestCheck.name === "Summarize PR Impact") &&
734+
latestCheck.name === IMPACT_CHECK_NAME &&
738735
latestCheck.status === "completed" &&
739736
latestCheck.conclusion === "success"
740737
) {
@@ -805,7 +802,7 @@ export async function getCheckRunTuple(
805802
);
806803
}
807804
} else {
808-
requiredCheckNames = ["Summarize PR Impact", "[TEST-IGNORE] Summarize PR Impact"];
805+
requiredCheckNames = [IMPACT_CHECK_NAME];
809806
}
810807

811808
const filteredReqCheckRuns = unifiedCheckRuns.filter(

.github/workflows/summarize-checks.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
name: "[TEST-IGNORE] Summarize Checks"
1+
name: "Summarize Checks"
22

33
on:
44
workflow_run:
55
workflows:
6-
- "\\[TEST-IGNORE\\] Swagger SemanticValidation - Set Status"
7-
- "\\[TEST-IGNORE\\] Swagger ModelValidation - Set Status"
8-
- "\\[TEST-IGNORE\\] Summarize PR Impact"
6+
- "Swagger SemanticValidation - Set Status"
7+
- "Swagger ModelValidation - Set Status"
8+
- "Summarize PR Impact"
99
- "Swagger Avocado - Set Status"
1010
- "Swagger LintDiff - Set Status"
1111
- "SDK Validation Status"
@@ -34,7 +34,7 @@ permissions:
3434
jobs:
3535
run-summarize-checks:
3636
if: ${{ github.event_name == 'pull_request_target' || github.event.workflow_run.conclusion != 'skipped' }}
37-
name: "[TEST-IGNORE] Summarize Checks"
37+
name: "Summarize Checks"
3838
runs-on: ubuntu-24.04
3939

4040
steps:

.github/workflows/summarize-impact.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "[TEST-IGNORE] Summarize PR Impact"
1+
name: "Summarize PR Impact"
22

33
on:
44
pull_request:
@@ -16,7 +16,7 @@ permissions:
1616

1717
jobs:
1818
impact:
19-
name: "[TEST-IGNORE] Summarize PR Impact"
19+
name: "Summarize PR Impact"
2020
runs-on: ubuntu-24.04
2121

2222
steps:

.github/workflows/swagger-modelvalidation-code.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "[TEST-IGNORE] Swagger ModelValidation - Analyze Code"
1+
name: "Swagger ModelValidation - Analyze Code"
22

33
on: pull_request
44

@@ -7,7 +7,7 @@ permissions:
77

88
jobs:
99
oav:
10-
name: "[TEST-IGNORE] Swagger ModelValidation - Analyze Code"
10+
name: "Swagger ModelValidation - Analyze Code"
1111
runs-on: ubuntu-24.04
1212

1313
steps:

.github/workflows/swagger-modelvalidation-status.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "[TEST-IGNORE] Swagger ModelValidation - Set Status"
1+
name: "Swagger ModelValidation - Set Status"
22

33
on:
44
# Must run on pull_request_target instead of pull_request, since the latter cannot trigger on
@@ -15,7 +15,7 @@ on:
1515
- labeled
1616
- unlabeled
1717
workflow_run:
18-
workflows: ["\\[TEST-IGNORE\\] Swagger ModelValidation - Analyze Code"]
18+
workflows: ["Swagger ModelValidation - Analyze Code"]
1919
types: [completed]
2020

2121
permissions:
@@ -30,6 +30,6 @@ jobs:
3030
name: Set ModelValidation Status
3131
uses: ./.github/workflows/_reusable-set-check-status.yaml
3232
with:
33-
monitored_workflow_name: "[TEST-IGNORE] Swagger ModelValidation - Analyze Code"
34-
required_check_name: "[TEST-IGNORE] Swagger ModelValidation"
33+
monitored_workflow_name: "Swagger ModelValidation - Analyze Code"
34+
required_check_name: "Swagger ModelValidation"
3535
overriding_label: "Approved-ModelValidation"

.github/workflows/swagger-semanticvalidation-code.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "[TEST-IGNORE] Swagger SemanticValidation - Analyze Code"
1+
name: "Swagger SemanticValidation - Analyze Code"
22

33
on: pull_request
44

@@ -7,7 +7,7 @@ permissions:
77

88
jobs:
99
oav:
10-
name: "[TEST-IGNORE] Swagger SemanticValidation - Analyze Code"
10+
name: "Swagger SemanticValidation - Analyze Code"
1111
runs-on: ubuntu-24.04
1212

1313
steps:

.github/workflows/swagger-semanticvalidation-status.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "[TEST-IGNORE] Swagger SemanticValidation - Set Status"
1+
name: "Swagger SemanticValidation - Set Status"
22

33
on:
44
# Must run on pull_request_target instead of pull_request, since the latter cannot trigger on
@@ -15,7 +15,7 @@ on:
1515
- labeled
1616
- unlabeled
1717
workflow_run:
18-
workflows: ["\\[TEST-IGNORE\\] Swagger SemanticValidation - Analyze Code"]
18+
workflows: ["Swagger SemanticValidation - Analyze Code"]
1919
types: [completed]
2020

2121
permissions:
@@ -30,6 +30,6 @@ jobs:
3030
name: Set SemanticValidation Status
3131
uses: ./.github/workflows/_reusable-set-check-status.yaml
3232
with:
33-
monitored_workflow_name: "[TEST-IGNORE] Swagger SemanticValidation - Analyze Code"
34-
required_check_name: "[TEST-IGNORE] Swagger SemanticValidation"
33+
monitored_workflow_name: "Swagger SemanticValidation - Analyze Code"
34+
required_check_name: "Swagger SemanticValidation"
3535
overriding_label: "Approved-SemanticValidation"

.github/workflows/test/set-status.test.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ describe("setStatusImpl", () => {
7272
target_url: "https://test.com/set_status_url",
7373
github,
7474
core,
75-
monitoredWorkflowName: "[TEST-IGNORE] Swagger Avocado - Analyze Code",
76-
requiredStatusName: "[TEST-IGNORE] Swagger Avocado",
75+
monitoredWorkflowName: "Swagger Avocado - Analyze Code",
76+
requiredStatusName: "Swagger Avocado",
7777
overridingLabel: "Approved-Avocado",
7878
}),
7979
).resolves.toBeUndefined();
@@ -83,7 +83,7 @@ describe("setStatusImpl", () => {
8383
repo: "test-repo",
8484
sha: fullGitSha,
8585
state: CommitStatusState.SUCCESS,
86-
context: "[TEST-IGNORE] Swagger Avocado",
86+
context: "Swagger Avocado",
8787
description: "Found label 'Approved-Avocado'",
8888
target_url: "https://test.com/set_status_url",
8989
});
@@ -103,8 +103,8 @@ describe("setStatusImpl", () => {
103103
target_url: "https://test.com/set_status_url",
104104
github,
105105
core,
106-
monitoredWorkflowName: "[TEST-IGNORE] Swagger BreakingChange - Analyze Code",
107-
requiredStatusName: "[TEST-IGNORE] Swagger BreakingChange",
106+
monitoredWorkflowName: "Swagger BreakingChange - Analyze Code",
107+
requiredStatusName: "Swagger BreakingChange",
108108
overridingLabel:
109109
"BreakingChange-Approved-Benign,BreakingChange-Approved-BugFix,BreakingChange-Approved-UserImpact",
110110
}),
@@ -115,7 +115,7 @@ describe("setStatusImpl", () => {
115115
repo: "test-repo",
116116
sha: fullGitSha,
117117
state: CommitStatusState.SUCCESS,
118-
context: "[TEST-IGNORE] Swagger BreakingChange",
118+
context: "Swagger BreakingChange",
119119
description: "Found label 'BreakingChange-Approved-Benign'",
120120
target_url: "https://test.com/set_status_url",
121121
});
@@ -138,8 +138,8 @@ describe("setStatusImpl", () => {
138138
target_url: "https://test.com/set_status_url",
139139
github,
140140
core,
141-
monitoredWorkflowName: "[TEST-IGNORE] Swagger BreakingChange - Analyze Code",
142-
requiredStatusName: "[TEST-IGNORE] Swagger BreakingChange",
141+
monitoredWorkflowName: "Swagger BreakingChange - Analyze Code",
142+
requiredStatusName: "Swagger BreakingChange",
143143
overridingLabel:
144144
"BreakingChange-Approved-Benign, BreakingChange-Approved-BugFix , BreakingChange-Approved-UserImpact",
145145
}),
@@ -150,7 +150,7 @@ describe("setStatusImpl", () => {
150150
repo: "test-repo",
151151
sha: fullGitSha,
152152
state: CommitStatusState.SUCCESS,
153-
context: "[TEST-IGNORE] Swagger BreakingChange",
153+
context: "Swagger BreakingChange",
154154
description: "Found label 'BreakingChange-Approved-UserImpact'",
155155
target_url: "https://test.com/set_status_url",
156156
});
@@ -170,8 +170,8 @@ describe("setStatusImpl", () => {
170170
target_url: "https://test.com/set_status_url",
171171
github,
172172
core,
173-
monitoredWorkflowName: "[TEST-IGNORE] Swagger BreakingChange - Analyze Code",
174-
requiredStatusName: "[TEST-IGNORE] Swagger BreakingChange",
173+
monitoredWorkflowName: "Swagger BreakingChange - Analyze Code",
174+
requiredStatusName: "Swagger BreakingChange",
175175
overridingLabel: "BreakingChange-Approved-Benign,,BreakingChange-Approved-Security,",
176176
}),
177177
).resolves.toBeUndefined();
@@ -181,7 +181,7 @@ describe("setStatusImpl", () => {
181181
repo: "test-repo",
182182
sha: fullGitSha,
183183
state: CommitStatusState.SUCCESS,
184-
context: "[TEST-IGNORE] Swagger BreakingChange",
184+
context: "Swagger BreakingChange",
185185
description: "Found label 'BreakingChange-Approved-Security'",
186186
target_url: "https://test.com/set_status_url",
187187
});
@@ -205,8 +205,8 @@ describe("setStatusImpl", () => {
205205
target_url: "https://test.com/set_status_url",
206206
github,
207207
core,
208-
monitoredWorkflowName: "[TEST-IGNORE] Swagger BreakingChange - Analyze Code",
209-
requiredStatusName: "[TEST-IGNORE] Swagger BreakingChange",
208+
monitoredWorkflowName: "Swagger BreakingChange - Analyze Code",
209+
requiredStatusName: "Swagger BreakingChange",
210210
overridingLabel:
211211
"BreakingChange-Approved-Benign,BreakingChange-Approved-BugFix,BreakingChange-Approved-UserImpact",
212212
}),
@@ -217,7 +217,7 @@ describe("setStatusImpl", () => {
217217
repo: "test-repo",
218218
sha: fullGitSha,
219219
state: CommitStatusState.PENDING,
220-
context: "[TEST-IGNORE] Swagger BreakingChange",
220+
context: "Swagger BreakingChange",
221221
target_url: "https://test.com/set_status_url",
222222
});
223223
});
@@ -240,8 +240,8 @@ describe("setStatusImpl", () => {
240240
target_url: "https://test.com/set_status_url",
241241
github,
242242
core,
243-
monitoredWorkflowName: "[TEST-IGNORE] Swagger BreakingChange - Analyze Code",
244-
requiredStatusName: "[TEST-IGNORE] Swagger BreakingChange",
243+
monitoredWorkflowName: "Swagger BreakingChange - Analyze Code",
244+
requiredStatusName: "Swagger BreakingChange",
245245
overridingLabel: "",
246246
}),
247247
).resolves.toBeUndefined();
@@ -251,7 +251,7 @@ describe("setStatusImpl", () => {
251251
repo: "test-repo",
252252
sha: fullGitSha,
253253
state: CommitStatusState.PENDING,
254-
context: "[TEST-IGNORE] Swagger BreakingChange",
254+
context: "Swagger BreakingChange",
255255
target_url: "https://test.com/set_status_url",
256256
});
257257
});
@@ -294,7 +294,7 @@ describe("setStatusImpl", () => {
294294
github.rest.actions.listWorkflowRunsForRepo.mockResolvedValue({
295295
data: [
296296
{
297-
name: "[TEST-IGNORE] Swagger Avocado - Analyze Code",
297+
name: "Swagger Avocado - Analyze Code",
298298
status: checkStatus,
299299
conclusion: checkConclusion,
300300
updated_at: "2025-01-01",
@@ -333,8 +333,8 @@ describe("setStatusImpl", () => {
333333
target_url: "https://test.com/set_status_url",
334334
github,
335335
core,
336-
monitoredWorkflowName: "[TEST-IGNORE] Swagger Avocado - Analyze Code",
337-
requiredStatusName: "[TEST-IGNORE] Swagger Avocado",
336+
monitoredWorkflowName: "Swagger Avocado - Analyze Code",
337+
requiredStatusName: "Swagger Avocado",
338338
overridingLabel: "Approved-Avocado",
339339
}),
340340
).resolves.toBeUndefined();
@@ -344,7 +344,7 @@ describe("setStatusImpl", () => {
344344
repo: "test-repo",
345345
sha: fullGitSha,
346346
state: commitStatusState,
347-
context: "[TEST-IGNORE] Swagger Avocado",
347+
context: "Swagger Avocado",
348348
target_url: targetUrl,
349349
});
350350
},

0 commit comments

Comments
 (0)