Skip to content

feat: sticky-comment-and-job-summary#6

Merged
CodeYogiCo merged 1 commit into
masterfrom
sticky-comment-and-job-summary
Jun 19, 2026
Merged

feat: sticky-comment-and-job-summary#6
CodeYogiCo merged 1 commit into
masterfrom
sticky-comment-and-job-summary

Conversation

@CodeYogiCo

Copy link
Copy Markdown
Owner

Two reporting features that build on the existing reporter seam and share the report Markdown.

Sticky PR comment

Previously the plugin POSTed a new comment on every push, stacking duplicates on active PRs. Now github_pr.go first GETs the PR's comments and, if it finds the one carrying a hidden marker (<!-- pull-request-code-coverage:patch-coverage -->), PATCHes that comment in place; otherwise it POSTs a new one. A single, always-current coverage comment.

Job summary ($GITHUB_STEP_SUMMARY)

New StepSummary reporter writes the same Markdown to $GITHUB_STEP_SUMMARY when set, so coverage renders on the Actions run page — visible even on fork PRs where the read-only token can't post a comment (pairs with the earlier fork-PR change). The workflow now mounts and passes the summary file.

Refactor

Extracted the shared buildMarkdownReport used by both the PR comment and the job summary, and added Unmarshal to the JSON client (to read the comments list).

Tests / docs

  • New step_summary_test.go; reworked github_pr_test.go for the GET→PATCH/POST flow (incl. a sticky-update case); mock GitHub API and golden bodies updated for the new GET call and marker.
  • go test ./..., gofmt, and golangci-lint run all clean.
  • README + AGENTS.md updated.

🤖 Generated with Claude Code

Add two reporting features that share the report markdown:

- Sticky PR comment: github_pr.go now lists the PR's comments and PATCHes
  the one carrying a hidden marker instead of POSTing a new comment on
  every push. Adds Unmarshal to the json client.
- Job summary: a StepSummary reporter writes the report to
  $GITHUB_STEP_SUMMARY when set, so coverage shows on the Actions run page
  even on fork PRs that can't be commented on. Wired into the workflow by
  mounting and passing the summary file.

Extracts the shared buildMarkdownReport used by both the comment and the
summary, and updates README/AGENTS docs and tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🛡️ Patch Coverage Report

Scope: changed lines only — the code this PR adds or edits, not whole files or the repo. It answers one thing — did your tests run the code you just touched?

Diff coverage: 81% 🟢 — 88 of 108 changed instructions covered

Metric Value
🟢 Covered instructions 88 (81%) changed code your tests executed
🔴 Missed instructions 20 (19%) changed code your tests never ran
📈 Tracked changed lines 108 (34%) lines the coverage tool could measure
⚪ Untracked changed lines 213 (66%) comments, blanks, declarations

Lines = the source lines you changed. Instructions = the executable units the coverage tool counts inside those lines — one line can hold several (e.g. JaCoCo bytecode), so the two counts differ.

Coverage by file

File Diff coverage Covered / Missed
internal/plugin/pluginjson/mocks.go 🔴 0% 0 / 5
internal/plugin/runner.go 🔴 10% 1 / 9
internal/plugin/reporter/step_summary.go 🟢 88% 14 / 2
internal/plugin/reporter/github_pr.go 🟢 94% 62 / 4
internal/plugin/pluginjson/client.go 🟢 100% 3 / 0
internal/test/mocks/mock_gh_api.go 🟢 100% 8 / 0

7 changed file(s) with no measurable lines (config, docs, generated, or test-only) omitted.

🔍 Uncovered lines (20)
--- internal/plugin/pluginjson/mocks.go:23
func (m *MockClient) Unmarshal(data []byte, v interface{}) error {
--- internal/plugin/pluginjson/mocks.go:24
	args := m.Called(data, v)
--- internal/plugin/pluginjson/mocks.go:25

--- internal/plugin/pluginjson/mocks.go:26
	return args.Error(0)
--- internal/plugin/pluginjson/mocks.go:27
}
--- internal/plugin/reporter/github_pr.go:141
		return 0, errors.Wrap(readErr, "Failed reading github comments response")
--- internal/plugin/reporter/github_pr.go:142
	}
--- internal/plugin/reporter/github_pr.go:150
		return 0, errors.Wrap(unmarshalErr, "Failed parsing github comments response")
--- internal/plugin/reporter/github_pr.go:151
	}
--- internal/plugin/reporter/step_summary.go:30
		return errors.Wrap(err, "Failed writing job summary")
--- internal/plugin/reporter/step_summary.go:31
	}
--- internal/plugin/runner.go:162
		// nolint: gosec // path comes from the trusted GitHub Actions runner env
--- internal/plugin/runner.go:163
		summaryFile, openErr := os.OpenFile(summaryPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
--- internal/plugin/runner.go:164
		if openErr != nil {
--- internal/plugin/runner.go:165
			return errors.Wrap(openErr, "Failed opening GITHUB_STEP_SUMMARY file")
--- internal/plugin/runner.go:166
		}
--- internal/plugin/runner.go:167
		defer func() {
--- internal/plugin/runner.go:168
			_ = summaryFile.Close()
--- internal/plugin/runner.go:169
		}()
--- internal/plugin/runner.go:171
		reporters = append(reporters, reporter.NewStepSummary(summaryFile))

🤖 Generated by pull-request-code-coverage — coverage for changed lines only.

@CodeYogiCo CodeYogiCo merged commit ef4c7f9 into master Jun 19, 2026
2 checks passed
@CodeYogiCo CodeYogiCo deleted the sticky-comment-and-job-summary branch June 19, 2026 07:12
Sign up for free to 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