Skip to content

Introduce custom mechanism for exposing coverage information#4146

Draft
ScottDugas wants to merge 4 commits into
FoundationDB:mainfrom
ScottDugas:custom-jacoco-report
Draft

Introduce custom mechanism for exposing coverage information#4146
ScottDugas wants to merge 4 commits into
FoundationDB:mainfrom
ScottDugas:custom-jacoco-report

Conversation

@ScottDugas
Copy link
Copy Markdown
Collaborator

@ScottDugas ScottDugas commented May 8, 2026

This introduces a new mechanism to our pull request builds to add annotations to the diff indicating the coverage of the changed file.
You can see an example of this in: #4147 OR #4164 (same changes but at different points in the history)

To each modified java file, it adds an annotation above the first changed line indicating the total coverage for that file, and the coverage of the modified lines.
We already have teamscale validating that no methods are completely uncovered, but hopefully this will provide some additional information that could expose situations where a code change is under-covered. Further information would need to be gathered by looking at the report directly.

Note: We currently also use https://github.com/Madrapps/jacoco-report which adds similar information to the build, but, we never got the commenting back to the PR to work, and it runs on Node 20, which is no longer going to be supported. This PR does not remove that dependency, but that will probably come later.

@ScottDugas ScottDugas added the build improvement Improvement to the build system label May 8, 2026
@ScottDugas ScottDugas changed the title Initial pass at publishing coverage results as github annotations Introduce custom mechanism for exposing coverage information May 12, 2026
Copy link
Copy Markdown
Collaborator

@alecgrieser alecgrieser left a comment

Choose a reason for hiding this comment

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

Overall, this looks good. I guess I had one or two questions, but this also seems like it would be good to merge


annotation_line = max(1, first_changed_line - 1)
message = f'File coverage: {file_pct_str} | Changed lines: {changed_pct_str}'
return f'::notice file={repo_path},line={annotation_line}::{message}'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should this upgrade from notice to warning if the changed percentage is below some threshold (say, 80%)? I could also see skipping this annotation if the coverage is high enough (say, 100%). I believe it's a bit harder, but also getting branch coverage may be nice

GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr diff ${{ github.event.pull_request.number }} > pr_diff.patch
- name: Annotate Coverage
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You mention in the PR description that this doesn't remove the JaCoCo report (yet). Is the idea that these annotations are preferable to the old report because they're more noticeable and have the same information? Or would we want to have a markdown summary get generated and put that into the GitHub step summary?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build improvement Improvement to the build system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants