Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JaCoCo for Code Coverage Reports in Pass Core #107

Merged
merged 9 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 7 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
87 changes: 87 additions & 0 deletions jacoco-aggregate-report/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?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>org.eclipse.pass</groupId>
<artifactId>pass-core</artifactId>
<version>1.14.0-SNAPSHOT</version>
</parent>

<artifactId>jacoco-aggregate-report</artifactId>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since pass-core-main depends on all other modules already, did you try putting this jacoco pom config (report-aggregate) into the pass-core-main module pom? I wonder if that may be better if it works so that we don't add another module to pass-core? I know there has been talk about wanting to consolidate the modules into one for pass-core.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I'd like to eventually consolidate all the pass-core modules. I don't think the separation has much point. I agree about using pass-core main if possible. In fact I was wondering if it would work in the pass root module to just cover everything.

Copy link
Contributor Author

@tsande16 tsande16 Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rpoet-jh I will give this a shot and see what happens. I followed this setup from JaCoCo

From my understanding the report aggregation needs to be it's own separate module. When I originally tried doing this I tried setting the project POM to be the aggregator, but that didn't work. From my reading of the docs, if it was setup in pass-core-main it wouldn't generate a report for pass-core-main, but would only collect from the other submodules and place the aggregated report in pass-core-main.

Copy link
Contributor Author

@tsande16 tsande16 Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markpatton @rpoet-jh This is what happens when I move the aggregation to pass-core-main. It won't create a report for pass-core-main. I've tried playing around with different phases, scopes, with/without the agent in pass-core-main.

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks for trying. When we consolidate the modules in pass-core, we can revisit. I'm fine leaving it like this for now, @markpatton any objection?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rpoet-jh @tsande16 No. Let's go for it.

<packaging>pom</packaging>

<properties>
<maven.compiler.source>23</maven.compiler.source>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pass-core uses java 17 atm.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. It's interesting that IntelliJ generated that even though my project is set to 17.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rpoet-jh I'm reviewing this and it seems like some modules have this property set and other do not. It looks like the majority do not have it set. Should I remove this property altogether?

Copy link
Contributor Author

@tsande16 tsande16 Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the only other POM that has it is in the pass-core-policy submodule. And I'm assuming all this will be inherited from pass-main POM:

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
  <release>17</release>
</configuration>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rpoet-jh I'm reviewing this and it seems like some modules have this property set and other do not. It looks like the majority do not have it set. Should I remove this property altogether?

Yeah, I think maven.compiler.source and maven.compiler.target should be removed. Like you said, release will be inherited from the main pom plugin config.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

<maven.compiler.target>23</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.eclipse.pass</groupId>
<artifactId>pass-core-doi-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.pass</groupId>
<artifactId>pass-core-file-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.pass</groupId>
<artifactId>pass-core-metadataschema-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.pass</groupId>
<artifactId>pass-core-main</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-tree</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.pass</groupId>
<artifactId>pass-core-object-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.pass</groupId>
<artifactId>pass-core-policy-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.pass</groupId>
<artifactId>pass-core-user-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.pass</groupId>
<artifactId>pass-core-usertoken</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<executions>
<execution>
<id>report-aggregate</id>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
19 changes: 19 additions & 0 deletions pass-core-doi-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,23 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
21 changes: 20 additions & 1 deletion pass-core-file-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>pass-core</artifactId>
<groupId>org.eclipse.pass</groupId>
<artifactId>pass-core</artifactId>
<version>1.14.0-SNAPSHOT</version>
</parent>

