From 79284a3450fbdc38cc4bd52d48ac8469ac2862ad Mon Sep 17 00:00:00 2001 From: Bernardo Botella Corbi Date: Thu, 21 Nov 2024 14:03:25 -0800 Subject: [PATCH 01/11] Add Delta Coverage plugin https://issues.apache.org/jira/browse/CASSANALYTICS-1 --- build.gradle | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/build.gradle b/build.gradle index d5bc95cac..3abdff56f 100644 --- a/build.gradle +++ b/build.gradle @@ -29,10 +29,12 @@ plugins { // Release Audit Tool (RAT) plugin for checking project licenses id("org.nosphere.apache.rat") version "0.8.1" + id("io.github.surpsg.delta-coverage") version "2.4.0" } repositories { mavenCentral() + maven { url "https://plugins.gradle.org/m2/" } } ext.scalaLabel = System.getenv("SCALA_VERSION") ?: "${scala}" @@ -255,4 +257,25 @@ subprojects { println() println(version) } + + deltaCoverageReport { + diffSource { + git.compareWith("refs/remotes/upstream/trunk") + git.useNativeGit.set(true) + } + + violationRules { + failOnViolation.set(true) + rule(io.github.surpsg.deltacoverage.gradle.CoverageEntity.LINE) { + minCoverageRatio.set(0.9d) + } + rule(io.github.surpsg.deltacoverage.gradle.CoverageEntity.BRANCH) { + minCoverageRatio.set(0.7d) + } + } + + reports { + html.set(true) + } + } } From 7416c27259611a77c63adf8e8c39a5ad4a2d0edd Mon Sep 17 00:00:00 2001 From: Bernardo Botella Corbi Date: Thu, 21 Nov 2024 15:23:01 -0800 Subject: [PATCH 02/11] Adds changes.txt --- CHANGES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.txt b/CHANGES.txt index 557f8280a..14a814995 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 1.0.0 + * Integrate delta-coverage-plugin plugin (CASSANALYTICS-1) * CEP-44 Kafka integration for Cassandra CDC using Sidecar (CASSANDRA-19962) * Expose detailed bulk write failure message for better insight (CASSANDRA-20066) * Add dataTransferApi and TwoPhaseImportCoordinator for coordinated write (CASSANDRA-19994) From 239ea5a433b806828ac1253980bfaef4b31c0077 Mon Sep 17 00:00:00 2001 From: Bernardo Botella Corbi Date: Thu, 21 Nov 2024 15:55:35 -0800 Subject: [PATCH 03/11] Remove redundant repository --- build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/build.gradle b/build.gradle index 3abdff56f..e18b8cbd3 100644 --- a/build.gradle +++ b/build.gradle @@ -34,7 +34,6 @@ plugins { repositories { mavenCentral() - maven { url "https://plugins.gradle.org/m2/" } } ext.scalaLabel = System.getenv("SCALA_VERSION") ?: "${scala}" From 257e2c25dcd6771c9cd12f5d71c30ee4ae296931 Mon Sep 17 00:00:00 2001 From: Bernardo Botella Corbi Date: Mon, 16 Dec 2024 15:00:12 -0800 Subject: [PATCH 04/11] Add circleCI config --- .circleci/config.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index a749b8639..15bee7499 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -370,6 +370,13 @@ jobs: - store_test_results: path: build/test-reports + # Delta coverage plugin requires java 11 so we only validate in java 11 builds + validate_delta_coverage: + docker: + - image: cimg/openjdk:11.0 + steps: + - run: ./gradlew deltaCoverage + workflows: version: 2 build-and-test: @@ -400,3 +407,9 @@ workflows: - int-spark3-2_13-jdk11: requires: - build-deps-jdk11 + - validate_delta_coverage: + requires: + - spark3-2_12-jdk11 + - spark3-2_13-jdk11 + - int-spark3-2_12-jdk11 + - int-spark3-2_13-jdk11 \ No newline at end of file From 329295c67913a97145365bbb0f687c2a4eafac4e Mon Sep 17 00:00:00 2001 From: Bernardo Botella Corbi Date: Mon, 16 Dec 2024 15:03:08 -0800 Subject: [PATCH 05/11] Fix circleCI --- .circleci/config.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 15bee7499..20a004404 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -370,12 +370,12 @@ jobs: - store_test_results: path: build/test-reports - # Delta coverage plugin requires java 11 so we only validate in java 11 builds - validate_delta_coverage: - docker: - - image: cimg/openjdk:11.0 - steps: - - run: ./gradlew deltaCoverage + # Delta coverage plugin requires java 11 so we only validate in java 11 builds + validate_delta_coverage: + docker: + - image: cimg/openjdk:11.0 + steps: + - run: ./gradlew deltaCoverage workflows: version: 2 From aae9674bc99694daec0cee21b7347f63b95761ae Mon Sep 17 00:00:00 2001 From: Bernardo Botella Corbi Date: Mon, 16 Dec 2024 15:56:32 -0800 Subject: [PATCH 06/11] Circle Test --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e18b8cbd3..227561354 100644 --- a/build.gradle +++ b/build.gradle @@ -259,7 +259,7 @@ subprojects { deltaCoverageReport { diffSource { - git.compareWith("refs/remotes/upstream/trunk") + git.compareWith("refs/remotes/origin/trunk") git.useNativeGit.set(true) } From a9f4246f06fcda70d2c7806f20637673a266dc0d Mon Sep 17 00:00:00 2001 From: Bernardo Botella Corbi Date: Tue, 17 Dec 2024 06:38:08 -0800 Subject: [PATCH 07/11] Add checkout step --- .circleci/config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 20a004404..039be6885 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -375,6 +375,8 @@ jobs: docker: - image: cimg/openjdk:11.0 steps: + - install_common + - checkout - run: ./gradlew deltaCoverage workflows: From e5db4bd3677e6385978c90109e21443e580b325f Mon Sep 17 00:00:00 2001 From: Bernardo Botella Corbi Date: Tue, 17 Dec 2024 08:24:37 -0800 Subject: [PATCH 08/11] Attach dependencies --- .circleci/config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 039be6885..0ecf00833 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -377,6 +377,8 @@ jobs: steps: - install_common - checkout + - attach_workspace: + at: dependencies - run: ./gradlew deltaCoverage workflows: From 68f684c66857c6332cee7faddc9ff80f6581b053 Mon Sep 17 00:00:00 2001 From: Bernardo Botella Corbi Date: Wed, 18 Dec 2024 08:21:47 -0800 Subject: [PATCH 09/11] Test adding info flag --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0ecf00833..74016ce9c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -379,7 +379,7 @@ jobs: - checkout - attach_workspace: at: dependencies - - run: ./gradlew deltaCoverage + - run: ./gradlew --info deltaCoverage workflows: version: 2 From 5136f2a401fb35c5adce15f49d60b32e46211933 Mon Sep 17 00:00:00 2001 From: Bernardo Botella Corbi Date: Mon, 23 Dec 2024 13:53:23 -0800 Subject: [PATCH 10/11] Adds missing jacoco aggregation --- .circleci/config.yml | 46 ++++++++++++++++++++++++- build.gradle | 3 ++ cassandra-analytics-common/build.gradle | 1 + scripts/get-jacoco-results.sh | 32 +++++++++++++++++ 4 files changed, 81 insertions(+), 1 deletion(-) create mode 100755 scripts/get-jacoco-results.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 74016ce9c..1aa7f37f3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -272,6 +272,12 @@ jobs: scala: "2.12" jdk: "11" use_jdk11: "true" + - run: + name: Move Jacoco results to unique folder + command: | + UNIQUE_ID="${CIRCLE_WORKFLOW_ID}-${CIRCLE_JOB}-${CIRCLE_NODE_INDEX}" + echo "Unique ID: $UNIQUE_ID" + ./scripts/get-jacoco-results.sh "jacoco-results/${UNIQUE_ID}" - store_artifacts: path: build/test-reports @@ -284,6 +290,11 @@ jobs: - store_test_results: path: build/test-reports + - persist_to_workspace: + root: ./jacoco-results + paths: + - "**/*" + int-spark3-2_12-jdk11: parallelism: 8 docker: @@ -300,6 +311,12 @@ jobs: scala: "2.12" jdk: "11" use_jdk11: "true" + - run: + name: Move Jacoco results to unique folder + command: | + UNIQUE_ID="${CIRCLE_WORKFLOW_ID}-${CIRCLE_JOB}-${CIRCLE_NODE_INDEX}" + echo "Unique ID: $UNIQUE_ID" + ./scripts/get-jacoco-results.sh "jacoco-results/${UNIQUE_ID}" - store_artifacts: path: build/test-reports @@ -316,6 +333,11 @@ jobs: - store_test_results: path: build/test-reports + - persist_to_workspace: + root: ./jacoco-results + paths: + - "**/*" + spark3-2_13-jdk11: docker: - image: cimg/openjdk:11.0 @@ -330,6 +352,12 @@ jobs: scala: "2.13" jdk: "11" use_jdk11: "true" + - run: + name: Move Jacoco results to unique folder + command: | + UNIQUE_ID="${CIRCLE_WORKFLOW_ID}-${CIRCLE_JOB}-${CIRCLE_NODE_INDEX}" + echo "Unique ID: $UNIQUE_ID" + ./scripts/get-jacoco-results.sh "jacoco-results/${UNIQUE_ID}" - store_artifacts: path: build/test-reports @@ -342,6 +370,11 @@ jobs: - store_test_results: path: build/test-reports + - persist_to_workspace: + root: ./jacoco-results + paths: + - "**/*" + int-spark3-2_13-jdk11: parallelism: 8 docker: @@ -358,6 +391,12 @@ jobs: scala: "2.13" jdk: "11" use_jdk11: "true" + - run: + name: Move Jacoco results to unique folder + command: | + UNIQUE_ID="${CIRCLE_WORKFLOW_ID}-${CIRCLE_JOB}-${CIRCLE_NODE_INDEX}" + echo "Unique ID: $UNIQUE_ID" + ./scripts/get-jacoco-results.sh "jacoco-results/${UNIQUE_ID}" - store_artifacts: path: build/test-reports @@ -370,6 +409,11 @@ jobs: - store_test_results: path: build/test-reports + - persist_to_workspace: + root: ./jacoco-results + paths: + - "**/*" + # Delta coverage plugin requires java 11 so we only validate in java 11 builds validate_delta_coverage: docker: @@ -378,7 +422,7 @@ jobs: - install_common - checkout - attach_workspace: - at: dependencies + at: jacoco-results - run: ./gradlew --info deltaCoverage workflows: diff --git a/build.gradle b/build.gradle index 227561354..d7b3f6415 100644 --- a/build.gradle +++ b/build.gradle @@ -30,6 +30,7 @@ plugins { // Release Audit Tool (RAT) plugin for checking project licenses id("org.nosphere.apache.rat") version "0.8.1" id("io.github.surpsg.delta-coverage") version "2.4.0" + id("jacoco") } repositories { @@ -263,6 +264,8 @@ subprojects { git.useNativeGit.set(true) } + coverageBinaryFiles = fileTree(".") { include("**/*.exec") } + violationRules { failOnViolation.set(true) rule(io.github.surpsg.deltacoverage.gradle.CoverageEntity.LINE) { diff --git a/cassandra-analytics-common/build.gradle b/cassandra-analytics-common/build.gradle index f350e3c5e..3acf278e9 100644 --- a/cassandra-analytics-common/build.gradle +++ b/cassandra-analytics-common/build.gradle @@ -22,6 +22,7 @@ import java.nio.file.Paths plugins { id('java-library') id('maven-publish') + id('jacoco') } java { diff --git a/scripts/get-jacoco-results.sh b/scripts/get-jacoco-results.sh new file mode 100755 index 000000000..8304ddcd7 --- /dev/null +++ b/scripts/get-jacoco-results.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +search_dir="." + +target_folder="${1}" + +mkdir -p $target_folder + +find "$search_dir" -type d -path "*/build/jacoco" -print0 | while IFS= read -r -d '' dir; do + destination_path="$target_folder/${dir:2}" + mkdir -p "$destination_path" + cp -r $dir "$destination_path" + echo "Copied folder $dir to $destination_path" +done + From 319d5d6abdf44cf9405aef045b12f8b65034778d Mon Sep 17 00:00:00 2001 From: Bernardo Botella Corbi Date: Mon, 23 Dec 2024 13:56:45 -0800 Subject: [PATCH 11/11] Adds jacoco after rebase --- cassandra-analytics-cdc/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/cassandra-analytics-cdc/build.gradle b/cassandra-analytics-cdc/build.gradle index d8b30e522..d94ee22e2 100644 --- a/cassandra-analytics-cdc/build.gradle +++ b/cassandra-analytics-cdc/build.gradle @@ -22,6 +22,7 @@ import java.nio.file.Paths plugins { id('java-library') id('maven-publish') + id('jacoco') } configurations {