Skip to content

Commit

Permalink
Switch diffCoverage plugin to deltaCoverage
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <[email protected]>
  • Loading branch information
dbwiddis committed Jul 6, 2024
1 parent cf1016f commit f3b59ee
Show file tree
Hide file tree
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)
Expand Down Expand Up @@ -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

Expand Down
43 changes: 14 additions & 29 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down Expand Up @@ -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.7d)
}
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"
Expand Down

0 comments on commit f3b59ee

Please sign in to comment.