Skip to content

RFC: Automated test coverage PR comments for easier code review#648

Open
alfredosa wants to merge 8 commits into
mainfrom
reusable-goapp-code-coverage
Open

RFC: Automated test coverage PR comments for easier code review#648
alfredosa wants to merge 8 commits into
mainfrom
reusable-goapp-code-coverage

Conversation

@alfredosa

Copy link
Copy Markdown
Contributor

This pr aims at adding code coverage comments as an increasing need for reviewers to have this available during code reviews. #611 Is the issue at hand.

Comment thread internal/core/core.go
if len(parts) == 0 {
return ""
}
return strings.Join(parts, " ")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [mage-go-coverage] reported by reviewdog 🐶
Lines 240-245 are not covered

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you 🫡

@alfredosa

Copy link
Copy Markdown
Contributor Author

See output:

2m 11s
12s
Prepare all required actions
Getting action download info
Download action repository 'aki77/reviewdog-action-code-coverage@v2' (SHA:afe9f2d9588ce5ade4fa73dff380d90c3a7dd31e)
Getting action download info
Download action repository 'reviewdog/action-setup@e04ffabe3898a0af8d0fb1af00c188831c4b5893' (SHA:e04ffabe3898a0af8d0fb1af00c188831c4b5893)
Download action repository 'baptiste0928/cargo-install@e38323ef017552d7f7af73a3f4db467f278310ed' (SHA:e38323ef017552d7f7af73a3f4db467f278310ed)
Download action repository 'aki77/delete-pr-comments-action@ef208cb51cacbff428349ac715a337b2a07d62ef' (SHA:ef208cb51cacbff428349ac715a337b2a07d62ef)
Run ./.github/actions/go-coverage-reviewdog
Run set -eu
go: downloading github.com/jandelgado/gcov2lcov v1.1.1
Run set -eu
/home/runner/work/_temp/bin/gcov2lcov
Converting var/coverage.out -> var/lcov/var_coverage.out.lcov
Run aki77/reviewdog-action-code-coverage@v2
Run reviewdog/action-setup@e04ffabe3898a0af8d0fb1af00c188831c4b5893
Run set -eu
🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog
Run set -eu
📖 reviewdog -h
Run # Determine OS and architecture
Downloading lcov_to_checkstyle-x86_64-unknown-linux-musl for linux/x86_64
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

100  520k  100  520k    0     0  3431k      0 --:--:-- --:--:-- --:--:-- 3431k
Run baptiste0928/cargo-install@e38323ef017552d7f7af73a3f4db467f278310ed
Installing lcov-util...
Restored lcov-util from cache.
Added /home/runner/.cargo-install/lcov-util/bin to PATH.
Installed lcov-util 0.2.1.
Run aki77/delete-pr-comments-action@ef208cb51cacbff428349ac715a337b2a07d62ef
Run lcov-merge $(ls var/lcov/*.lcov) | \
Error: internal/core/core.go:245:0: warning: Lines 240-245 are not covered (coverage) # <-------- HEHE

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds automated PR feedback for Go test coverage by converting generated coverage.out files to LCOV and using reviewdog to comment uncovered added lines directly in pull requests, reducing the need to inspect CI logs manually (Issue #611).

Changes:

  • Add a composite GitHub Action to convert Go coverage profiles to LCOV and post PR annotations via reviewdog.
  • Wire the coverage-commenting step into existing Go CI workflows and grant required PR write permissions.
  • Adjust a failing pallets validation fixture and add a small core string utility.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/targets/pallets/testdata/fail-validate/.pallet/gitconfig.yaml Updates fail fixture to ensure validation fails deterministically.
internal/core/core.go Adds NormalizeWhitespace helper for consistent string normalization.
.github/workflows/reusable-goapp.yaml Runs the new coverage reviewdog step after Go tests and requests PR write permission.
.github/workflows/mage.yaml Runs the new coverage reviewdog step in the mage workflow and requests PR write permission.
.github/workflows/cicd.yaml Grants PR write permission where needed for downstream reusable workflows.
.github/actions/go-coverage-reviewdog/action.yaml New composite action to install gcov2lcov, generate LCOV files, and invoke reviewdog coverage commenting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 74 to +77
runs-on: ubuntu-24.04
permissions:
contents: read
pull-requests: write
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants