Skip to content

[context.js] Write step summary #36574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/src/context.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// @ts-check

import { isFullGitSha } from "../../shared/src/git.js";
Expand Down Expand Up @@ -25,6 +25,15 @@
core.info(` payload.action: ${context.payload.action}`);
core.info(` payload.workflow_run.event: ${context.payload.workflow_run?.event || "undefined"}`);

core.summary.addHeading("extractInputs", 2);
core.summary.addTable([
["eventName", context.eventName],
["payload.action", context.payload.action || "undefined"],
["payload.workflow_run.event", context.payload.workflow_run?.event || "undefined"],
]);
core.summary.write();
core.setOutput("summary", process.env.GITHUB_STEP_SUMMARY);

// Log full context when debug is enabled. Most workflows should be idempotent and can be re-run
// with debug enabled to replay the previous context.
if (core.isDebug()) {
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/src/summarize-checks/summarize-checks.js
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated code cleanup

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// @ts-check

/*
Expand Down Expand Up @@ -364,9 +364,7 @@
core.info(`Handling ${event_name} event for PR #${issue_number} in ${owner}/${repo}.`);

const prUrl = `https://github.com/${owner}/${repo}/pull/${issue_number}`;
core.summary.addRaw("PR: ");
core.summary.addLink(prUrl, prUrl);
core.summary.write();
core.summary.addRaw("PR: ").addLink(prUrl, prUrl).write();
core.setOutput("summary", process.env.GITHUB_STEP_SUMMARY);

let labelNames = await getExistingLabels(github, owner, repo, issue_number);
Expand Down Expand Up @@ -447,8 +445,7 @@
core.info(
`Updating comment '${NEXT_STEPS_COMMENT_ID}' on ${owner}/${repo}#${issue_number} with body: ${commentBody}`,
);
core.summary.addRaw(`\n${commentBody}\n\n`);
core.summary.write();
core.summary.addRaw(`\n${commentBody}\n\n`).write();

// this will remain commented until we're comfortable with the change.
// await commentOrUpdate(
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/test/mocks.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { RequestError } from "@octokit/request-error";
import { vi } from "vitest";

Expand Down Expand Up @@ -57,8 +57,13 @@
setOutput: vi.fn((name, value) => console.log(`setOutput('${name}', '${value}')`)),
setFailed: vi.fn((msg) => console.log(`setFailed('${msg}')`)),
summary: {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
addRaw: vi.fn(function (content) {
addHeading: vi.fn(function () {
return this; // Return 'this' for method chaining
}),
addRaw: vi.fn(function () {
return this; // Return 'this' for method chaining
}),
addTable: vi.fn(function () {
return this; // Return 'this' for method chaining
}),
write: vi.fn().mockResolvedValue(undefined),
Expand Down
Loading