Skip to content

Commit

Permalink
Added:
Browse files Browse the repository at this point in the history
1. Code overage for java projects
2. Agregated coverage report
  • Loading branch information
patotskiy committed Oct 17, 2024
1 parent df564b0 commit 28a29af
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 6 deletions.
30 changes: 30 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,13 @@ plugins {
id 'com.palantir.docker' version '0.35.0' apply false
id 'com.avast.gradle.docker-compose' version '0.17.6'
id "com.diffplug.spotless" version "6.23.3"
id 'jacoco-report-aggregation'
// https://blog.ltgt.net/javax-jakarta-mess-and-gradle-solution/
// TODO id "org.gradlex.java-ecosystem-capabilities" version "1.0"
}

apply from: "gradle/docker/docker.gradle"
apply from: "gradle/coverage/coverage.gradle"

project.ext.spec = [
'product' : [
Expand Down Expand Up @@ -281,6 +283,7 @@ project.ext.externalDependency = [
allprojects {
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'jacoco'
// apply plugin: 'org.gradlex.java-ecosystem-capabilities'

tasks.withType(Test).configureEach { task -> if (task.project.name != "metadata-io") {
Expand All @@ -290,6 +293,7 @@ allprojects {
if (project.configurations.getByName("testImplementation").getDependencies()
.any { it.getName().contains("testng") }) {
useTestNG()
finalizedBy jacocoTestReport
}
}
}
Expand Down Expand Up @@ -372,6 +376,7 @@ subprojects {
apply plugin: 'maven-publish'
apply plugin: 'com.gorylenko.gradle-git-properties'
apply plugin: 'com.diffplug.spotless'
apply plugin: 'jacoco'

gitProperties {
keys = ['git.commit.id','git.commit.id.describe','git.commit.time']
Expand Down Expand Up @@ -402,6 +407,16 @@ subprojects {
}
}


jacocoTestReport {
reports {
xml.required = true
csv.required = true
html.outputLocation = layout.buildDirectory.dir('jacocoHtml')
}
dependsOn test // tests are required to run before generating the report
}

spotless {
java {
googleJavaFormat()
Expand Down Expand Up @@ -486,3 +501,18 @@ subprojects {
}
}
}



reporting {
reports {
testCodeCoverageReport(JacocoCoverageReport) {
testType = TestSuiteType.UNIT_TEST

}
}
}

tasks.named('check') {
dependsOn tasks.named('testCodeCoverageReport', JacocoReport)
}
22 changes: 22 additions & 0 deletions datahub-graphql-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,25 @@ tasks.withType(Checkstyle) {

compileJava.dependsOn 'graphqlCodegen'
sourceSets.main.java.srcDir "$projectDir/src/mainGeneratedGraphQL/java"


test{
useTestNG()
finalizedBy jacocoTestReport
}

def jacocoExclusions = [
'**/graphql/generated/**'
];

jacocoTestReport {

afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it,
exclude: jacocoExclusions
)
}))
}

}
61 changes: 61 additions & 0 deletions gradle/coverage/coverage.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
dependencies {
jacocoAggregation project(':datahub-frontend')
jacocoAggregation project(':datahub-graphql-core')
jacocoAggregation project(':datahub-upgrade')
jacocoAggregation project(':entity-registry')
jacocoAggregation project(':ingestion-scheduler')
jacocoAggregation project(':li-utils')
jacocoAggregation project(':metadata-auth')
jacocoAggregation project(':metadata-dao-impl')
jacocoAggregation project(':metadata-events')
jacocoAggregation project(':metadata-integration')
jacocoAggregation project(':metadata-io')
jacocoAggregation project(':metadata-jobs')
jacocoAggregation project(':metadata-models')
jacocoAggregation project(':metadata-models-custom')
jacocoAggregation project(':metadata-models-validator')
jacocoAggregation project(':metadata-operation-context')
jacocoAggregation project(':metadata-service')
jacocoAggregation project(':metadata-utils')
jacocoAggregation project(':mock-entity-registry')
jacocoAggregation project(':metadata-auth:auth-api')
jacocoAggregation project(':metadata-dao-impl:kafka-producer')
jacocoAggregation project(':metadata-events:mxe-avro')
jacocoAggregation project(':metadata-events:mxe-registration')
jacocoAggregation project(':metadata-events:mxe-schemas')
jacocoAggregation project(':metadata-events:mxe-utils-avro')
jacocoAggregation project(':metadata-integration:java')
jacocoAggregation project(':metadata-io:metadata-io-api')
jacocoAggregation project(':metadata-jobs:common')
jacocoAggregation project(':metadata-jobs:mce-consumer')
jacocoAggregation project(':metadata-jobs:mce-consumer-job')
jacocoAggregation project(':metadata-jobs:pe-consumer')
jacocoAggregation project(':metadata-service:auth-config')
jacocoAggregation project(':metadata-service:auth-filter')
jacocoAggregation project(':metadata-service:auth-impl')
jacocoAggregation project(':metadata-service:auth-servlet-impl')
jacocoAggregation project(':metadata-service:configuration')
jacocoAggregation project(':metadata-service:factories')
jacocoAggregation project(':metadata-service:graphql-servlet-impl')
jacocoAggregation project(':metadata-service:openapi-analytics-servlet')
jacocoAggregation project(':metadata-service:openapi-entity-servlet')
jacocoAggregation project(':metadata-service:openapi-servlet')
jacocoAggregation project(':metadata-service:plugin')
jacocoAggregation project(':metadata-service:restli-api')
jacocoAggregation project(':metadata-service:restli-client')
jacocoAggregation project(':metadata-service:restli-client-api')
jacocoAggregation project(':metadata-service:restli-servlet-impl')
jacocoAggregation project(':metadata-service:schema-registry-api')
jacocoAggregation project(':metadata-service:schema-registry-servlet')
jacocoAggregation project(':metadata-service:services')
jacocoAggregation project(':metadata-service:servlet')
jacocoAggregation project(':metadata-integration:java:acryl-spark-lineage')
jacocoAggregation project(':metadata-integration:java:custom-plugin-lib')
jacocoAggregation project(':metadata-integration:java:datahub-client')
jacocoAggregation project(':metadata-integration:java:datahub-event')
jacocoAggregation project(':metadata-integration:java:datahub-protobuf')
jacocoAggregation project(':metadata-integration:java:examples')
jacocoAggregation project(':metadata-integration:java:openlineage-converter')
jacocoAggregation project(':metadata-service:openapi-entity-servlet:generators')
jacocoAggregation project(':metadata-service:openapi-servlet:models')
}
4 changes: 2 additions & 2 deletions metadata-integration/java/openlineage-converter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ jacocoTestReport {

test {
forkEvery = 1
useJUnit()
useTestNG()
finalizedBy jacocoTestReport
}

test {
useJUnit()
useTestNG()
finalizedBy jacocoTestReport
}
shadowJar {
Expand Down
22 changes: 22 additions & 0 deletions metadata-models/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,25 @@ task cleanExtraDirs {
delete "$projectDir/src/generatedJsonSchema"
}
clean.finalizedBy(cleanExtraDirs)

test{
useTestNG()
finalizedBy jacocoTestReport
}

def jacocoExclusions = [
'**/openapi/generated/**'
];

jacocoTestReport {

afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it,
exclude: jacocoExclusions
)
}))
}

}

2 changes: 1 addition & 1 deletion metadata-service/restli-servlet-impl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ dependencies {
task integrationTest(type: Test) {
description = 'Runs integration tests.'
group = 'verification'
useJUnitPlatform()
useTestNG()

testClassesDirs = sourceSets.integTest.output.classesDirs
classpath = sourceSets.integTest.runtimeClasspath
Expand Down
6 changes: 3 additions & 3 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ include ':docker:datahub-ingestion'
include ':docker:datahub-ingestion-base'
include 'metadata-models'
include 'metadata-models-validator'
include 'metadata-testing:metadata-models-test-utils'
include 'metadata-testing:metadata-test-utils'
//include 'metadata-testing:metadata-models-test-utils'
//include 'metadata-testing:metadata-test-utils'
include 'entity-registry'
include 'metadata-io'
include 'metadata-io:metadata-io-api'
include 'datahub-upgrade'
include 'metadata-utils'
include 'li-utils'
include 'test-models'
include 'metadata-perf'
//include 'metadata-perf'
include 'docs-website'
include 'metadata-models-custom'
include 'entity-registry:custom-test-model'
Expand Down

0 comments on commit 28a29af

Please sign in to comment.