Skip to content

Commit 2f264d5

Browse files
Copilotmikeharder
andauthored
[openapi-diff-runner] Re-implement helpers using @actions/core (#40612)
* Initial plan * Remove addToSummary() and logGroup() helpers, use @actions/core summary directly Co-authored-by: mikeharder <9459391+mikeharder@users.noreply.github.com> * Replace setOutput() helper with core.setOutput() from @actions/core Co-authored-by: mikeharder <9459391+mikeharder@users.noreply.github.com> * Keep setOutput/addToSummary helpers in log.ts, re-implement using @actions/core Co-authored-by: mikeharder <9459391+mikeharder@users.noreply.github.com> * Clarify behavior in addToSummary function Added a comment to clarify behavior when GITHUB_STEP_SUMMARY is not available. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: mikeharder <9459391+mikeharder@users.noreply.github.com> Co-authored-by: Mike Harder <mharder@microsoft.com>
1 parent abf38bb commit 2f264d5

File tree

4 files changed

+7
-25
lines changed

4 files changed

+7
-25
lines changed

eng/tools/openapi-diff-runner/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"node": ">=20.0.0"
1919
},
2020
"dependencies": {
21+
"@actions/core": "^3.0.0",
2122
"@azure-tools/specs-shared": "file:../../../.github/shared",
2223
"@azure/oad": "0.12.3"
2324
},

eng/tools/openapi-diff-runner/src/generate-report.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,6 @@ async function writeToJobSummary(markdownContent: string): Promise<void> {
284284
);
285285
}
286286

287-
addToSummary(finalContent);
287+
await addToSummary(finalContent);
288288
logMessage(`Successfully wrote ${finalContent.length} characters to GitHub Actions job summary.`);
289289
}

eng/tools/openapi-diff-runner/src/log.ts

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { appendFileSync } from "node:fs";
1+
import * as core from "@actions/core";
22

33
/**
44
* Log prefix for all messages from openapi-diff-runner
@@ -97,40 +97,20 @@ export function logWarning(message: string, file?: string, line?: number, col?:
9797
* @param value Output parameter value
9898
*/
9999
export function setOutput(name: string, value: string): void {
100-
if (process.env.GITHUB_OUTPUT) {
101-
appendFileSync(process.env.GITHUB_OUTPUT, `${name}=${value}\n`);
102-
} else {
103-
// Fallback to older syntax
104-
console.log(`::set-output name=${name}::${value}`);
105-
}
100+
core.setOutput(name, value);
106101
}
107102

108103
/**
109104
* Add content to the GitHub Actions job summary
110105
* @param content Content to add to summary
111106
*/
112-
export function addToSummary(content: string): void {
107+
export async function addToSummary(content: string): Promise<void> {
113108
if (process.env.GITHUB_STEP_SUMMARY) {
114-
appendFileSync(process.env.GITHUB_STEP_SUMMARY, content);
109+
await core.summary.addRaw(content).write();
115110
}
116111
// Do nothing if GITHUB_STEP_SUMMARY is not available
117112
}
118113

119-
/**
120-
* Create a collapsible group in logs
121-
* @param title Group title
122-
* @param content Function that logs the group content
123-
*/
124-
export async function logGroup<T>(title: string, content: () => Promise<T> | T): Promise<T> {
125-
logMessage(title, LogLevel.Group);
126-
try {
127-
const result = await content();
128-
return result;
129-
} finally {
130-
logMessage("", LogLevel.EndGroup);
131-
}
132-
}
133-
134114
/**
135115
* Maximum safe log line length for GitHub Actions (64KB - some buffer)
136116
*/

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)