Expand Down Expand Up @@ -60,4 +60,23 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ public class FileStorageService {

/**
* FileStorageService Class constructor.
*
* @param ocflRepository ocfl object that is a layer to handle the io of the files
* @param storageProperties properties indicating where and what type of storage is used for persistence.
* @param rootLoc path of the root location used to set up temp working directory for the File Service
*/
public FileStorageService(OcflRepository ocflRepository,
StorageProperties storageProperties,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ public class StorageConfiguration {
@Value("${aws.region}")
private String awsRegion;

/**
* Creates and configures an S3TransferManager for managing file transfers to Amazon S3.
*
* @return a configured S3TransferManager instance.
*/
@Bean
@ConditionalOnProperty(name = "pass.file-service.storage-type", havingValue = "S3")
public S3TransferManager s3TransferManager() {
Expand All @@ -72,6 +77,13 @@ public S3TransferManager s3TransferManager() {
.build();
}

/**
* Creates and configures an S3AsyncClient for interacting with Amazon S3 or an S3-compatible storage service.
*
* @param storageProperties the StorageProperties containing the configuration.
* @return a configured S3AsyncClient instance.
* @throws IOException if the S3 bucket name is not set in StorageProperties.
*/
@Bean
@ConditionalOnProperty(name = "pass.file-service.storage-type", havingValue = "S3")
public S3AsyncClient s3Client(StorageProperties storageProperties) throws IOException {
Expand All @@ -93,6 +105,17 @@ public S3AsyncClient s3Client(StorageProperties storageProperties) throws IOExce
return s3Client;
}

/**
* Creates and configures an OcflRepository instance for use with Amazon S3 as the storage backend.
*
* @param s3Client the S3AsyncClient for interacting with Amazon S3.
* @param s3TransferManager the S3TransferManager to manage file transfers to S3.
* @param storageProperties the StorageProperties containing the configuration.
* @param rootLoc the root Path for the file service.
* @return a OcflRepository instance, using S3 as the storage layer.
* @throws IOException if the S3 bucket name is not set in the StorageProperties, or if there are
* issues creating or accessing the working directory.
*/
@Bean
@ConditionalOnProperty(name = "pass.file-service.storage-type", havingValue = "S3")
public OcflRepository ocflS3Repository(S3AsyncClient s3Client, S3TransferManager s3TransferManager,
Expand Down Expand Up @@ -121,6 +144,17 @@ public OcflRepository ocflS3Repository(S3AsyncClient s3Client, S3TransferManager
return ocflRepository;
}

/**
* Creates and configures an {@link OcflRepository} instance when the file service storage type
* is set to "FILE_SYSTEM". This method ensures that the OCFL directory exists, is accessible,
* and is properly set up with the required permissions.
*
* @param storageProperties the StorageProperties object containing storage configurations.
* @param rootLoc the root Path where the OCFL directory will be created or accessed.
* @return a fully configured OcflRepository instance backed by a file system storage type.
* @throws IOException if the OCFL directory cannot be created, or if there are insufficient
* read/write permissions.
*/
@Bean
@ConditionalOnProperty(name = "pass.file-service.storage-type", havingValue = "FILE_SYSTEM")
public OcflRepository ocflFileRepository(StorageProperties storageProperties,
Expand All @@ -142,6 +176,13 @@ public OcflRepository ocflFileRepository(StorageProperties storageProperties,
return ocflRepository;
}

/**
* Configures and provides the root Path for the file service storage.
*
* @param storageProperties the StorageProperties object containing storage configuration details.
* @return the root Path for the storage system.
* @throws IOException if an error occurs while creating the temporary directory.
*/
@Bean
@Qualifier("rootPath")
public Path rootPath(StorageProperties storageProperties) throws IOException {
Expand Down
14 changes: 14 additions & 0 deletions pass-core-main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,20 @@
<artifactId>cyclonedx-maven-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>
</project>
18 changes: 18 additions & 0 deletions pass-core-metadataschema-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,22 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
19 changes: 19 additions & 0 deletions pass-core-object-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,23 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
18 changes: 18 additions & 0 deletions pass-core-policy-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,22 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
19 changes: 19 additions & 0 deletions pass-core-user-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,23 @@
<version>${jakarta.json.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
19 changes: 19 additions & 0 deletions pass-core-usertoken/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,23 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Loading
Loading