From ae63f5644d9cdda27ba97c927800a6695d58e4fe Mon Sep 17 00:00:00 2001 From: Paul Flynn Date: Wed, 16 Oct 2024 10:29:36 -0400 Subject: [PATCH 1/8] Add JaCoCo and SonarCloud integration Introduce a new Maven profile for JaCoCo test coverage reporting in the `pom.xml`. Additionally, update the GitHub Actions workflow to include a SonarCloud scan that uses the JaCoCo coverage data. --- .github/workflows/checks.yaml | 21 +++++++++++++++++++-- pom.xml | 31 +++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index fa06679e..78038191 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -42,11 +42,28 @@ jobs: distribution: "adopt" server-id: github - name: Maven Verify - run: | - mvn --batch-mode verify + run: mvn --batch-mode verify + env: + BUF_INPUT_HTTPS_USERNAME: opentdf-bot + BUF_INPUT_HTTPS_PASSWORD: ${{ secrets.PERSONAL_ACCESS_TOKEN_OPENTDF }} + + sonarcloud: + name: SonarCloud Scan + runs-on: ubuntu-22.04 + steps: + - name: Check out repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - name: Set up JDK + uses: actions/setup-java@5896cecc08fd8a1fbdfaf517e29b571164b031f7 + with: + java-version: "11" + distribution: "adopt" + server-id: github + - name: Maven Test Coverage env: BUF_INPUT_HTTPS_USERNAME: opentdf-bot BUF_INPUT_HTTPS_PASSWORD: ${{ secrets.PERSONAL_ACCESS_TOKEN_OPENTDF }} + run: mvn --batch-mode clean sonar:sonar -P coverage platform-integration: runs-on: ubuntu-22.04 diff --git a/pom.xml b/pom.xml index 3307b7e1..43a7ecb3 100644 --- a/pom.xml +++ b/pom.xml @@ -342,5 +342,36 @@ + + coverage + + + + org.jacoco + jacoco-maven-plugin + 0.8.12 + + + prepare-agent + + prepare-agent + + + + report + + report + + + + XML + + + + + + + + \ No newline at end of file From 8eac970b04be1d8a268d8a384aeb01dd5928aa6b Mon Sep 17 00:00:00 2001 From: Paul Flynn Date: Wed, 16 Oct 2024 10:44:23 -0400 Subject: [PATCH 2/8] Add SonarCloud configuration to coverage profile This commit adds necessary properties for integrating SonarCloud to the Maven coverage profile. It includes organization, project key, and host URL settings for SonarCloud. --- pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pom.xml b/pom.xml index 43a7ecb3..f7f8cec4 100644 --- a/pom.xml +++ b/pom.xml @@ -344,6 +344,11 @@ coverage + + opentdf + opentdf_java-sdk + https://sonarcloud.io + From 1a30f44d60f686db9b9a99418df6b31894cd84e7 Mon Sep 17 00:00:00 2001 From: Paul Flynn Date: Wed, 16 Oct 2024 10:47:26 -0400 Subject: [PATCH 3/8] Update Java version and distribution in GitHub Actions Upgraded JDK version from 11 to 17 and changed the distribution from 'adopt' to 'temurin' in the checks workflow. This ensures compatibility with newer Java features and improves build stability. --- .github/workflows/checks.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 78038191..ab78a57f 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -56,8 +56,8 @@ jobs: - name: Set up JDK uses: actions/setup-java@5896cecc08fd8a1fbdfaf517e29b571164b031f7 with: - java-version: "11" - distribution: "adopt" + java-version: "17" + distribution: "temurin" server-id: github - name: Maven Test Coverage env: From 06288b5161d44da52d8cae736b66831f84bbcdd2 Mon Sep 17 00:00:00 2001 From: Paul Flynn Date: Wed, 16 Oct 2024 10:53:05 -0400 Subject: [PATCH 4/8] Change Maven goal from sonar to verify in CI workflow Update the CI workflow to run `mvn clean verify` instead of `mvn clean sonar:sonar`. This ensures that the build verification process is executed, aligning the workflow with standard Maven practices. --- .github/workflows/checks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index ab78a57f..3c6cd196 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -63,7 +63,7 @@ jobs: env: BUF_INPUT_HTTPS_USERNAME: opentdf-bot BUF_INPUT_HTTPS_PASSWORD: ${{ secrets.PERSONAL_ACCESS_TOKEN_OPENTDF }} - run: mvn --batch-mode clean sonar:sonar -P coverage + run: mvn --batch-mode clean verify -P coverage platform-integration: runs-on: ubuntu-22.04 From e9ea01b18dfc2a38161d5ca678f6f25aff60f00c Mon Sep 17 00:00:00 2001 From: Paul Flynn Date: Wed, 16 Oct 2024 11:09:37 -0400 Subject: [PATCH 5/8] Add coverage module and configure report generation Included SDK module in the coverage profile and added multiple reporting phases in the Maven Surefire plugin. This enhances the testing process by generating and aggregating coverage reports at different stages of the build lifecycle. --- pom.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pom.xml b/pom.xml index f7f8cec4..9a6d1e08 100644 --- a/pom.xml +++ b/pom.xml @@ -344,6 +344,9 @@ coverage + + sdk + opentdf opentdf_java-sdk @@ -360,10 +363,12 @@ prepare-agent prepare-agent + report-aggregate report + test report @@ -373,6 +378,13 @@ + + post-test-report + prepare-package + + report + + From 84650d9ebe00172a0b0b93ec2292382d5423fe2c Mon Sep 17 00:00:00 2001 From: Paul Flynn Date: Wed, 16 Oct 2024 11:32:33 -0400 Subject: [PATCH 6/8] Add Buf setup action to GitHub workflow This integrates the Buf setup action in the checks workflow. The action will be configured using the GitHub token for authentication. This change ensures proper configuration for projects using Buf. --- .github/workflows/checks.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 3c6cd196..2514fc71 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -53,6 +53,9 @@ jobs: steps: - name: Check out repository uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: bufbuild/buf-setup-action@2211e06e8cf26d628cda2eea15c95f8c42b080b3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} - name: Set up JDK uses: actions/setup-java@5896cecc08fd8a1fbdfaf517e29b571164b031f7 with: From 7d3e3bbcddc262f7ffe8effb2898ec1d6d6b33c3 Mon Sep 17 00:00:00 2001 From: Paul Flynn Date: Wed, 16 Oct 2024 11:56:45 -0400 Subject: [PATCH 7/8] Add Jacoco Maven plugin for code coverage reporting This commit integrates the Jacoco Maven plugin into the project for better code coverage reporting. It configures specific goals and phases to prepare the agent and generate XML reports during the test phase. This change enhances code quality monitoring and facilitates thorough testing practices. --- pom.xml | 1 + sdk/pom.xml | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/pom.xml b/pom.xml index 9a6d1e08..4e186854 100644 --- a/pom.xml +++ b/pom.xml @@ -373,6 +373,7 @@ report + ${project.parent.basedir}/target/jacoco.exec XML diff --git a/sdk/pom.xml b/sdk/pom.xml index 890ba1e3..b6f06e1e 100644 --- a/sdk/pom.xml +++ b/sdk/pom.xml @@ -275,6 +275,35 @@ + + org.jacoco + jacoco-maven-plugin + 0.8.12 + + + prepare-agent + + prepare-agent + + + ${project.parent.basedir}/target/jacoco.exec + + + + report + test + + report + + + ${project.parent.basedir}/target/jacoco.exec + + XML + + + + + \ No newline at end of file From 3fb96fd517d3060e978a1ff04cab1a76cc6e3f9d Mon Sep 17 00:00:00 2001 From: Paul Flynn Date: Wed, 16 Oct 2024 12:16:42 -0400 Subject: [PATCH 8/8] Add sonarcloud to CI jobs This commit adds the 'sonarcloud' job to the CI workflow file. SonarCloud will help in tracking code quality and identifying potential issues early. It runs alongside existing jobs to ensure comprehensive code analysis during CI checks. --- .github/workflows/checks.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 2514fc71..98b89f76 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -277,6 +277,7 @@ jobs: - platform-integration - platform-xtest - mavenverify + - sonarcloud - pr runs-on: ubuntu-latest if: always()