Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch diffCoverage plugin to deltaCoverage #762

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/test_security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
pull_request:
types: [opened, synchronize, reopened]

env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true

jobs:
Get-CI-Image-Tag:
uses: opensearch-project/opensearch-build/.github/workflows/get-ci-image-tag.yml@main
Expand Down
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 @@ -684,38 +681,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"
Expand Down
Loading