Read GitHub job logs from the raw REST endpoint; decode JSON with luanil #786
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
fugitive
good first issue
help wanted
invalid
question
v0.1.0
v0.2.0
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
barrettruth/forge.nvim!786
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/github-raw-job-logs-and-luanil"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up to #784 (exploring guh.nvim's CI-log approach). Implements the two items worth borrowing; declines the rest.
1. GitHub single-job logs via the raw REST endpoint
check_log_cmdnow fetchesgh api repos/{owner}/{repo}/actions/jobs/{id}/logswhen a job id is known, instead ofgh run view --job <id> --log. The raw endpoint omits gh's{workflow} / {job} {step}per-line prefix.ci_job_log_raw(GitHub only). The whole-RUN path keepsgh run view --log, because the whole-run raw endpoint returns a ZIP rather than text.parse_githubgains a column-lesssingle_jobmode: it synthesizes the job header from the check/job name and derives structure from##[group]markers + the steps JSON, instead of the now-absentJOB\tSTEPcolumns. The tab-format (run-level) path is unchanged.columnless+job_nameare threaded throughlog/init.lua,ci/actions.lua, andpr/checks.lua, gated on the capability and a present job id.set -eu(notgh ... | tail) so a non-zero gh exit (404 / expired logs) surfaces as an error instead of rendering gh's error JSON as log lines.Deliberate behavior change (failed checks)
The raw endpoint has no server-side step filter, so opening a failed check now shows the whole job log instead of only the failed steps. Measured on a real failed job (run 25129091893, job Format):
gh run view --job --log-failed: 262 linesgh api .../jobs/{id}/logs: 828 lines (==--log)Accepted intentionally: in the structured/folded view the
##[error]line is still highlighted, the failed step header renders red (from the steps JSON conclusion), and the cursor lands at the bottom near the failure. We trade "failed steps only" for uniform, prefix-free logs + full context.2. luanil JSON-decode hardening
All 25
vim.json.decodesites now pass{ luanil = { object = true } }, so JSONnullobject fields decode tonilinstead of truthyvim.NIL. This is the exact footgun that crashed guh.nvim's CI-job sort (a.conclusion or a.statuskeptvim.NIL).object-only is used deliberately to avoid any sparse-array length hazard.Test plan
bustedsuite green (pre-existing tree-sitter-yaml env failures aside)check_log_cmdraw vs run-view fallbackSwitch GitHub single-job CI log fetching to the raw `gh api repos/{owner}/{repo}/actions/jobs/{id}/logs` endpoint, which omits gh's "{workflow} / {job} {step}" per-line prefix. parse_github gains a column-less mode that synthesizes the job header (from the check/job name) and derives structure from ##[group] markers plus the steps JSON; the run-level path keeps `gh run view --log` since the whole-run endpoint is a ZIP. The raw fetch buffers to a tempfile under `set -eu` so a non-zero gh exit (404/expired logs) surfaces as an error instead of rendering gh's error JSON as log lines. Decode every vim.json.decode call with `{ luanil = { object = true } }` so JSON null object fields become nil instead of truthy vim.NIL, which otherwise survives `x or default` and crashes later sorts/compares.