-
Notifications
You must be signed in to change notification settings - Fork 4
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
kachick
merged 28 commits into
main
from
prefer-output-rather-than-console-in-debug-mode
Jun 5, 2024
Merged
Changes from 15 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 ddcda0c
Fix typos
kachick df660dd
Move into lightweight job
kachick 61cfe22
Fix missing step name
kachick 108ea79
Print the output size
kachick 2dc5792
Fix typo
kachick 9777fd4
Update documents
kachick c235b73
Gathers into single object
kachick 692d003
Extract outputs workflow to make rerun easy
kachick 66bcbcd
No need to guard uploading
kachick 23ab2fd
Fix a typo
kachick e9a5abd
Adjust times to make multiple pollings
kachick 81a9573
Check the filesize
kachick 5c98a4f
Do not early exit with set -e
kachick e2e86a3
Do not append excess lf
kachick b09e5a0
Do not depend on debug mode
kachick 0124347
Omit middle pollings in debug report
kachick b421c79
Remove outdated isDebug
kachick 586d9d4
Remove payload from dump data
kachick 234f146
Remove outdated guard in workflow
kachick 81ed152
Do not use single quote for multine lines
kachick aa42873
`pnpm install @actions/artifact`
kachick 1da1ce2
Write dump to file and just outputs the path
kachick 1ea10a0
`pnpm uninstall @actions/artifact`
kachick 5a273f5
Update use of action
kachick b5b8e70
Remove unused code and compile
kachick 3f9d611
Clarify outputs in action.yml
kachick 9d768c5
Simplify message
kachick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: Outputs | ||
on: | ||
push: | ||
branches: [main] | ||
paths: | ||
- '.github/workflows/outputs.yml' | ||
- 'action.yml' | ||
- 'dist/**' | ||
pull_request: | ||
paths: | ||
- '.github/workflows/outputs.yml' | ||
- 'action.yml' | ||
- 'dist/**' | ||
workflow_dispatch: | ||
|
||
# Disable all permissions in workflow global as to setup clean room | ||
# However PRs will have read permissions because this project is on a public repository | ||
permissions: {} | ||
|
||
jobs: | ||
echo: | ||
runs-on: ubuntu-24.04 | ||
timeout-minutes: 5 | ||
steps: | ||
- run: echo ':)' | ||
# Wait longer than min-interval-seconds | ||
- run: sleep 8 | ||
- run: echo '🎉' | ||
dump: | ||
runs-on: ubuntu-24.04 | ||
if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]' }} | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | ||
- uses: ./ | ||
id: wait | ||
with: | ||
retry-method: 'equal_intervals' | ||
wait-seconds-before-first-polling: '1' | ||
min-interval-seconds: '3' | ||
skip-same-workflow: 'false' | ||
wait-list: | | ||
[ | ||
{ | ||
"workflowFile": "outputs.yml", | ||
"jobName": "echo", | ||
"optional": false | ||
} | ||
] | ||
- name: 'Copy the output results to files' | ||
env: | ||
DEBUG_DUMP: '${{ steps.wait.outputs.dump }}' | ||
run: | | ||
mkdir outputs | ||
echo -n "$DEBUG_DUMP" > ./outputs/dump.json | ||
ls -alh ./outputs | ||
set +e | ||
if [[ -s './outputs/dump.json' ]] && [[ '${{ runner.debug }}' != '1' ]]; then | ||
exit 2 | ||
fi | ||
- name: Upload dumps as an artifact | ||
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 | ||
with: | ||
name: 'outputs-${{ github.job }}-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}' | ||
path: ./outputs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
|
@@ -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 | ||
); | ||
|
@@ -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 | ||
|
@@ -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]; | ||
|
@@ -846,10 +846,10 @@ var require_tunnel = __commonJS({ | |
console.error.apply(console, args); | ||
}; | ||
} else { | ||
debug3 = function() { | ||
debug = function() { | ||
}; | ||
} | ||
exports.debug = debug3; | ||
exports.debug = debug; | ||
} | ||
}); | ||
|
||
|
@@ -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 setOutput2(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 = setOutput2; | ||
function setCommandEcho(enabled) { | ||
command_1.issue("echo", enabled ? "on" : "off"); | ||
} | ||
|
@@ -18896,14 +18896,14 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); | |
error2(message); | ||
} | ||
exports.setFailed = setFailed2; | ||
function isDebug3() { | ||
function isDebug2() { | ||
return process.env["RUNNER_DEBUG"] === "1"; | ||
} | ||
exports.isDebug = isDebug3; | ||
function debug3(message) { | ||
exports.isDebug = isDebug2; | ||
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); | ||
} | ||
|
@@ -31125,9 +31125,6 @@ function parseInput() { | |
if (typeof prSha === "string") { | ||
commitSha = prSha; | ||
} else { | ||
if ((0, import_core.isDebug)()) { | ||
(0, import_core.debug)(JSON.stringify({ label: "PullRequestContext", pr: pr2 }, null, 2)); | ||
} | ||
(0, import_core.error)("github context has unexpected format: missing context.payload.pull_request.head.sha"); | ||
} | ||
} | ||
|
@@ -31161,7 +31158,7 @@ function parseInput() { | |
const trigger = { ...repo, ref: commitSha, runId, jobName: job, eventName }; | ||
const githubToken = (0, import_core.getInput)("github-token", { required: true, trimWhitespace: false }); | ||
(0, import_core.setSecret)(githubToken); | ||
return { trigger, options, githubToken }; | ||
return { trigger, options, githubToken, payload }; | ||
} | ||
|
||
// node_modules/.pnpm/[email protected]/node_modules/universal-user-agent/index.js | ||
|
@@ -32555,8 +32552,9 @@ function colorize(severity, message) { | |
async function run() { | ||
const startedAt = performance.now(); | ||
(0, import_core3.startGroup)("Parameters"); | ||
const { trigger, options, githubToken } = parseInput(); | ||
const { trigger, options, githubToken, payload } = parseInput(); | ||
(0, import_core3.info)(JSON.stringify( | ||
// Do NOT include payload | ||
{ | ||
trigger, | ||
startedAt, | ||
|
@@ -32572,6 +32570,7 @@ async function run() { | |
if (options.isDryRun) { | ||
return; | ||
} | ||
const dumper = { trigger, options, payload, results: [] }; | ||
for (; ; ) { | ||
attempts += 1; | ||
if (attempts > options.attemptLimits) { | ||
|
@@ -32589,9 +32588,6 @@ async function run() { | |
const elapsed = mr.Duration.from({ milliseconds: Math.ceil(performance.now() - startedAt) }); | ||
(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)); | ||
} | ||
const report = generateReport( | ||
getSummaries(checks, trigger), | ||
trigger, | ||
|
@@ -32613,9 +32609,7 @@ async function run() { | |
`${workflowBasename}(${colorize(severity, jobName)}): [eventName: ${eventName}][runStatus: ${runStatus}][runConclusion: ${runConclusion ?? nullStr}][runURL: ${checkRunUrl}]` | ||
); | ||
} | ||
if ((0, import_core3.isDebug)()) { | ||
(0, import_core3.debug)(JSON.stringify({ label: "filtered", report }, null, 2)); | ||
} | ||
dumper.results.push({ elapsed, checks, report }); | ||
const { ok, done, logs } = report; | ||
for (const { severity, message, resource } of logs) { | ||
(0, import_core3.info)(colorize(severity, message)); | ||
|
@@ -32645,6 +32639,9 @@ async function run() { | |
break; | ||
} | ||
} | ||
if ((0, import_core3.isDebug)()) { | ||
(0, import_core3.setOutput)("dump", JSON.stringify(dumper, null, 2)); | ||
} | ||
} | ||
void run(); | ||
/*! Bundled license information: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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#jobsjob_idoutputs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want a payload for addressing issues, such as #767.
However, the object schema scares me due to accidents. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
In my understanding, this payload will points to
github.event
, not the whole of context.But...