Skip to content
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

Dump resources, especially checks, for debugging #832

Merged
merged 28 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7c8f4f5
Prefer GITHUB_OUTPUT for printing debug resources
kachick Jun 3, 2024
ddcda0c
Fix typos
kachick Jun 3, 2024
df660dd
Move into lightweight job
kachick Jun 3, 2024
61cfe22
Fix missing step name
kachick Jun 3, 2024
108ea79
Print the output size
kachick Jun 3, 2024
2dc5792
Fix typo
kachick Jun 3, 2024
9777fd4
Update documents
kachick Jun 3, 2024
c235b73
Gathers into single object
kachick Jun 4, 2024
692d003
Extract outputs workflow to make rerun easy
kachick Jun 4, 2024
66bcbcd
No need to guard uploading
kachick Jun 4, 2024
23ab2fd
Fix a typo
kachick Jun 4, 2024
e9a5abd
Adjust times to make multiple pollings
kachick Jun 4, 2024
81a9573
Check the filesize
kachick Jun 4, 2024
5c98a4f
Do not early exit with set -e
kachick Jun 4, 2024
e2e86a3
Do not append excess lf
kachick Jun 4, 2024
b09e5a0
Do not depend on debug mode
kachick Jun 4, 2024
0124347
Omit middle pollings in debug report
kachick Jun 4, 2024
b421c79
Remove outdated isDebug
kachick Jun 5, 2024
586d9d4
Remove payload from dump data
kachick Jun 5, 2024
234f146
Remove outdated guard in workflow
kachick Jun 5, 2024
81ed152
Do not use single quote for multine lines
kachick Jun 5, 2024
aa42873
`pnpm install @actions/artifact`
kachick Jun 5, 2024
1da1ce2
Write dump to file and just outputs the path
kachick Jun 5, 2024
1ea10a0
`pnpm uninstall @actions/artifact`
kachick Jun 5, 2024
5a273f5
Update use of action
kachick Jun 5, 2024
b5b8e70
Remove unused code and compile
kachick Jun 5, 2024
3f9d611
Clarify outputs in action.yml
kachick Jun 5, 2024
9d768c5
Simplify message
kachick Jun 5, 2024
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
18 changes: 18 additions & 0 deletions .github/workflows/itself.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ jobs:
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- uses: ./
id: wait
with:
retry-method: 'equal_intervals'
min-interval-seconds: 5
Expand All @@ -180,3 +181,20 @@ jobs:
"workflowFile": "GH-820-graceperiod.yml"
}
]
- name: 'Copy the output results to files'
env:
DEBUG_PR_CONTEXT: '${{ steps.wait.outputs.pr-context }}'
DEBUG_CHECKS_CONTEXT: '${{ steps.wait.outputs.checks }}'
DEBUG_REPORT_CONTEXT: '${{ steps.wait.outputs.report }}'
run: |
mkdir outputs
echo "$DEBUG_PR_CONTEXT" > ./outputs/pr-context.json
echo "$DEBUG_CHECKS_CONTEXT" > ./outputs/checks.json
echo "$DEBUG_REPORT_CONTEXT" > ./outputs/report.json
ls -alh ./outputs
- name: Upload logs as an artifact
if: runner.debug
kachick marked this conversation as resolved.
Show resolved Hide resolved
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: 'outputs-${{ github.job }}-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}'
path: ./outputs
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ Full list of the options
| `skip-same-workflow` | Skip jobs defined in the same workflow which using this action | `bool` | `false` | |
| `dry-run` | Avoid requests for tests | `bool` | `false` | |

## Outputs

(Since v3.4.0)

For now, this action outputs used resources only into `GITHUB_OUTPUT` in debug mode.

- checks
- pr-context
- report

## Required GITHUB_TOKEN permissions

