From d7f2660167444ace220e38e748a79673a1139864 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 8 Jul 2024 20:32:51 +0000 Subject: [PATCH] Switch diffCoverage plugin to deltaCoverage (#762) * Switch diffCoverage plugin to deltaCoverage Signed-off-by: Daniel Widdis * Allow lower NodeJS version on GH runners for security test Signed-off-by: Daniel Widdis --------- Signed-off-by: Daniel Widdis (cherry picked from commit a0a937563342e682caabb2073472faf9c2610598) Signed-off-by: github-actions[bot] --- CONTRIBUTING.md | 4 ++-- build.gradle | 43 ++++++++++++++----------------------------- 2 files changed, 16 insertions(+), 31 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 76ff9d0f2..003aac02d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -- [Contributing to OpenSearch AI Flow Framework](#contributing-to-flow-framework) +- [Contributing to OpenSearch Flow Framework](#contributing-to-opensearch-flow-framework) - [First Things First](#first-things-first) - [Ways to Contribute](#ways-to-contribute) - [Bug Reports](#bug-reports) @@ -100,7 +100,7 @@ Adding in the change is two step process - Any new functionality requires testing. Your PR will trigger an automatic assessment of the code coverage of the lines you've added. You should add unit and/or integration tests to exercise as much of your new code as possible. -If you'd like to preview your coverage before submitting your PR, to identify lines of code which are not tested, you may run `./gradlew diffCoverage` and review the report available in the project build directory at `build/reports/jacoco/diffCoverage/html/index.html`. +If you'd like to preview your coverage before submitting your PR, to identify lines of code which are not tested, you may run `./gradlew test deltaCoverage` and review the report available in the project build directory at `build/reports/coverage-reports/delta-coverage/html/index.html`. ## Review Process diff --git a/build.gradle b/build.gradle index e7b29f38c..5706df517 100644 --- a/build.gradle +++ b/build.gradle @@ -47,13 +47,13 @@ buildscript { dependencies { classpath "org.opensearch.gradle:build-tools:${opensearch_version}" classpath "com.diffplug.spotless:spotless-plugin-gradle:6.25.0" - classpath "com.github.form-com.diff-coverage-gradle:diff-coverage:0.9.5" } } plugins { id "de.undercouch.download" version "5.6.0" id "org.gradle.test-retry" version "1.5.9" apply false + id "io.github.surpsg.delta-coverage" version "2.1.0" } apply plugin: 'java' @@ -66,9 +66,6 @@ apply plugin: 'com.diffplug.spotless' apply from: 'formatter/formatting.gradle' // for javadocs and checks spotless doesn't do apply plugin: 'checkstyle' -// for coverage and diff -apply plugin: 'jacoco' -apply plugin: 'com.form.diff-coverage' def pluginName = 'opensearch-flow-framework' def pluginDescription = 'OpenSearch plugin that enables builders to innovate AI apps on OpenSearch' @@ -682,38 +679,26 @@ task updateVersion { } } -diffCoverageReport { - afterEvaluate { - // Get uncommitted files via git diff - // https://github.com/form-com/diff-coverage-gradle/issues/73 - def file = Files.createTempFile(URLEncoder.encode(project.name, 'UTF-8'), '.diff').toFile() - def diffBase = 'refs/remotes/origin/main' - // Only run locally - if (!System.getenv('CI')) { - file.withOutputStream { out -> - exec { - ignoreExitValue true - commandLine 'git', 'diff', '--no-color', '--minimal', diffBase - standardOutput = out - } - } - } - diffSource.file = file +deltaCoverageReport { + diffSource { + git.compareWith("refs/remotes/origin/main") } - // View report at build/reports/jacoco/diffCoverage/html/index.html - reports { - html = true + violationRules { + failOnViolation.set(true) + rule(io.github.surpsg.deltacoverage.gradle.CoverageEntity.LINE) { + minCoverageRatio.set(0.75d) + } + rule(io.github.surpsg.deltacoverage.gradle.CoverageEntity.BRANCH) { + minCoverageRatio.set(0.6d) + } } - violationRules { - minBranches = 0.60 - minLines = 0.75 - failOnViolation = true + reports { + html.set(true) } } - tasks.withType(AbstractPublishToMaven) { def predicate = provider { publication.name == "pluginZip"