Skip to content

Commit 4381195

Browse files
authored
[BreakingChanges] Always set required outputs head_sha and issue_number (#36607)
1 parent 4446f2c commit 4381195

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

.github/workflows/src/breaking-change-add-label-artifacts.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ export const CROSS_VERSION_BREAKING_CHANGE_WORKFLOW_NAME =
1515
*/
1616
export default async function getLabelActions({ github, context, core }) {
1717
const { owner, repo, head_sha, issue_number } = await extractInputs(github, context, core);
18+
19+
core.setOutput("head_sha", head_sha);
20+
core.setOutput("issue_number", issue_number);
21+
1822
const workflowRuns = await github.paginate(github.rest.actions.listWorkflowRunsForRepo, {
1923
owner,
2024
repo,
@@ -74,9 +78,6 @@ export default async function getLabelActions({ github, context, core }) {
7478
})
7579
).map((a) => a.name);
7680

77-
core.setOutput("head_sha", head_sha);
78-
core.setOutput("issue_number", issue_number);
79-
8081
if (
8182
breakingChangesArtifactNames.length === 0 &&
8283
crossVersionBreakingChangesArtifactNames.length === 0

.github/workflows/test/breaking-change-add-label-artifacts.test.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,14 @@ describe("breaking-change-add-label-artifacts", () => {
7373
createMockWorkflowRun(CROSS_VERSION_BREAKING_CHANGE_WORKFLOW_NAME, "completed", "success", 2),
7474
];
7575

76-
const expectStandardOutputs = (breakingChangeValue, versioningValue) => {
76+
const expectRequiredOutputs = () => {
7777
expect(mockCore.setOutput).toHaveBeenCalledWith("head_sha", mockInputs.head_sha);
7878
expect(mockCore.setOutput).toHaveBeenCalledWith("issue_number", mockInputs.issue_number);
79+
};
80+
81+
const expectStandardOutputs = (breakingChangeValue, versioningValue) => {
82+
expectRequiredOutputs();
83+
7984
expect(mockCore.setOutput).toHaveBeenCalledWith(
8085
"breakingChangeReviewLabelName",
8186
REVIEW_REQUIRED_LABELS.BREAKING_CHANGE,
@@ -92,9 +97,13 @@ describe("breaking-change-add-label-artifacts", () => {
9297
};
9398

9499
const expectEarlyReturn = (infoMessage) => {
100+
expectRequiredOutputs();
101+
102+
// Ensure setOutput was *only* called with the two required outputs
103+
expect(mockCore.setOutput).toHaveBeenCalledTimes(2);
104+
95105
expect(mockCore.info).toHaveBeenCalledWith(infoMessage);
96106
expect(mockGithub.rest.actions.listWorkflowRunArtifacts).not.toHaveBeenCalled();
97-
expect(mockCore.setOutput).not.toHaveBeenCalled();
98107
};
99108

100109
describe("successful execution with both workflows completed", () => {

0 commit comments

Comments
 (0)