In public repositories, they are satisfied by default
Expand Down
32 changes: 16 additions & 16 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ var require_tunnel = __commonJS({
connectOptions.headers = connectOptions.headers || {};
connectOptions.headers["Proxy-Authorization"] = "Basic " + new Buffer(connectOptions.proxyAuth).toString("base64");
}
debug3("making CONNECT request");
debug("making CONNECT request");
var connectReq = self.request(connectOptions);
connectReq.useChunkedEncodingByDefault = false;
connectReq.once("response", onResponse);
Expand All @@ -746,7 +746,7 @@ var require_tunnel = __commonJS({
connectReq.removeAllListeners();
socket.removeAllListeners();
if (res.statusCode !== 200) {
debug3(
debug(
"tunneling socket could not be established, statusCode=%d",
res.statusCode
);
Expand All @@ -758,21 +758,21 @@ var require_tunnel = __commonJS({
return;
}
if (head.length > 0) {
debug3("got illegal response body from proxy");
debug("got illegal response body from proxy");
socket.destroy();
var error2 = new Error("got illegal response body from proxy");
error2.code = "ECONNRESET";
options.request.emit("error", error2);
self.removeSocket(placeholder);
return;
}
debug3("tunneling connection has established");
debug("tunneling connection has established");
self.sockets[self.sockets.indexOf(placeholder)] = socket;
return cb(socket);
}
function onError(cause) {
connectReq.removeAllListeners();
debug3(
debug(
"tunneling socket could not be established, cause=%s\n",
cause.message,
cause.stack
Expand Down Expand Up @@ -834,9 +834,9 @@ var require_tunnel = __commonJS({
}
return target;
}
var debug3;
var debug;
if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) {
debug3 = function() {
debug = function() {
var args = Array.prototype.slice.call(arguments);
if (typeof args[0] === "string") {
args[0] = "TUNNEL: " + args[0];
Expand All @@ -846,10 +846,10 @@ var require_tunnel = __commonJS({
console.error.apply(console, args);
};
} else {
debug3 = function() {
debug = function() {
};
}
exports.debug = debug3;
exports.debug = debug;
}
});

Expand Down Expand Up @@ -18878,15 +18878,15 @@ var require_core = __commonJS({
Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
}
exports.getBooleanInput = getBooleanInput2;
function setOutput(name, value) {
function setOutput3(name, value) {
const filePath = process.env["GITHUB_OUTPUT"] || "";
if (filePath) {
return file_command_1.issueFileCommand("OUTPUT", file_command_1.prepareKeyValueMessage(name, value));
}
process.stdout.write(os2.EOL);
command_1.issueCommand("set-output", { name }, utils_1.toCommandValue(value));
}
exports.setOutput = setOutput;
exports.setOutput = setOutput3;
function setCommandEcho(enabled) {
command_1.issue("echo", enabled ? "on" : "off");
}
Expand All @@ -18900,10 +18900,10 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
return process.env["RUNNER_DEBUG"] === "1";
}
exports.isDebug = isDebug3;
function debug3(message) {
function debug(message) {
command_1.issueCommand("debug", {}, message);
}
exports.debug = debug3;
exports.debug = debug;
function error2(message, properties = {}) {
command_1.issueCommand("error", utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
}
Expand Down Expand Up @@ -31126,7 +31126,7 @@ function parseInput() {
commitSha = prSha;
} else {
if ((0, import_core.isDebug)()) {
(0, import_core.debug)(JSON.stringify({ label: "PullRequestContext", pr: pr2 }, null, 2));
(0, import_core.setOutput)("pr-context", JSON.stringify(pr2, null, 2));
}
(0, import_core.error)("github context has unexpected format: missing context.payload.pull_request.head.sha");
}
Expand Down Expand Up @@ -32590,7 +32590,7 @@ async function run() {
(0, import_core3.startGroup)(`Polling ${attempts}: ${(/* @__PURE__ */ new Date()).toISOString()} # total elapsed ${readableDuration(elapsed)}`);
const checks = await fetchChecks(githubToken, trigger);
if ((0, import_core3.isDebug)()) {
(0, import_core3.debug)(JSON.stringify({ label: "rawdata", checks, elapsed }, null, 2));
(0, import_core3.setOutput)("checks", JSON.stringify(checks, null, 2));
}
const report = generateReport(
getSummaries(checks, trigger),
Expand All @@ -32614,7 +32614,7 @@ async function run() {
);
}
if ((0, import_core3.isDebug)()) {
(0, import_core3.debug)(JSON.stringify({ label: "filtered", report }, null, 2));
(0, import_core3.setOutput)("report", JSON.stringify(report, null, 2));
}
const { ok, done, logs } = report;
for (const { severity, message, resource } of logs) {
Expand Down
4 changes: 4 additions & 0 deletions snapshots/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# How to get snapshot of resources

Since v3.4.0, we can use GITHUB_OUTPUT only in debug mode\
See the section in [README](../README.md#outputs)
4 changes: 2 additions & 2 deletions src/input.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { debug, getInput, getBooleanInput, setSecret, isDebug, error } from '@actions/core';
import { getInput, getBooleanInput, setSecret, isDebug, error, setOutput } from '@actions/core';
import { context } from '@actions/github';

import { Durationable, Options, Trigger } from './schema.ts';
Expand All @@ -21,7 +21,7 @@ export function parseInput(): { trigger: Trigger; options: Options; githubToken:
} else {
if (isDebug()) {
// Do not print secret even for debug code
debug(JSON.stringify({ label: 'PullRequestContext', pr }, null, 2));
setOutput('pr-context', JSON.stringify(pr, null, 2));
}
error('github context has unexpected format: missing context.payload.pull_request.head.sha');
}
Expand Down
6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { debug, info, setFailed, isDebug, startGroup, endGroup } from '@actions/core';
import { info, setFailed, isDebug, startGroup, endGroup, setOutput } from '@actions/core';
import styles from 'ansi-styles';

function colorize(severity: Severity, message: string): string {
Expand Down Expand Up @@ -71,7 +71,7 @@ async function run(): Promise<void> {
startGroup(`Polling ${attempts}: ${(new Date()).toISOString()} # total elapsed ${readableDuration(elapsed)}`);
const checks = await fetchChecks(githubToken, trigger);
if (isDebug()) {
debug(JSON.stringify({ label: 'rawdata', checks, elapsed }, null, 2));
setOutput('checks', JSON.stringify(checks, null, 2));
}
const report = generateReport(
getSummaries(checks, trigger),
Expand Down Expand Up @@ -102,7 +102,7 @@ async function run(): Promise<void> {
}

if (isDebug()) {
debug(JSON.stringify({ label: 'filtered', report }, null, 2));
setOutput('report', JSON.stringify(report, null, 2));
}

const { ok, done, logs } = report;
Expand Down
Loading