Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# Diff-Coverage Maven plugin

## 0.4.0

### Added
- Support min coverage threshold.
- If changed entity number is below the threshold, then coverage check for the entity will be skipped.
```xml
<violations>
<rules>
<rule>
<coverageEntity>INSTRUCTION</coverageEntity>
<minCoverageRatio>0.9</minCoverageRatio>
<entityCountThreshold>20</entityCountThreshold>
</rule>
<rule>
<coverageEntity>BRANCH</coverageEntity>
<minCoverageRatio>0.8</minCoverageRatio>
<entityCountThreshold>3</entityCountThreshold>
</rule>
</rules>
</violations>
```

### Deprecated
- `<minLines>`, `<minBranches>`, `<minInstructions>` are deprecated.
- Use `<minCoverage>` or `<rules>` instead.

## 0.3.3

### Fixes
Expand Down
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,26 @@ The plugin does the next steps:
<minCoverage>0.7</minCoverage>

<!-- Each rule could be configured separately -->
<!-- Default '0.0'. If value is '0.0' then the rule is disabled -->
<minLines>0.1</minLines>
<minBranches>0.7</minBranches>
<minInstructions>1.0</minInstructions>
<rules>
<rule>
<coverageEntity>INSTRUCTION</coverageEntity>
<!-- Default '0.0'. If value is '0.0' then the rule is disabled -->
<minCoverageRatio>1.0</minCoverageRatio>
<!-- Default 'null'.
If changed entity number is below the threshold,
then coverage check for the entity will be skipped. -->
<entityCountThreshold>20</entityCountThreshold>
</rule>
<rule>
<coverageEntity>BRANCH</coverageEntity>
<minCoverageRatio>1.0</minCoverageRatio>
<entityCountThreshold>3</entityCountThreshold>
</rule>
<rule>
<coverageEntity>LINE</coverageEntity>
<minCoverageRatio>1.0</minCoverageRatio>
</rule>
</rules>
</violations>

<!-- Optional. Exec files include pattern. By default 'build/jacoco.exec' file is used -->
Expand Down
50 changes: 38 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<artifactId>diff-coverage-maven-plugin</artifactId>
<name>${project.groupId}:${project.artifactId}</name>
<packaging>maven-plugin</packaging>
<version>0.3.3</version>
<version>0.4.0-SNAPSHOT</version>
<description>
Diff coverage maven plugin builds code coverage report of new and modified code based on a provided diff
</description>
Expand Down Expand Up @@ -55,18 +55,20 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kotlin.code.style>official</kotlin.code.style>
<diff.source>HEAD</diff.source>

<maven.version>3.9.4</maven.version>
<maven.plugin.tools.version>3.9.0</maven.plugin.tools.version>

<kotlin.version>1.4.32</kotlin.version>
<kotlin.code.style>official</kotlin.code.style>
<kotlin.version>1.9.10</kotlin.version>
<kotlin.compiler.jvmTarget>11</kotlin.compiler.jvmTarget>
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
<junit.version>4.13.2</junit.version>

<junit.version>5.10.0</junit.version>
<kotest.version>5.7.2</kotest.version>
<jacoco.version>0.8.10</jacoco.version>
<delt.coverage.core.version>0.9.5</delt.coverage.core.version>
<delta.coverage.core.version>1.2.0</delta.coverage.core.version>
<diff.coverage.plugin.version>0.3.2</diff.coverage.plugin.version>
</properties>

Expand All @@ -78,6 +80,18 @@
</pluginRepository>
</pluginRepositories>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down Expand Up @@ -111,9 +125,9 @@
</dependency>

