diff --git a/.circleci/config.yml b/.circleci/config.yml index d7ac88f60..6d32c975d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -251,7 +251,12 @@ jobs: at: dtest-jars - run: ./scripts/install-shaded-dtest-jar-local.sh - run: ./gradlew --no-daemon -PdtestVersion=4.1.8 -Dcassandra.sidecar.versions_to_test="4.0" checkstyleIntegrationTest spotbugsIntegrationTest integrationTestLightWeight --stacktrace - + - 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/reports destination: test-reports @@ -262,6 +267,10 @@ jobs: - store_test_results: path: build/test-results/ + - persist_to_workspace: + root: ./jacoco-results + paths: + - "**/*" integration_heavy_cassandra_40_java11: docker: @@ -277,7 +286,12 @@ jobs: at: dtest-jars - run: ./scripts/install-shaded-dtest-jar-local.sh - run: ./gradlew --no-daemon -PdtestVersion=4.1.8 -Dcassandra.sidecar.versions_to_test="4.0" integrationTestHeavyWeight --stacktrace - + - 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/reports destination: test-reports @@ -289,6 +303,11 @@ jobs: - store_test_results: path: build/test-results/ + - persist_to_workspace: + root: ./jacoco-results + paths: + - "**/*" + integration_cassandra_50_java11: docker: - image: cimg/openjdk:11.0 @@ -303,7 +322,12 @@ jobs: at: dtest-jars - run: ./scripts/install-shaded-dtest-jar-local.sh - run: ./gradlew --no-daemon -PdtestVersion=5.0.3 -Dcassandra.sidecar.versions_to_test="5.0" checkstyleIntegrationTest spotbugsIntegrationTest integrationTestLightWeight --stacktrace - + - 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/reports destination: test-reports @@ -315,6 +339,11 @@ jobs: - store_test_results: path: build/test-results/ + - persist_to_workspace: + root: ./jacoco-results + paths: + - "**/*" + integration_heavy_cassandra_50_java11: docker: - image: cimg/openjdk:11.0 @@ -329,7 +358,12 @@ jobs: at: dtest-jars - run: ./scripts/install-shaded-dtest-jar-local.sh - run: ./gradlew --no-daemon -PdtestVersion=5.0.3 -Dcassandra.sidecar.versions_to_test="5.0" integrationTestHeavyWeight --stacktrace - + - 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/reports destination: test-reports @@ -341,6 +375,11 @@ jobs: - store_test_results: path: build/test-results/ + - persist_to_workspace: + root: ./jacoco-results + paths: + - "**/*" + integration_cassandra_trunk_java11: docker: - image: cimg/openjdk:11.0 @@ -355,7 +394,12 @@ jobs: at: dtest-jars - run: ./scripts/install-shaded-dtest-jar-local.sh - run: ./gradlew --no-daemon -PdtestVersion=5.1 -Dcassandra.sidecar.versions_to_test="5.1" checkstyleIntegrationTest spotbugsIntegrationTest integrationTestLightWeight --stacktrace - + - 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/reports destination: test-reports @@ -367,6 +411,11 @@ jobs: - store_test_results: path: build/test-results/ + - persist_to_workspace: + root: ./jacoco-results + paths: + - "**/*" + integration_heavy_cassandra_trunk_java11: docker: - image: cimg/openjdk:11.0 @@ -381,7 +430,12 @@ jobs: at: dtest-jars - run: ./scripts/install-shaded-dtest-jar-local.sh - run: ./gradlew --no-daemon -PdtestVersion=5.1 -Dcassandra.sidecar.versions_to_test="5.1" integrationTestHeavyWeight --stacktrace - + - 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/reports destination: test-reports @@ -393,6 +447,25 @@ jobs: - store_test_results: path: build/test-results/ + - 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: + - image: cimg/openjdk:11.0 + environment: + skipIntegrationTest: true + steps: + - setup_remote_docker + - install_common + - checkout + - attach_workspace: + at: jacoco-results + - run: ./gradlew --info deltaCoverage + # ensures we can build and install deb packages deb_build_install: docker: @@ -484,6 +557,15 @@ workflows: requires: - unit_java11 - build-dtest-jdk11 + - validate_delta_coverage: + requires: + - unit_java11 + - integration_cassandra_40_java11 + - integration_heavy_cassandra_40_java11 + - integration_cassandra_50_java11 + - integration_heavy_cassandra_50_java11 + - integration_cassandra_trunk_java11 + - integration_heavy_cassandra_trunk_java11 - docs_build: requires: - unit_java8 diff --git a/CHANGES.txt b/CHANGES.txt index 891ff1d11..3f8c793b6 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,5 +1,6 @@ 1.0.0 ----- + * Integrate delta-coverage-plugin plugin (CASSSIDECAR-163) * Mechanism to have a reduced number of Sidecar instances run operations (CASSSIDECAR-174) * Adding support for CDC APIs into sidecar client (CASSSIDECAR-172) * Stopping Sidecar can take a long time (CASSSIDECAR-178) diff --git a/build.gradle b/build.gradle index 8cf04458c..347478864 100644 --- a/build.gradle +++ b/build.gradle @@ -49,6 +49,7 @@ plugins { id("org.nosphere.apache.rat") version "0.8.0" id 'jacoco' + id("io.github.surpsg.delta-coverage") version "2.5.0" } // Force checkstyle, rat, and spotBugs to run before test tasks for faster feedback @@ -88,6 +89,29 @@ allprojects { } +deltaCoverageReport { + diffSource { + git.compareWith("refs/remotes/origin/trunk") + git.useNativeGit.set(true) + } + + coverageBinaryFiles = fileTree(".") { include("**/*.exec") } + + 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) + } +} + group 'org.apache.cassandra' version project.version 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 +