Skip to content

Commit bf7b1d4

Browse files
authored
[set-status] Trigger on both old and new names (#36653)
1 parent af8eab5 commit bf7b1d4

8 files changed

+42
-11
lines changed

.github/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"format:check": "prettier . --check",
4444
"format:check:ci": "prettier . --check --log-level debug",
4545
"test": "vitest",
46-
"test:ci": "vitest run --coverage --reporter=verbose"
46+
"test:ci": "vitest run --coverage --reporter=verbose",
47+
"validate": "npm run lint && npm run format:check && npm run test:ci"
4748
}
4849
}

.github/workflows/avocado-status.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ on:
1515
- labeled
1616
- unlabeled
1717
workflow_run:
18-
workflows: ["Swagger Avocado - Analyze Code"]
18+
# Trigger on both old and new names, to handle the rename more gracefully
19+
workflows: ["Swagger Avocado - Analyze Code", "[TEST-IGNORE] Swagger Avocado - Analyze Code"]
1920
types: [completed]
2021

2122
permissions:

.github/workflows/breaking-change-cross-version-status.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ on:
1515
- labeled
1616
- unlabeled
1717
workflow_run:
18-
workflows: ["Breaking Change(Cross-Version) - Analyze Code"]
18+
# Trigger on both old and new names, to handle the rename more gracefully
19+
workflows:
20+
[
21+
"Breaking Change(Cross-Version) - Analyze Code",
22+
"[TEST-IGNORE] Breaking Change(Cross-Version) - Analyze Code",
23+
]
1924
types: [completed]
2025

2126
permissions:

.github/workflows/breaking-change-status.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ on:
1515
- labeled
1616
- unlabeled
1717
workflow_run:
18-
workflows: ["Swagger BreakingChange - Analyze Code"]
18+
# Trigger on both old and new names, to handle the rename more gracefully
19+
workflows:
20+
[
21+
"Swagger BreakingChange - Analyze Code",
22+
"[TEST-IGNORE] Swagger BreakingChange - Analyze Code",
23+
]
1924
types: [completed]
2025

2126
permissions:

.github/workflows/lintdiff-status.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ on:
1515
- labeled
1616
- unlabeled
1717
workflow_run:
18-
workflows: ["Swagger LintDiff - Analyze Code"]
18+
# Trigger on both old and new names, to handle the rename more gracefully
19+
workflows: ["Swagger LintDiff - Analyze Code", "[TEST-IGNORE] Swagger LintDiff - Analyze Code"]
1920
types: [completed]
2021

2122
permissions:

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
CommitStatusState,
88
PER_PAGE_MAX,
99
} from "../../shared/src/github.js";
10+
import { byDate, invert } from "../../shared/src/sort.js";
1011
import { extractInputs } from "./context.js";
1112

1213
// TODO: Add tests
@@ -138,17 +139,23 @@ export async function setStatusImpl({
138139
});
139140

140141
const targetRuns = workflowRuns
141-
.filter((wf) => wf.name == monitoredWorkflowName)
142+
.filter(
143+
(wf) =>
144+
// Match both old and new names, to handle the rename more gracefully
145+
wf.name === monitoredWorkflowName || wf.name === `[TEST-IGNORE] ${monitoredWorkflowName}`,
146+
)
142147
// Sort by "updated_at" descending
143-
.sort((a, b) => new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime());
148+
.sort(invert(byDate((r) => r.updated_at)));
144149

145150
// Sorted by "updated_at" descending, so most recent run is at index 0.
146151
// If "targetRuns.length === 0", run will be "undefined", which the following
147152
// code must handle.
148153
const run = targetRuns[0];
149154

150155
if (!run) {
151-
console.log(`No workflow runs found for '${monitoredWorkflowName}'.`);
156+
console.log(
157+
`No workflow runs found for '${monitoredWorkflowName}' or '[TEST-IGNORE] ${monitoredWorkflowName}'.`,
158+
);
152159
}
153160

154161
if (run) {
@@ -219,7 +226,8 @@ export async function setStatusImpl({
219226
});
220227
} else {
221228
core.info(
222-
`No workflow runs found for '${monitoredWorkflowName}'. Setting status to ${CommitStatusState.PENDING} for required status: ${requiredStatusName}.`,
229+
`No workflow runs found for '${monitoredWorkflowName}' or '[TEST-IGNORE] ${monitoredWorkflowName}'.` +
230+
` Setting status to ${CommitStatusState.PENDING} for required status: ${requiredStatusName}.`,
223231
);
224232
// Run was not found (not started), or not completed
225233
await github.rest.repos.createCommitStatus({

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ on:
1515
- labeled
1616
- unlabeled
1717
workflow_run:
18-
workflows: ["Swagger ModelValidation - Analyze Code"]
18+
# Trigger on both old and new names, to handle the rename more gracefully
19+
workflows:
20+
[
21+
"Swagger ModelValidation - Analyze Code",
22+
"[TEST-IGNORE] Swagger ModelValidation - Analyze Code",
23+
]
1924
types: [completed]
2025

2126
permissions:

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ on:
1515
- labeled
1616
- unlabeled
1717
workflow_run:
18-
workflows: ["Swagger SemanticValidation - Analyze Code"]
18+
# Trigger on both old and new names, to handle the rename more gracefully
19+
workflows:
20+
[
21+
"Swagger SemanticValidation - Analyze Code",
22+
"[TEST-IGNORE] Swagger SemanticValidation - Analyze Code",
23+
]
1924
types: [completed]
2025

2126
permissions:

0 commit comments

Comments
 (0)