From 20247e42d426027143dda2159d9270a85f8513f5 Mon Sep 17 00:00:00 2001 From: Rishabh Goyal Date: Sun, 13 Apr 2025 02:46:38 +0530 Subject: [PATCH 01/11] Optimized Utils.name() method --- pom.xml | 49 +------------------ .../databuilderframework/engine/Utils.java | 4 +- 2 files changed, 3 insertions(+), 50 deletions(-) diff --git a/pom.xml b/pom.xml index 95cd532..6b1be40 100644 --- a/pom.xml +++ b/pom.xml @@ -62,8 +62,7 @@ UTF-8 2.10.3 - 1.16.6 - 1.16.6.1 + 1.18.30 5.2.5.Final 4.13.1 @@ -117,19 +116,6 @@ - - org.projectlombok - lombok-maven-plugin - - - generate-sources - - delombok - - - - ${lombok.maven.version} - org.apache.maven.plugins maven-compiler-plugin @@ -138,39 +124,6 @@ 1.8 - - org.codehaus.mojo - cobertura-maven-plugin - 2.6 - - - 85 - 85 - true - 85 - 85 - 85 - 85 - - - com.flipkart.databuilderframework.* - 100 - 100 - - - - - true - - - - - - clean - - - - org.apache.maven.plugins maven-jar-plugin diff --git a/src/main/java/com/flipkart/databuilderframework/engine/Utils.java b/src/main/java/com/flipkart/databuilderframework/engine/Utils.java index 569a02a..59bb9ed 100644 --- a/src/main/java/com/flipkart/databuilderframework/engine/Utils.java +++ b/src/main/java/com/flipkart/databuilderframework/engine/Utils.java @@ -30,8 +30,8 @@ public static String name(Object object) { } public static String name(Class clazz) { - return CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, - CLASS_TO_NAME_MAPPING.computeIfAbsent(clazz, aClass -> clazz.getSimpleName())); + return CLASS_TO_NAME_MAPPING.computeIfAbsent(clazz, + aClass -> CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, clazz.getSimpleName())); } public static boolean isEmpty(Collection collection) { From e699b519ff86af251ece884d7a02b56f6c68d65c Mon Sep 17 00:00:00 2001 From: Rishabh Goyal Date: Mon, 14 Apr 2025 15:17:20 +0530 Subject: [PATCH 02/11] Added Jacoco --- pom.xml | 22 ++++++++++++++++++- .../databuilderframework/engine/Utils.java | 4 ++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 6b1be40..da56eb5 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> com.flipkart.databuilderframework - 0.5.12 + 0.5.13-RC1 4.0.0 databuilderframework @@ -116,6 +116,26 @@ + + org.jacoco + jacoco-maven-plugin + 0.8.12 + + + prepare-agent + + prepare-agent + + + + report + prepare-package + + report + + + + org.apache.maven.plugins maven-compiler-plugin diff --git a/src/main/java/com/flipkart/databuilderframework/engine/Utils.java b/src/main/java/com/flipkart/databuilderframework/engine/Utils.java index 59bb9ed..569a02a 100644 --- a/src/main/java/com/flipkart/databuilderframework/engine/Utils.java +++ b/src/main/java/com/flipkart/databuilderframework/engine/Utils.java @@ -30,8 +30,8 @@ public static String name(Object object) { } public static String name(Class clazz) { - return CLASS_TO_NAME_MAPPING.computeIfAbsent(clazz, - aClass -> CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, clazz.getSimpleName())); + return CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, + CLASS_TO_NAME_MAPPING.computeIfAbsent(clazz, aClass -> clazz.getSimpleName())); } public static boolean isEmpty(Collection collection) { From 6e1d9ed5379c744ee76f6eacef29ad670ded5411 Mon Sep 17 00:00:00 2001 From: Rishabh Goyal Date: Mon, 14 Apr 2025 15:18:32 +0530 Subject: [PATCH 03/11] Added Jacoco --- .../java/com/flipkart/databuilderframework/engine/Utils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/flipkart/databuilderframework/engine/Utils.java b/src/main/java/com/flipkart/databuilderframework/engine/Utils.java index 569a02a..59bb9ed 100644 --- a/src/main/java/com/flipkart/databuilderframework/engine/Utils.java +++ b/src/main/java/com/flipkart/databuilderframework/engine/Utils.java @@ -30,8 +30,8 @@ public static String name(Object object) { } public static String name(Class clazz) { - return CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, - CLASS_TO_NAME_MAPPING.computeIfAbsent(clazz, aClass -> clazz.getSimpleName())); + return CLASS_TO_NAME_MAPPING.computeIfAbsent(clazz, + aClass -> CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, clazz.getSimpleName())); } public static boolean isEmpty(Collection collection) { From d190cafbecfb72175e3577a99b8be4e93fea5c21 Mon Sep 17 00:00:00 2001 From: Rishabh Goyal Date: Mon, 14 Apr 2025 15:23:57 +0530 Subject: [PATCH 04/11] Added Github action for coverage in PR --- .github/workflows/coverage-report.yml | 72 +++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/coverage-report.yml diff --git a/.github/workflows/coverage-report.yml b/.github/workflows/coverage-report.yml new file mode 100644 index 0000000..28ea8c4 --- /dev/null +++ b/.github/workflows/coverage-report.yml @@ -0,0 +1,72 @@ +name: JaCoCo Coverage Report + +on: + pull_request: + branches: [ main, master ] # Adjust branches as needed + +permissions: + # Required for checking out the code + contents: read + # Required for posting comments and status checks + pull-requests: write + # Required for reading report files + actions: read # Optional, often implicitly available + +jobs: + build-and-report: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + # Fetch depth 0 is needed for calculating coverage on changed files accurately + fetch-depth: 0 + + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: '1.8' # Or your project's Java version + distribution: 'temurin' # Or your preferred distribution + + # --- Build and Test Step --- + # Choose ONE of the following based on your build tool + + # Option A: Maven + - name: Build and Test with Maven + run: mvn clean verify --batch-mode # The 'verify' phase usually triggers the jacoco:report goal + + # Option B: Gradle + # - name: Grant execute permission for gradlew + # run: chmod +x gradlew + # - name: Build and Test with Gradle + # run: ./gradlew build jacocoTestReport # Explicitly run jacocoTestReport task + + # --- Coverage Reporting Step --- + - name: JaCoCo Report to PR Comment + id: jacoco + uses: madrapps/jacoco-report@v1.6.1 # Use the latest version + with: + # IMPORTANT: Adjust the path(s) to your jacoco.xml report file(s) + paths: | + ${{ github.workspace }}/target/site/jacoco/jacoco.xml # Maven default + ${{ github.workspace }}/**/build/reports/jacoco/test/jacocoTestReport.xml # Gradle default (using wildcard for multi-module) + # Token is needed to post comments and status checks + token: ${{ secrets.GITHUB_TOKEN }} + # Minimum coverage percentages (optional) - Fails the check if below + min-coverage-overall: 0 # Example value + min-coverage-changed-files: 0 # Example value + # Update existing comment instead of posting new ones + update-comment: true + # Custom title for the comment (optional) + title: "📊 JaCoCo Code Coverage" + # Fail build if coverage requirements are not met (optional) + # fail-if-coverage-less-than: false # Default is false + # Skip comment if coverage is 100% (optional) + # skip-comment-if-no-changes: true # Default is false + + # Optional: Output coverage details + - name: Print Coverage Summary + run: | + echo "Overall Coverage: ${{ steps.jacoco.outputs.coverage-overall }}%" + echo "Changed Files Coverage: ${{ steps.jacoco.outputs.coverage-changed-files }}%" \ No newline at end of file From c73b163dbad6251f1c6d00a2e50810fd958c86ee Mon Sep 17 00:00:00 2001 From: Rishabh Goyal Date: Mon, 14 Apr 2025 15:27:13 +0530 Subject: [PATCH 05/11] Corrected Java version in Github Actions --- .github/workflows/coverage-report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage-report.yml b/.github/workflows/coverage-report.yml index 28ea8c4..15fdcf0 100644 --- a/.github/workflows/coverage-report.yml +++ b/.github/workflows/coverage-report.yml @@ -26,7 +26,7 @@ jobs: - name: Set up JDK uses: actions/setup-java@v4 with: - java-version: '1.8' # Or your project's Java version + java-version: '8' # Or your project's Java version distribution: 'temurin' # Or your preferred distribution # --- Build and Test Step --- From 0adba7ff962768b20222616c879f880a94f85575 Mon Sep 17 00:00:00 2001 From: Rishabh Goyal Date: Mon, 14 Apr 2025 15:32:39 +0530 Subject: [PATCH 06/11] Expecting minimum 95% coverage on all new files and existing codebase --- .github/workflows/coverage-report.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coverage-report.yml b/.github/workflows/coverage-report.yml index 15fdcf0..e1834a6 100644 --- a/.github/workflows/coverage-report.yml +++ b/.github/workflows/coverage-report.yml @@ -54,8 +54,8 @@ jobs: # Token is needed to post comments and status checks token: ${{ secrets.GITHUB_TOKEN }} # Minimum coverage percentages (optional) - Fails the check if below - min-coverage-overall: 0 # Example value - min-coverage-changed-files: 0 # Example value + min-coverage-overall: 95 # Example value + min-coverage-changed-files: 95 # Example value # Update existing comment instead of posting new ones update-comment: true # Custom title for the comment (optional) From 279011061ee74dfae962b63b00d5a8b67cc99181 Mon Sep 17 00:00:00 2001 From: Rishabh Goyal Date: Mon, 14 Apr 2025 15:34:23 +0530 Subject: [PATCH 07/11] Upgraded plugin version --- pom.xml | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index da56eb5..a6b6413 100644 --- a/pom.xml +++ b/pom.xml @@ -119,22 +119,21 @@ org.jacoco jacoco-maven-plugin - 0.8.12 - - - prepare-agent - - prepare-agent - - - - report - prepare-package - - report - - - + 0.8.13 + + + prepare-agent + + + + report + verify + report + + + + + org.apache.maven.plugins From 7900c51fcd8a4426202d13dcfb90584b95a54b54 Mon Sep 17 00:00:00 2001 From: Rishabh Goyal Date: Mon, 14 Apr 2025 15:41:19 +0530 Subject: [PATCH 08/11] Printing Jacoco file paths for debugging --- .github/workflows/coverage-report.yml | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/.github/workflows/coverage-report.yml b/.github/workflows/coverage-report.yml index e1834a6..d611757 100644 --- a/.github/workflows/coverage-report.yml +++ b/.github/workflows/coverage-report.yml @@ -20,7 +20,6 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: - # Fetch depth 0 is needed for calculating coverage on changed files accurately fetch-depth: 0 - name: Set up JDK @@ -29,41 +28,29 @@ jobs: java-version: '8' # Or your project's Java version distribution: 'temurin' # Or your preferred distribution - # --- Build and Test Step --- - # Choose ONE of the following based on your build tool - - # Option A: Maven - name: Build and Test with Maven run: mvn clean verify --batch-mode # The 'verify' phase usually triggers the jacoco:report goal - # Option B: Gradle - # - name: Grant execute permission for gradlew - # run: chmod +x gradlew - # - name: Build and Test with Gradle - # run: ./gradlew build jacocoTestReport # Explicitly run jacocoTestReport task + - name: Check for JaCoCo Report File + run: | + echo "Searching for JaCoCo reports..." + find ${{ github.workspace }} -name 'jacoco*.xml' # General search + echo "--- Listing Maven default ---" + ls -l ${{ github.workspace }}/target/site/jacoco/jacoco.xml || echo "Maven default not found" # --- Coverage Reporting Step --- - name: JaCoCo Report to PR Comment id: jacoco uses: madrapps/jacoco-report@v1.6.1 # Use the latest version with: - # IMPORTANT: Adjust the path(s) to your jacoco.xml report file(s) paths: | ${{ github.workspace }}/target/site/jacoco/jacoco.xml # Maven default ${{ github.workspace }}/**/build/reports/jacoco/test/jacocoTestReport.xml # Gradle default (using wildcard for multi-module) - # Token is needed to post comments and status checks token: ${{ secrets.GITHUB_TOKEN }} - # Minimum coverage percentages (optional) - Fails the check if below min-coverage-overall: 95 # Example value min-coverage-changed-files: 95 # Example value - # Update existing comment instead of posting new ones update-comment: true - # Custom title for the comment (optional) title: "📊 JaCoCo Code Coverage" - # Fail build if coverage requirements are not met (optional) - # fail-if-coverage-less-than: false # Default is false - # Skip comment if coverage is 100% (optional) - # skip-comment-if-no-changes: true # Default is false # Optional: Output coverage details - name: Print Coverage Summary From 30bd31e9d17dcb982bbdca2503aa56543d5c99aa Mon Sep 17 00:00:00 2001 From: Rishabh Goyal Date: Mon, 14 Apr 2025 15:44:50 +0530 Subject: [PATCH 09/11] Intentionally changing jacoco file to see if the whole thing fails --- .github/workflows/coverage-report.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/coverage-report.yml b/.github/workflows/coverage-report.yml index d611757..89704bf 100644 --- a/.github/workflows/coverage-report.yml +++ b/.github/workflows/coverage-report.yml @@ -44,8 +44,7 @@ jobs: uses: madrapps/jacoco-report@v1.6.1 # Use the latest version with: paths: | - ${{ github.workspace }}/target/site/jacoco/jacoco.xml # Maven default - ${{ github.workspace }}/**/build/reports/jacoco/test/jacocoTestReport.xml # Gradle default (using wildcard for multi-module) + ${{ github.workspace }}/target/site/jacoco/jacoc.xml token: ${{ secrets.GITHUB_TOKEN }} min-coverage-overall: 95 # Example value min-coverage-changed-files: 95 # Example value From 3ed3485984bb45e42dbf874210ca96a9f86a65dc Mon Sep 17 00:00:00 2001 From: Rishabh Goyal Date: Mon, 14 Apr 2025 15:52:18 +0530 Subject: [PATCH 10/11] Intentionally changing jacoco file to see if the whole thing fails --- .github/workflows/coverage-report.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coverage-report.yml b/.github/workflows/coverage-report.yml index 89704bf..26377b8 100644 --- a/.github/workflows/coverage-report.yml +++ b/.github/workflows/coverage-report.yml @@ -41,10 +41,10 @@ jobs: # --- Coverage Reporting Step --- - name: JaCoCo Report to PR Comment id: jacoco - uses: madrapps/jacoco-report@v1.6.1 # Use the latest version + uses: madrapps/jacoco-report@v1.7.1 # Use the latest version with: paths: | - ${{ github.workspace }}/target/site/jacoco/jacoc.xml + ${{ github.workspace }}/**/target/site/jacoco/jacoc.xml token: ${{ secrets.GITHUB_TOKEN }} min-coverage-overall: 95 # Example value min-coverage-changed-files: 95 # Example value From d99f957e35a4593478a1f033e016f714b8f470c4 Mon Sep 17 00:00:00 2001 From: Rishabh Goyal Date: Mon, 14 Apr 2025 15:52:23 +0530 Subject: [PATCH 11/11] Intentionally changing jacoco file to see if the whole thing fails --- .github/workflows/coverage-report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage-report.yml b/.github/workflows/coverage-report.yml index 26377b8..2a57f98 100644 --- a/.github/workflows/coverage-report.yml +++ b/.github/workflows/coverage-report.yml @@ -44,7 +44,7 @@ jobs: uses: madrapps/jacoco-report@v1.7.1 # Use the latest version with: paths: | - ${{ github.workspace }}/**/target/site/jacoco/jacoc.xml + ${{ github.workspace }}/**/target/site/jacoco/jacoco.xml token: ${{ secrets.GITHUB_TOKEN }} min-coverage-overall: 95 # Example value min-coverage-changed-files: 95 # Example value