What the agent does
The agent reads the build before it adds a tool, because in a project like spring-projects/spring-petclinic the coverage data is already there and nobody looks at it. pom.xml configures jacoco-maven-plugin 0.8.15 with two executions, prepare-agent and a report goal bound to prepare-package, so every ./mvnw verify writes target/site/jacoco/ with index.html, jacoco.xml and jacoco.csv. .github/workflows/maven-build.yml runs ./mvnw -B verify on push and pull request to main with Java 17 and then ends: no artifact, no summary, no threshold, so the report is built on every run and discarded with the runner. The test side is twenty classes under src/test/java/, among them MySqlIntegrationTests with @Testcontainers(disabledWithoutDocker = true) and PostgresIntegrationTests on Docker Compose, which means a verify on a machine without Docker runs the H2-backed suite and skips those; gradle-build.yml runs ./gradlew build, and build.gradle has Checkstyle and the format plugin but no JaCoCo, so this change stays on the Maven side.
In its sandbox the agent runs ./mvnw -B verify on Java 17 first, to read the numbers it will write into the configuration: 79 tests run with the 2 MySQL ones skipped, and a report over 22 classes with 313 of 333 lines and 100 of 122 branches covered, which the agent reads from jacoco.csv rather than guessing from the HTML; the lowest class is PetClinicRuntimeHints, native-image hints with nothing a unit test reaches. Those figures set the floor: a check execution on the same plugin, bound to verify, with a BUNDLE rule of LINE COVEREDRATIO at a minimum a few points below today's figure, so the build fails only when coverage actually drops, and an exclusion for the runtime-hints class so the floor measures code a test can reach.
Then the workflow. After the verify step, maven-build.yml gets a step that uploads target/site/jacoco/ with actions/upload-artifact@v7, named for the run, and a step that reads jacoco.csv with awk, sums the LINE_MISSED and LINE_COVERED columns and writes a two-line table of lines and branches covered into $GITHUB_STEP_SUMMARY, so the number shows on the workflow page of every pull request with no third-party action and no token. The check goal is what fails the job on a drop; the summary is what a reviewer reads. The agent keeps the existing actions/checkout@v4 and actions/setup-java@v4 lines and the adopt distribution as they are, pins the upload action by major tag like its neighbours, and leaves gradle-build.yml alone, naming a JaCoCo Gradle plugin as the follow-up if the team wants both builds to agree.
To close, the agent runs ./mvnw -B verify again with the check goal in place and pastes the jacoco:check line that reports the rule passed, then runs the awk summary step locally against the fresh jacoco.csv to show the exact table the workflow will print. It also runs the check once with the minimum set above today's figure, to show the failure message a reviewer will see when coverage drops, and keeps that output in the pull request as the demonstration that the floor bites.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Add coverage reporting to CI for this Maven Spring Boot project. Read pom.xml, .github/workflows/maven-build.yml, .github/workflows/gradle-build.yml, build.gradle, and the test classes under src/test/java, noting which need Docker. JaCoCo already writes target/site/jacoco on verify; do not add another coverage tool. Run ./mvnw -B verify on Java 17 in the sandbox, read the totals from jacoco.csv, and add a jacoco check execution bound to verify with a BUNDLE LINE COVEREDRATIO minimum a few points below today's line coverage, excluding the native-image RuntimeHints class. In maven-build.yml, after the verify step, upload target/site/jacoco with actions/upload-artifact pinned by major tag, and add a step that sums LINE and BRANCH columns of jacoco.csv with awk into GITHUB_STEP_SUMMARY as a small table. Do not change the existing steps or gradle-build.yml; name a Gradle JaCoCo plugin as a follow-up. Run verify again to show the check passing, run the awk step locally to show the table, and run the check once with the minimum above today's figure to show the failure. Open a pull request that pastes those outputs and the coverage totals.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
What comes back is a pull request that changes two files: pom.xml, where the JaCoCo plugin gains a check execution with its rule and the exclusion, and .github/workflows/maven-build.yml, which gains an upload step and a summary step after verify. The description quotes the test and coverage totals the agent read from jacoco.csv, the jacoco:check line from the passing run, the summary table as the workflow will print it, and the failure output from the deliberately high minimum.
The run's record holds both Maven runs with their test output, including the MySQL tests skipped for want of Docker, and the awk command and its table, so a reviewer sees where the floor came from and what the job summary will look like before the workflow runs on GitHub.
Before merging, a reviewer decides whether the floor should be a line ratio, a branch ratio or both, whether any other class belongs in the exclusion, and whether the Gradle build should get the same report. Then CI runs on the pull request itself, uploads the report and prints the summary for the first time.
Run it on every pull request
Once the floor is in, every pull request's maven-build.yml run uploads the report and prints the table on its own, with no run needed. To act on a drop, create an automation in the Project with a github trigger on workflow_run.failure and the prompt "if the failed workflow is Java CI with Maven and the log shows jacoco:check failing, say which classes lost coverage against main and write the missing tests"; the trigger adds the event after the prompt, and only work by an owner, member or collaborator fires it, never a fork's.
A nightly schedule trigger with this project's prompt pointed at the lowest classes in jacoco.csv turns the same report into the next pull request of tests. Each run opens one pull request on its own branch, and the automation's max_runs_per_hour keeps a mis-set schedule from starting more than one.
The use case this job follows, with its automation and trigger: Write the missing tests.
Why run it on Rush?
The report is already built on every run; the work is reading it, choosing a floor from the real numbers, and getting it in front of a reviewer without another service or token. Done by hand that means a local verify with the Docker-backed tests skipped, a CSV to add up, a plugin execution to get the goal and phase right, and a workflow step nobody tests until it runs. The agent does all of that in its own sandbox on the project's Java 17 and pins the floor to what the suite covers today, so the first pull request with the check already passes it.
Every command and its output stays on the run, including the failure the agent provoked to show the floor works. Several Maven services can get the same treatment at once, each in its own sandbox, each floor read from that service's own report.
Frequently asked questions
Why not a coverage service or a PR comment action?
Because the report, the floor and the summary are all available from the build and the workflow's own step summary, with no token and no third-party action. The artifact gives a reviewer the full HTML report, jacoco:check fails the job on a drop, and the table on the workflow page shows the number. A service with history graphs is a separate decision and the pull request says so.
Where does the minimum come from?
From jacoco.csv after a real verify in the sandbox: the agent sums the LINE_MISSED and LINE_COVERED columns and sets the floor a few points below the ratio it finds, so today's suite passes and a drop fails. The exact number is in the pull request beside the totals it was read from.
What about the tests that need Docker?
MySqlIntegrationTests is disabled without Docker and PostgresIntegrationTests runs no test without Compose, so a sandbox and a runner without Docker both measure the H2-backed suite. The floor is read from that run, which is what maven-build.yml measures too, and the pull request says that a runner with Docker would report slightly more.
Why exclude the RuntimeHints class?
It registers native-image hints that run only under GraalVM, so no unit test reaches it and it sits at zero in the report. Leaving it in makes the floor a little lower for no reason; excluding it in the check rule keeps the report complete and the floor about code a test can cover.
Does the Gradle build get the same check?
Not in this pull request. build.gradle has no JaCoCo configuration, so adding it is a second change with its own plugin and tasks; the description names it as the follow-up so the two builds can enforce the same floor.