Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
11 changes: 7 additions & 4 deletions .github/actions/scan-with-sonar/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ runs:

- name: Build project for SonarQube scan
run: |
mvn clean verify -ntp -B \
-pl cds-feature-attachments,storage-targets/cds-feature-attachments-fs,storage-targets/cds-feature-attachments-oss \
-am
mvn clean verify -ntp -B
shell: bash

- name: Verify JaCoCo reports exist
Expand All @@ -59,6 +57,11 @@ runs:
echo "Missing: $module/target/site/jacoco/jacoco.xml"
fi
done
if [ -f "coverage-report/target/site/jacoco-aggregate/jacoco.xml" ]; then
echo "Found: coverage-report/target/site/jacoco-aggregate/jacoco.xml"
else
echo "Missing: coverage-report/target/site/jacoco-aggregate/jacoco.xml"
fi
shell: bash

- name: SonarQube Scan
Expand All @@ -70,4 +73,4 @@ runs:
--githubToken=${{ inputs.github-token }}
--version=${{ steps.get-revision.outputs.REVISION }}
--inferJavaBinaries=true
--options=-Dsonar.exclusions=**/samples/**,-Dsonar.coverage.jacoco.xmlReportPaths=cds-feature-attachments/target/site/jacoco/jacoco.xml,storage-targets/cds-feature-attachments-fs/target/site/jacoco/jacoco.xml,storage-targets/cds-feature-attachments-oss/target/site/jacoco/jacoco.xml
--options=-Dsonar.exclusions=**/samples/**,-Dsonar.coverage.jacoco.xmlReportPaths=cds-feature-attachments/target/site/jacoco/jacoco.xml,storage-targets/cds-feature-attachments-fs/target/site/jacoco/jacoco.xml,storage-targets/cds-feature-attachments-oss/target/site/jacoco/jacoco.xml,coverage-report/target/site/jacoco-aggregate/jacoco.xml
2 changes: 1 addition & 1 deletion .pipeline/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ steps:
- sonar.java.source=17
- sonar.exclusions=**/node_modules/**,**/target/**,**/test/**
- sonar.modules=cds-feature-attachments,cds-feature-attachments-fs,cds-feature-attachments-oss
- sonar.coverage.jacoco.xmlReportPaths=cds-feature-attachments/target/site/jacoco/jacoco.xml,storage-targets/cds-feature-attachments-fs/target/site/jacoco/jacoco.xml,storage-targets/cds-feature-attachments-oss/target/site/jacoco/jacoco.xml
- sonar.coverage.jacoco.xmlReportPaths=cds-feature-attachments/target/site/jacoco/jacoco.xml,storage-targets/cds-feature-attachments-fs/target/site/jacoco/jacoco.xml,storage-targets/cds-feature-attachments-oss/target/site/jacoco/jacoco.xml,coverage-report/target/site/jacoco-aggregate/jacoco.xml
- sonar.coverage.exclusions=cds-feature-attachments/src/test/**,cds-feature-attachments/src/gen/**,storage-targets/cds-feature-attachments-fs/src/test/**,storage-targets/cds-feature-attachments-oss/src/test/**
- cds-feature-attachments.sonar.projectBaseDir=cds-feature-attachments
- cds-feature-attachments.sonar.sources=src/main/java
Expand Down
176 changes: 176 additions & 0 deletions coverage-report/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.sap.cds</groupId>
<artifactId>cds-feature-attachments-root</artifactId>
<version>${revision}</version>
</parent>

<artifactId>cds-feature-attachments-coverage-report</artifactId>
<packaging>pom</packaging>

<name>CDS Feature for Attachments - Coverage Report</name>
<description>Aggregated JaCoCo coverage report combining unit tests and integration tests.</description>

<!-- Dependencies whose coverage data and classes are included in the aggregated report -->
<dependencies>
<!-- Source module to measure coverage for -->
<dependency>
<groupId>com.sap.cds</groupId>
<artifactId>cds-feature-attachments</artifactId>
Comment thread
Schmarvinius marked this conversation as resolved.
</dependency>

<!-- Module that produces additional coverage data via @SpringBootTest -->
<dependency>
<groupId>com.sap.cds.integration-tests</groupId>
<artifactId>cds-feature-attachments-integration-tests-srv</artifactId>
<version>${revision}</version>
</dependency>
Comment thread
Schmarvinius marked this conversation as resolved.
</dependencies>

<build>
<plugins>
<!-- Do not deploy this module -->
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>

<!-- Skip static analysis β€” this module has no source code -->
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>

<!--
Copy core module's compiled classes into this module's target/classes.
This uses the exact same class files that were instrumented at runtime,
avoiding JaCoCo "classes do not match" warnings that occur when
unpacking from the JAR artifact.
-->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>copy-core-classes</id>
<goals>
<goal>copy-resources</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/../cds-feature-attachments/target/classes</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<!-- Aggregate HTML/XML/CSV report from all dependency modules -->
<execution>
<id>jacoco-aggregate-report</id>
<goals>
<goal>report-aggregate</goal>
</goals>
<phase>verify</phase>
<configuration>
<dataFileExcludes>
<dataFileExclude>**/integration-tests/db/**</dataFileExclude>
</dataFileExcludes>
Comment thread
Schmarvinius marked this conversation as resolved.
Outdated
</configuration>
</execution>

<!-- Merge .exec files from unit tests and integration tests into one -->
<execution>
<id>jacoco-merge</id>
<goals>
<goal>merge</goal>
</goals>
<phase>verify</phase>
Comment thread
Schmarvinius marked this conversation as resolved.
Outdated
<configuration>
<fileSets>
<fileSet>
<directory>${project.basedir}/../cds-feature-attachments/target</directory>
<includes>
<include>jacoco.exec</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/../integration-tests/srv/target</directory>
<includes>
<include>jacoco.exec</include>
</includes>
</fileSet>
</fileSets>
<destFile>${project.build.directory}/jacoco-merged.exec</destFile>
</configuration>
</execution>

<!-- Enforce coverage thresholds on the merged data -->
<execution>
<id>jacoco-check-aggregated</id>
<goals>
<goal>check</goal>
</goals>
<phase>verify</phase>
<configuration>
<dataFile>${project.build.directory}/jacoco-merged.exec</dataFile>
<excludes>
<exclude>${excluded.generation.package}**/*</exclude>
</excludes>
<rules>
<rule implementation="org.jacoco.maven.RuleConfiguration">
<element>BUNDLE</element>
<limits>
<limit implementation="org.jacoco.report.check.Limit">
<counter>INSTRUCTION</counter>
<value>COVEREDRATIO</value>
<minimum>0.95</minimum>
</limit>
<limit implementation="org.jacoco.report.check.Limit">
<counter>BRANCH</counter>
<value>COVEREDRATIO</value>
<minimum>0.95</minimum>
</limit>
<limit implementation="org.jacoco.report.check.Limit">
<counter>COMPLEXITY</counter>
<value>COVEREDRATIO</value>
<minimum>0.95</minimum>
</limit>
<limit implementation="org.jacoco.report.check.Limit">
<counter>CLASS</counter>
<value>MISSEDCOUNT</value>
<maximum>0</maximum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
12 changes: 12 additions & 0 deletions integration-tests/srv/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
4 changes: 3 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<module>storage-targets/cds-feature-attachments-fs</module>
<module>storage-targets/cds-feature-attachments-oss</module>
<module>integration-tests</module>
<module>coverage-report</module>
</modules>

<scm>
Expand Down Expand Up @@ -406,6 +407,7 @@
<excludeArtifact>cds-feature-attachments-integration-tests-parent</excludeArtifact>
<excludeArtifact>cds-feature-attachments-integration-tests-db</excludeArtifact>
<excludeArtifact>cds-feature-attachments-integration-tests-srv</excludeArtifact>
<excludeArtifact>cds-feature-attachments-coverage-report</excludeArtifact>
</excludeArtifacts>
</configuration>
</plugin>
Expand All @@ -418,7 +420,7 @@
<module>cds-feature-attachments</module>
<module>storage-targets/cds-feature-attachments-fs</module>
<module>storage-targets/cds-feature-attachments-oss</module>
<!-- Exclude integration-tests modules -->
<!-- Exclude integration-tests and coverage-report modules -->
</modules>
Comment thread
Schmarvinius marked this conversation as resolved.
</profile>
</profiles>
Expand Down
Loading