<dependency>
<groupId>com.github.form-com.diff-coverage-gradle</groupId>
<groupId>com.github.SurpSG.delta-coverage-plugin</groupId>
<artifactId>jacoco-filtering-extension</artifactId>
<version>${delt.coverage.core.version}</version>
<version>${delta.coverage.core.version}</version>
</dependency>
<dependency>
<groupId>org.jacoco</groupId>
Expand All @@ -138,15 +152,21 @@
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.kotest</groupId>
<artifactId>kotest-runner-junit5-jvm</artifactId>
<version>${kotest.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
Expand Down Expand Up @@ -177,7 +197,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<version>0.8.10</version>
<executions>
<execution>
<id>pre-unit-test</id>
Expand Down Expand Up @@ -233,14 +253,15 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.3.0</version>
<version>3.6.0</version>
<configuration>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<postBuildHookScript>verify</postBuildHookScript>
<preBuildHookScript>setup</preBuildHookScript>
<addTestClassPath>true</addTestClassPath>
<showErrors>true</showErrors>
<streamLogsOnFailures>true</streamLogsOnFailures>
<parallelThreads>2</parallelThreads>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
<pomExcludes>
<!-- Temporary exclude this tests.
Expand All @@ -256,6 +277,10 @@
<goal>install</goal>
</goals>
<settingsFile>src/it/settings.xml</settingsFile>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
</configuration>
<executions>
<execution>
Expand All @@ -266,6 +291,7 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>com.github.surpsg</groupId>
<artifactId>diff-coverage-maven-plugin</artifactId>
Expand Down
6 changes: 1 addition & 5 deletions src/it/exclude-classes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
<artifactId>it-check-passes</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
Expand All @@ -38,6 +33,7 @@
<plugin>
<groupId>com.github.surpsg</groupId>
<artifactId>diff-coverage-maven-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<diffSource>
<file>diffFile.patch</file>
Expand Down
6 changes: 1 addition & 5 deletions src/it/excluded-all-classes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
<artifactId>it-check-passes</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
Expand All @@ -38,6 +33,7 @@
<plugin>
<groupId>com.github.surpsg</groupId>
<artifactId>diff-coverage-maven-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<diffSource>
<file>diffFile.patch</file>
Expand Down

This file was deleted.

17 changes: 0 additions & 17 deletions src/it/fail-on-duplicated-coverage-config-check/verify.bsh

This file was deleted.

6 changes: 1 addition & 5 deletions src/it/git-diff-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
<artifactId>it-check-passes</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
Expand All @@ -38,6 +33,7 @@
<plugin>
<groupId>com.github.surpsg</groupId>
<artifactId>diff-coverage-maven-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<diffSource>
<git>HEAD</git>
Expand Down
6 changes: 1 addition & 5 deletions src/it/include-classes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
<artifactId>it-check-passes</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
Expand All @@ -38,6 +33,7 @@
<plugin>
<groupId>com.github.surpsg</groupId>
<artifactId>diff-coverage-maven-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<diffSource>
<file>diffFile.patch</file>
Expand Down
6 changes: 1 addition & 5 deletions src/it/include-exclude-classes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
<artifactId>it-check-passes</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
Expand All @@ -38,6 +33,7 @@
<plugin>
<groupId>com.github.surpsg</groupId>
<artifactId>diff-coverage-maven-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<diffSource>
<file>diffFile.patch</file>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.debug = true
5 changes: 0 additions & 5 deletions src/it/multi-module-reports-exclusions-check/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<plugin>
<groupId>com.github.surpsg</groupId>
<artifactId>diff-coverage-maven-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<diffSource>
<file>diffFile.patch</file>
Expand Down
8 changes: 4 additions & 4 deletions src/it/multi-module-reports-exclusions-check/verify.bsh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import java.io.*;
import org.codehaus.plexus.util.*;

File reportsDir = new File(basedir, "/report/target/site/diffCoverage");
File reportsDir = new File(basedir, "/report/target/site/deltaCoverage");
File htmlReportDir = new File( reportsDir, "/html" );
if ( !htmlReportDir.exists() || !htmlReportDir.isDirectory() ) {
throw new RuntimeException( "Html report dir wasn't found: " + htmlReportDir.getAbsolutePath() );
Expand All @@ -17,9 +17,9 @@ if ( !csvReportFile.exists() || !csvReportFile.isFile() ) {
throw new RuntimeException( "CSV report file wasn't found: " + csvReportFile.getAbsolutePath() );
}

String expectedInstructionsErrMsg = "[INFO] New violation: Rule violated for bundle multi-module-reports-exclusions-check: instructions covered ratio is 0.5, but expected minimum is 0.6";
String expectedLinesErrMsg = "[INFO] New violation: Rule violated for bundle multi-module-reports-exclusions-check: lines covered ratio is 0.5, but expected minimum is 0.7";
String unexpectedBranchesErrMsg = "[INFO] New violation: Rule violated for bundle multi-module-reports-exclusions-check: branches covered ratio";
String expectedInstructionsErrMsg = "New violation: Rule violated for bundle multi-module-reports-exclusions-check: instructions covered ratio is 0.5, but expected minimum is 0.6";
String expectedLinesErrMsg = "New violation: Rule violated for bundle multi-module-reports-exclusions-check: lines covered ratio is 0.5, but expected minimum is 0.7";
String unexpectedBranchesErrMsg = "New violation: Rule violated for bundle multi-module-reports-exclusions-check: branches covered ratio";

String buildLog = FileUtils.fileRead( new File( basedir, "build.log" ) );
if ( !buildLog.contains( expectedInstructionsErrMsg ) ) {
Expand Down
5 changes: 0 additions & 5 deletions src/it/multi-module-reports-generation-check/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<plugin>
<groupId>com.github.surpsg</groupId>
<artifactId>diff-coverage-maven-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<diffSource>
<file>diffFile.patch</file>
Expand Down
2 changes: 1 addition & 1 deletion src/it/multi-module-reports-generation-check/verify.bsh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import java.io.*;
import org.codehaus.plexus.util.*;

File reportsDir = new File(basedir, "/report/target/site/diffCoverage");
File reportsDir = new File(basedir, "/report/target/site/deltaCoverage");
File htmlReportDir = new File( reportsDir, "/html" );
if ( !htmlReportDir.exists() || !htmlReportDir.isDirectory() ) {
throw new RuntimeException( "Html report dir wasn't found: " + htmlReportDir.getAbsolutePath() );
Expand Down
Loading