[
https://issues.apache.org/jira/browse/OAK-12397?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18114248#comment-18114248
]
Manfred Baedke edited comment on OAK-12397 at 9/11/26 1:36 PM:
---------------------------------------------------------------
That is a very good idea. I'd to not just enforce it using Sonar on the PRs,
but already on the local build. AI recommends Maven Enforce per Groovy-Skript,
see attachment.
was (Author: baedke):
That is a very good idea. I'd to not just enforce it using Sonar on the PRs,
but already on the local build. AI recommends Maven Enforce per Groovy-Skript:
{code:java}
<properties> <!-- Define the global threshold here and increase it
step-by-step over time -->
<global.minimum.line.coverage>65.5</global.minimum.line.coverage> </properties>
<build> <plugins> <plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId> <executions>
<execution> <id>check-global-coverage</id>
<phase>verify</phase> <goals>
<goal>execute</goal> </goals>
<configuration> <scripts>
<script> <![CDATA[
def csvFile = new File(project.basedir,
'target/site/jacoco-aggregate/jacoco.csv') if
(!csvFile.exists()) { log.warn("No
aggregated jacoco.csv found. Skipping global coverage check.")
return }
int linesMissed = 0 int
linesCovered = 0 // Parse CSV. Index 7 =
LINE_MISSED, Index 8 = LINE_COVERED
csvFile.splitEachLine(',') { fields -> if
(fields[0] != 'GROUP') { // Skip header row
linesMissed += (fields[7] as Integer)
linesCovered += (fields[8] as Integer) }
} def
totalLines = linesMissed + linesCovered if
(totalLines == 0) { log.warn("No evaluable
lines of code found.") return
} double coverage =
(linesCovered / totalLines) * 100 double
threshold =
Double.parseDouble(project.properties.getProperty('global.minimum.line.coverage',
'0.0')) log.info(String.format("Global line
coverage: %.2f%% (Target: %.2f%%)", coverage, threshold))
if (coverage < threshold) {
throw new org.apache.maven.plugin.MojoFailureException(
String.format("Build failed: Global line coverage (%.2f%%) is
below the required minimum of %.2f%%.", coverage, threshold)
) }
]]> </script>
</scripts> </configuration> </execution>
</executions> </plugin> </plugins> </build>
{code}
> Enforce test coverage
> ---------------------
>
> Key: OAK-12397
> URL: https://issues.apache.org/jira/browse/OAK-12397
> Project: Jackrabbit Oak
> Issue Type: Task
> Reporter: Julian Reschke
> Assignee: Julian Reschke
> Priority: Minor
> Attachments: global-coverage-check.xml
>
>
> Now that we have Sonar complaining about code coverage <80% for new code, I'd
> like to restart enforcing that coverage does not go down (and also regularly
> bump the coverage target once it improves)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)