Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Commit

Permalink
Add support for better coverage reporting... and disable it because i…
Browse files Browse the repository at this point in the history
…t conflicts with configuration caching in Gradle 7.0
  • Loading branch information
davidmc24 committed Apr 22, 2021
1 parent 269014e commit 9b0a7d9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
arguments: --no-daemon --info --stacktrace build
dependencies-cache-enabled: true
configuration-cache-enabled: true
- uses: codecov/codecov-action@v1
with:
file: ./build/reports/jacoco/test/jacocoTestReport.xml
fail_ci_if_error: true
# - uses: codecov/codecov-action@v1
# with:
# file: ./build/reports/jacoco/test/jacocoTestReport.xml
# fail_ci_if_error: true
35 changes: 22 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,23 @@ plugins {
id "checkstyle"
id "codenarc"
id "idea"
id "jacoco"
// id "jacoco"
id "maven-publish"
id "signing"
id "java-gradle-plugin"
id "org.nosphere.gradle.github.actions" version "1.2.0"
id "io.github.gradle-nexus.publish-plugin" version "1.0.0"
// id "pl.droidsonroids.jacoco.testkit" version "1.0.8"
}

// Gradle TestKit (which most of this plugins tests run using) runs the builds in a separate
// JVM than the tests. Thus, for Jacoco to pick up on it, you need to do some extra legwork.
// https://github.com/koral--/jacoco-gradle-testkit-plugin seeks to solve that
// However, Gradle 7.0-rc-1 doesn't currently support the combination of the configuration cache
// with a Java agent (such as Jacoco) and TestKit.
// Thus, for now, no coverage reporting, as I place a higher value on testing configuration cache
// support.

group = "com.github.davidmc24.gradle.plugin"
version = "1.1.1-SNAPSHOT"

Expand Down Expand Up @@ -201,7 +210,7 @@ test {
gradleVersion: gradle.gradleVersion,
kotlinPluginVersion: latestKotlinVersion,
]
finalizedBy jacocoTestReport // report is always generated after tests run
// finalizedBy jacocoTestReport // report is always generated after tests run
}

tasks.create(name: "testCompatibility", type: Test) {
Expand Down Expand Up @@ -239,18 +248,18 @@ tasks.create(name: "testKotlinPluginCompatibility", type: Test) {
}
}

jacoco {
// 0.8.7+ needed for Java 15 support
// See https://www.jacoco.org/jacoco/trunk/doc/changes.html
toolVersion = "0.8.7-SNAPSHOT"
}
//jacoco {
// // 0.8.7+ needed for Java 15 support
// // See https://www.jacoco.org/jacoco/trunk/doc/changes.html
// toolVersion = "0.8.7-SNAPSHOT"
//}

jacocoTestReport {
reports {
html.enabled true
xml.enabled true
}
}
//jacocoTestReport {
// reports {
// html.enabled true
// xml.enabled true
// }
//}

tasks.withType(Test) {
jvmArgs "-Xss320k"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,15 @@ abstract class FunctionalSpec extends Specification {
}

protected void copyResource(String name, File targetFolder) {
def file = new File(targetFolder, name)
copyResource(name, targetFolder, name)
}

protected void copyResource(String name, File targetFolder, String targetName) {
def resource = getClass().getResourceAsStream(name)
def file = new File(targetFolder, targetName)
if (resource == null) {
throw new FileNotFoundException("Could not resource with name ${name}")
}
file.parentFile.mkdirs()
file << getClass().getResourceAsStream(name)
}
Expand All @@ -121,6 +129,8 @@ abstract class FunctionalSpec extends Specification {
}

protected GradleRunner createGradleRunner() {
// // Set up code coverage reporting based on https://github.com/koral--/jacoco-gradle-testkit-plugin
// copyResource("/testkit-gradle.properties", testProjectDir, "gradle.properties")
return GradleRunner.create().withProjectDir(testProjectDir).withGradleVersion(gradleVersion.version).withPluginClasspath()
}

Expand Down

0 comments on commit 9b0a7d9

Please sign in to comment.