Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch diffCoverage plugin to deltaCoverage
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <[email protected]>
dbwiddis committed Jul 7, 2024
1 parent cf1016f commit c63456f
Showing 2 changed files with 16 additions and 31 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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

43 changes: 14 additions & 29 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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'
@@ -683,38 +680,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"

0 comments on commit c63456f

Please sign in to comment.