feat: comment/summary rendering module (Phase 5a)#613
Draft
rdhar wants to merge 2 commits into
Draft
Conversation
First half of Phase 5 (part of #582, tracking #568): the last pure module. No behavioural change — added and unit-tested but not wired in; dist unchanged. - comment.ts: parseDiff (terraform show -> +/-/!/~/# symbol-prefixed lines + change count), parseSummary (last Error:/Plan:/Apply complete!/No changes./ Success line, else "View output."), truncate (Unicode code-point truncation with \n… sentinel, per Q5), and buildCommentBody (reproduces the composite post-step markdown: 6 comment-pos placeholders, ```fish command block, collapsible diff, collapsible summary with actor footer + view-log link, console block, trailing <!-- marker -->). - 18 new tests. Next (Phase 5b): orchestrator.ts wiring all modules + flip action.yml to using: node24 + README/major-tag — the runtime cutover, as its own PR. Co-authored-by: Rishav Dhar <[email protected]>
This was referenced Jun 28, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds the Phase 5a pure rendering module for PR comments and job summaries, extracting the composite action’s markdown construction into unit-tested TypeScript helpers as part of the ongoing TS migration.
Changes:
- Added
src/comment.tswith pure functions for diff parsing, summary extraction, code-point truncation, and comment body assembly. - Added unit tests covering the rendering and parsing behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/comment.ts | Implements the comment/summary rendering helpers intended to mirror the composite action’s post-step markdown output. |
| tests/comment.test.ts | Adds unit tests for diff parsing, summary parsing, truncation, and comment body layout. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…eview) Drop the escaped dot in parseSummary so the "No changes." token matches the composite awk byte-for-byte (and a future "No changes:"/"!" variant matches identically). Comment-only behaviour otherwise unchanged. Co-authored-by: Rishav Dhar <[email protected]>
Comment on lines
+97
to
+99
| /** The collapsible diff block, or "" when there are no changed-resource lines. */ | ||
| function renderDiffBlock(parts: CommentParts): string { | ||
| if (parts.diff.lines.length === 0) return ""; |
Comment on lines
+139
to
+140
| <!-- ${parts.marker} --> | ||
| ${pos6}`; |
Comment on lines
+116
to
+118
| for (const p of ["P1", "P2", "P3", "P4", "P5", "P6"]) | ||
| expect(body).toContain(p); | ||
| }); |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Phase 5a — Comment/summary rendering (
comment.ts)First half of Phase 5 (part of #582, tracking #568), built on Phase 4 (#612). No behavioural change:
comment.tsis added and unit-tested but not wired intomain.ts, sodist/is unchanged. It's the last pure module before the runtime cutover.Reproduces the composite action's
post-step markdown as pure, testable functions:parseDiff(showOutput)— turnsterraform show# …lines into+/-/!/~/#-prefixed diff lines (first-match-wins, mirroring the sequentialsed), plus the changed-resourcecount(excludes#lines).parseSummary(consoleOutput)— the lastError:/Plan:/Apply complete!/No changes./Successline, elseView output.(mirrors theawk).truncate(text, maxCodePoints)— code-point truncation with a\n…sentinel (per Q5, so a multi-byte char is never split).buildCommentBody(parts)— assembles the exact heredoc layout: the sixcomment-pos-*placeholders, the ```fish command block, the collapsible diff, the collapsible summary with the actor footer +(view log)link, the console block, and the trailing `` the upsert keys off.Checklist
bun run typecheck(strict, noanyinsrc/)bun run format:checkbun test— 87 pass (+18)bun run build:check— nodist/driftWhy split Phase 5
Phase 5 bundles comment + orchestrator + the
action.ymlusing: node24flip. That flip is the one change that alters runtime behaviour and retires all the bash, so it deserves its own focused, closely-reviewed PR. This PR lands the pure rendering so the cutover PR is just wiring.Next — Phase 5b (the cutover, separate PR)
orchestrator.tssequencing every module + setting the 11 action outputs;main.tswiring;action.yml→using: node24(+GH_CHECK_RUN_ID: ${{ job.check_run_id }},$GITHUB_STEP_SUMMARYwrite, the hide/show-args command filtering, check-run token =github.token); then README rewrite + major version tag (#583). The fulltest_ci/test_awsmatrix runs against the flipped action there.Draft until reviewed.
Generated by Claude Code