From 312cc4ce2254bc7126429f72c5186581a3e3bcb7 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 7 Feb 2023 15:57:18 +0100 Subject: [PATCH] Kover: add verify rules: global and for Presenters --- .github/workflows/quality.yml | 9 +++++++++ build.gradle.kts | 31 +++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index 78c407cde1..31630acf97 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -29,6 +29,15 @@ jobs: name: linting-report path: | */build/reports/**/*.* + - name: Check Kover rules + run: ./gradlew koverMergedVerify $CI_GRADLE_ARG_PROPERTIES + - name: Upload reports + if: failure() + uses: actions/upload-artifact@v3 + with: + name: kover-report + path: | + */build/reports/kover/merged/verification/errors.txt - name: Prepare Danger if: always() run: | diff --git a/build.gradle.kts b/build.gradle.kts index f2f16714ea..97e26f956b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -174,4 +174,35 @@ koverMerged { ) } } + + // Run ./gradlew koverMergedVerify to check the rules. + verify { + // Does not seems to work, so also run the task manually on the workflow. + onCheck.set(true) + // General rule: minimum code coverage. + rule { + name = "Global minimum code coverage." + target = kotlinx.kover.api.VerificationTarget.ALL + bound { + minValue = 35 + // Setting a max value, so that if coverage is bigger, it means that we have to change minValue. + maxValue = 40 + counter = kotlinx.kover.api.CounterType.LINE + valueType = kotlinx.kover.api.VerificationValueType.COVERED_PERCENTAGE + } + } + // Rule to ensure that coverage of Presenters is sufficient. + rule { + name = "Check code coverage of presenters" + target = kotlinx.kover.api.VerificationTarget.CLASS + overrideClassFilter { + includes += "*Presenter" + } + bound { + minValue = 80 + counter = kotlinx.kover.api.CounterType.LINE + valueType = kotlinx.kover.api.VerificationValueType.COVERED_PERCENTAGE + } + } + } }