Skip to content

Add JaCoCo code coverage reporting with Codecov integration#1285

Merged
chrjohn merged 10 commits into
masterfrom
copilot/update-documentation-for-quickfix-j
Jul 24, 2026
Merged

Add JaCoCo code coverage reporting with Codecov integration#1285
chrjohn merged 10 commits into
masterfrom
copilot/update-documentation-for-quickfix-j

Conversation

Copilot AI commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Integrates JaCoCo coverage instrumentation into the Maven build and wires it up to Codecov via GitHub Actions.

pom.xml

  • Add jacoco-maven-plugin 0.8.15 with prepare-agent (test-time instrumentation) and report (package phase) executions
  • Exclude generated message classes (quickfixj-messages/quickfixj-messages-*/target/classes/**) from the coverage report
  • Add @{argLine} to maven-surefire-plugin configuration — required so the JaCoCo Java agent is actually passed to the JVM running tests; without this no coverage data is collected

README.md

  • Add Codecov badge.

maven.yml

  • The test job now has a Codecov upload step with if: matrix.os == 'ubuntu-latest' && matrix.java == 21, so only that combination uploads results.

Prerequisites: register the repository on codecov.io and store the upload token as a repository secret named CODECOV_TOKEN.

Copilot AI added 2 commits July 23, 2026 09:28
- Add jacoco-maven-plugin 0.8.12 to pom.xml with prepare-agent and report executions
- Exclude dictgenerator from coverage report
- Wire argLine into maven-surefire-plugin so JaCoCo agent is activated during tests
- Add test-coverage GitHub Actions job that runs tests and uploads to Codecov
... it is done on the nightly build.
Added Codecov badge to README for coverage tracking.
@chrjohn

chrjohn commented Jul 23, 2026

Copy link
Copy Markdown
Member

@copilot is there the possibility to only create the coverage report selectively, i.e. on the nightly build?

…ightly build

- Add default empty argLine property so surefire @{argLine} expands safely without the profile
- Move jacoco-maven-plugin (prepare-agent + report) into a new coverage profile
- Activate -Pcoverage only on the nightly Build SNAPSHOT step

Copilot AI commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

@copilot is there the possibility to only create the coverage report selectively, i.e. on the nightly build?

Yes — JaCoCo is now gated behind a coverage Maven profile (commit refactor: move JaCoCo to a coverage Maven profile):

  • pom.xml: the jacoco-maven-plugin (prepare-agent + report) is in a coverage profile (activeByDefault=false). A default empty <argLine/> property is added so the @{argLine} surefire config expands safely when the profile is not active.
  • nightly-build.yml: -P"coverage" is added to the Build SNAPSHOT command — this is the only place JaCoCo runs.
  • maven.yml (regular CI): unchanged — JaCoCo is never activated there.

Copilot AI requested a review from chrjohn July 23, 2026 12:40
@chrjohn

chrjohn commented Jul 23, 2026

Copy link
Copy Markdown
Member

@copilot Non-parseable POM /Users/runner/work/quickfixj/quickfixj/pom.xml: end tag name must match start tag name from line 437 (position: TEXT seen ...\n\t\t\t... @455:14) @ line 455, column 14

Copilot AI commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Non-parseable POM /Users/runner/work/quickfixj/quickfixj/pom.xml: end tag name must match start tag name from line 437 (position: TEXT seen ...</executio...

Fixed in the latest commit. The edit that moved JaCoCo into a profile accidentally dropped the </plugin> closing tag for maven-enforcer-plugin, leaving </plugins> where </plugin> was expected.

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@chrjohn

chrjohn commented Jul 24, 2026

Copy link
Copy Markdown
Member

@copilot please move the codecov upload from the nightly build to the normal maven.yml. I think it needs to be there to correctly analyze PRs.

Copilot AI commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please move the codecov upload from the nightly build to the normal maven.yml. I think it needs to be there to correctly analyze PRs.

Done. A dedicated coverage job has been added to maven.yml (commit refactor: move Codecov upload from nightly build to maven.yml coverage job). It runs on ubuntu-latest with JDK 21, activates -P"coverage", and uploads to Codecov — so it will trigger on both pushes to production branches and on PRs. The Codecov upload and coverage profile have been removed from nightly-build.yml.

@chrjohn

chrjohn commented Jul 24, 2026

Copy link
Copy Markdown
Member

@copilot please change maven.yml so that there is no separate job where coverage data is uploaded. Instead, use only the "ubuntu-latest" job on JDK 21 for uploading coverage data. Coverage data can be generated on each job, so we do not need the "coverage" profile anymore.

Copilot AI commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please change maven.yml so that there is no separate job where coverage data is uploaded. Instead, use only the "ubuntu-latest" job on JDK 21 for uploading coverage data. Co...

Done (commit refactor: move JaCoCo to main build; upload coverage from ubuntu/JDK21 test job):

  • pom.xml: JaCoCo prepare-agent + report moved from the coverage profile into the main <build><plugins> section — runs on every job. The coverage profile is removed.
  • maven.yml: The separate coverage job is removed. The test job now has a Codecov upload step with if: matrix.os == 'ubuntu-latest' && matrix.java == 21, so only that combination uploads results.

@chrjohn
chrjohn marked this pull request as ready for review July 24, 2026 13:20
@chrjohn chrjohn added this to the QFJ 3.0.2 milestone Jul 24, 2026
@chrjohn
chrjohn merged commit 9b58948 into master Jul 24, 2026
14 checks passed
@chrjohn
chrjohn deleted the copilot/update-documentation-for-quickfix-j branch July 24, 2026 14:07
@the-thing

Copy link
Copy Markdown
Collaborator

@chrjohn

Seems that messages are still included, which is probably not desired?

@chrjohn

chrjohn commented Jul 24, 2026

Copy link
Copy Markdown
Member

@the-thing I still need to get used to their UI. Do you mean the golden source files?
I excluded

<exclude>quickfixj-messages/quickfixj-messages-*/target/classes/**</exclude>

@the-thing

Copy link
Copy Markdown
Collaborator

Yes, but it seems like it is not being picked up? Shows 0% for quickfixj-messages/quickfixj-messages-fixlatest/src/test/resources/golden/fixlatest/quickfix , I think it should not be there if excluded.

@chrjohn

chrjohn commented Jul 25, 2026

Copy link
Copy Markdown
Member

@the-thing #1286

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.

3 participants