Skip to content

fix(ci): target the failure region when parsing the pin guard from job logs - #453

Merged
joshua-temple merged 3 commits into
mainfrom
fix/pr-failure-comment-pin-guard-extraction
Jul 5, 2026
Merged

fix(ci): target the failure region when parsing the pin guard from job logs#453
joshua-temple merged 3 commits into
mainfrom
fix/pr-failure-comment-pin-guard-extraction

Conversation

@joshua-temple

Copy link
Copy Markdown
Collaborator

Problem

The PR Failure Report companion (drift-comment.yaml) parses the action-pins consistency guard (TestActionPinsAnchorCoversManifest / TestWorkflowsConsistentWithActionPins) from a failed job's log so it can print the exact internal/generate/action_pins.yaml remediation (action, want vs got SHA). An intentional-trip validation of the merged companion (#441) showed the remediation was absent: the sticky comment named the failed Unit Tests job but printed no manifest edit, only a generic exit code 123 annotation.

Root cause: parsePinGuard was fed the last 30 lines of the job log. For a Go test failure the guard signature and its want ... got ... rows print in the middle of the log; the trailing lines are post-job git-config and credential cleanup ending at Cleaning up orphan processes. The parser saw no signature, so it produced nothing.

Fix

  • Feed the full job log to parsePinGuard so the signature and want/got rows are found wherever they land, rather than a blind trailing slice.
  • Add extractFailRegion, which anchors on the first failure signature (--- FAIL, the guard messages) and windows forward, so the displayed log region shows the failing test output instead of the cleanup tail. Falls back to the trailing lines for non-test failures.
  • Existing fork-log fencing and the non-pin fallback are unchanged.

Verification

  • New node unit test (.github/workflows/__tests__/pin-guard.test.js) extracts the shipped helpers verbatim from the workflow (between sentinels, so no forked copy can drift) and runs them against a real captured failing Unit Tests job log. It asserts the manifest remediation is produced, the display region lands on the failure (not the cleanup tail), and that the prior last-30-lines approach produced nothing. 4/4 pass under node --test.
  • actionlint clean on the workflow; node --check clean on the embedded script.

The companion runs only from main on workflow_run, so this local proof stands in for a live run.

…b logs
The PR Failure Report companion parsed the action-pins consistency guard
from the last 30 lines of a failed job log. For a Go test failure the guard
signature and its want/got rows print in the middle of the log; the trailing
lines are post-job git-config cleanup ending at "Cleaning up orphan
processes". parsePinGuard therefore saw no signature and dropped the manifest
remediation, leaving only a generic exit-code annotation.
Feed the full job log to parsePinGuard so the signature and rows are found
wherever they land, and display a failure-anchored region instead of the
cleanup tail. Adds a node unit test that extracts the shipped helpers verbatim
from the workflow and runs them against a real captured failing job log.
Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
The pin-guard node test and its fixture were never wired into any CI
job, so drop them along with the sentinel comments that existed only
to support extracting the helper source for that test. The underlying
fix (parsing the pin guard against the full job log and anchoring
extractFailRegion on the failure signature) is unchanged.
Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
The sentinel comments existed only to mark the extraction boundary for
the now-removed node unit test. Remove them along with it.
Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
@joshua-temple
joshua-temple merged commit 4a6ba15 into mainJul 5, 2026
15 checks passed
@joshua-temple
joshua-temple deleted the fix/pr-failure-comment-pin-guard-extraction branch July 5, 2026 03:37
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@joshua-temple