Skip to content

Commit

Permalink
WIP 318 Restrict Gradle integration tests locally
Browse files Browse the repository at this point in the history
  • Loading branch information
ascheman committed Aug 29, 2024
1 parent 5f7b4dc commit b2672ec
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
16 changes: 14 additions & 2 deletions htmlSanityCheck-gradle-plugin/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,23 @@ htmlSanityCheck {

The Plugin has been tested with the following Gradle versions:

[source]
[source,groovy]
.Tested Gradle versions
----
include::src/test/groovy/org/aim42/htmlsanitycheck/gradle/HtmlSanityCheckTaskFunctionalTest.groovy[tag=tested-gradle-versions,indent=0]
include::src/test/groovy/org/aim42/htmlsanitycheck/gradle/HtmlSanityCheckTaskFunctionalSpec.groovy[tag=tested-gradle-versions,indent=0]
----

[NOTE]
====
The full range of Gradle versions is only tested in CI (GitHub action).
The local test only tests the latest Gradle version:
[source,groovy]
.Restricting versions to the latest versions locally
----
include::src/test/groovy/org/aim42/htmlsanitycheck/gradle/HtmlSanityCheckTaskFunctionalSpec.groovy[tag=restrict-gradle-versions-locally,indent=0]
----
====

[[sec:development-versions]]
== Development versions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,40 @@
package org.aim42.htmlsanitycheck.gradle


import org.gradle.testkit.runner.GradleRunner
import org.jsoup.Jsoup
import org.jsoup.nodes.Element
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import spock.lang.Unroll

import static org.gradle.testkit.runner.TaskOutcome.FAILED
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS

class HtmlSanityCheckTaskFunctionalSpec extends HtmlSanityCheckBaseSpec {

private final static GRADLE_VERSIONS = [
// @Slf4j does not initialize logger for static initializer
private static final Logger log = LoggerFactory.getLogger(HtmlSanityCheckTaskFunctionalSpec)

private final static List<String> getVersions(List<String> versions) {
// tag::restrict-gradle-versions-locally[]
def result = System.getenv("GITHUB_ACTION") ? versions : [versions[-1]]
// end::restrict-gradle-versions-locally[]
log.warn("Testing HSC Gradle plugin with versions '{}'", result)
return result
}

private final static String[] GRADLE_VERSIONS = getVersions([
// tag::tested-gradle-versions[]
// Test execution in CI will execute all versions.
// Local test is restricted to latest version
// 6.x or older does not work!
'7.6.3', // latest 7.x
'8.0.2', '8.1.1', '8.2.1', '8.3', '8.4',
'8.5', '8.6', '8.7', '8.8', '8.9',
'8.10' // all 8.x minor versions (latest patch release)
// end::tested-gradle-versions[]
]
])

@Unroll
def "can execute htmlSanityCheck task with Gradle version #gradleVersion"() {
Expand All @@ -27,7 +43,7 @@ class HtmlSanityCheckTaskFunctionalSpec extends HtmlSanityCheckBaseSpec {
createBuildFile()

when:
def result = runnerForHtmlSanityCheckTask(gradleVersion).build()
def result = runnerForHtmlSanityCheckTask(gradleVersion as String).build()

then:
result.task(":htmlSanityCheck").outcome == SUCCESS
Expand All @@ -46,7 +62,7 @@ class HtmlSanityCheckTaskFunctionalSpec extends HtmlSanityCheckBaseSpec {

when:

def result = runnerForHtmlSanityCheckTask(gradleVersion).buildAndFail()
def result = runnerForHtmlSanityCheckTask(gradleVersion as String).buildAndFail()

then:
result.task(":htmlSanityCheck").outcome == FAILED
Expand All @@ -69,7 +85,7 @@ class HtmlSanityCheckTaskFunctionalSpec extends HtmlSanityCheckBaseSpec {
""")

when:
def result = runnerForHtmlSanityCheckTask(gradleVersion).build()
def result = runnerForHtmlSanityCheckTask(gradleVersion as String).build()

then:
result.task(":htmlSanityCheck").outcome == SUCCESS
Expand All @@ -87,7 +103,7 @@ class HtmlSanityCheckTaskFunctionalSpec extends HtmlSanityCheckBaseSpec {
""")

when:
runnerForHtmlSanityCheckTask(gradleVersion).build()
runnerForHtmlSanityCheckTask(gradleVersion as String).build()
def htmlReportFile = new File(testProjectDir.root, "build/index.html")

then:
Expand Down

0 comments on commit b2672ec

Please sign in to comment.