Skip to content

Commit

Permalink
#318 Migrate integration-test to this subdirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
ascheman committed Aug 21, 2024
1 parent bb8ffa2 commit 673ff19
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 130 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/test-java-os-mix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ jobs:
if: runner.os != 'Windows'
run: |
uname -a
./gradlew integrationTestOnly --scan
cd integration-test
../gradlew integrationTest --scan
- name: Execute integration tests (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
uname -a
cmd /c "echo off && gradlew.bat integrationTestOnly --scan"
cd integration-test
cmd /c "echo off && ..\gradlew.bat integrationTest --scan"
- name: Collect state upon failure (On Unix)
if: failure() && runner.os != 'Windows'
Expand Down
138 changes: 29 additions & 109 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ plugins {
alias(libs.plugins.sonar)

alias(libs.plugins.jreleaser)

id 'com.dorongold.task-tree' version '4.0.0'
}

allprojects {
Expand Down Expand Up @@ -61,7 +63,7 @@ tasks.register("cleanMavenBuildRepo", Delete) {
delete mavenBuildRepo
}

task signAll() {
tasks.register('signAll') {
doLast {
logger.quiet("Signed all artifacts for upload with JReleaser")
}
Expand Down Expand Up @@ -171,7 +173,7 @@ configure(subprojects) {
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
Expand Down Expand Up @@ -277,139 +279,57 @@ sonar {
tasks.register("publishAllPublicationsToMyLocalRepositoryForFullIntegrationTestsRepository") {
group("Publishing")
description("Publishes all publications to the local Maven repository")
}
publishAllPublicationsToMyLocalRepositoryForFullIntegrationTestsRepository.configure {

dependsOn(":htmlSanityCheck-core:publishMavenJavaPublicationToMyLocalRepositoryForFullIntegrationTestsRepository",
":htmlSanityCheck-gradle-plugin:publishPluginMavenPublicationToMyLocalRepositoryForFullIntegrationTestsRepository",
":htmlSanityCheck-gradle-plugin:publishHtmlSanityCheckPluginMarkerMavenPublicationToMyLocalRepositoryForFullIntegrationTestsRepository"
)
}

final String INTEGRATION_TEST_DIRECTORY = "integration-test"
final String INTEGRATION_TEST_DIRECTORY_CLI = "${INTEGRATION_TEST_DIRECTORY}/cli"
final String INTEGRATION_TEST_DIRECTORY_COMMON = "${INTEGRATION_TEST_DIRECTORY}/common"
final String INTEGRATION_TEST_DIRECTORY_GRADLE_PLUGIN = "${INTEGRATION_TEST_DIRECTORY}/gradle-plugin"

tasks.register("integrationTestPrepare") {
group("Verification")
description("Prepare integration tests data")

doLast {
def result = exec {
workingDir INTEGRATION_TEST_DIRECTORY_COMMON
commandLine System.getProperty("os.name") ==~ /Windows.*/
? "..\\..\\gradlew.bat"
: "../../gradlew", "clean", "buildReadmeAll"
}
logger.debug "Script output: $result"
}
}
tasks.register("cleanIntegrationTestCommon", Delete) {
description("Deletes the common data for integration tests")

doLast {
delete(file(INTEGRATION_TEST_DIRECTORY_COMMON))
}
}
//clean.dependsOn(cleanIntegrationTestCommon)
integrationTestPrepare.mustRunAfter(cleanIntegrationTestCommon)

tasks.register("integrationTestGradlePluginOnly") {
tasks.register("integrationTestOnly") {
group("Verification")
description("Run gradle-plugin integration tests (only)")

final File testIndex = new File(file(INTEGRATION_TEST_DIRECTORY_GRADLE_PLUGIN), "${Project.DEFAULT_BUILD_DIR_NAME}/reports/index.html")
outputs.file testIndex
description("Perform all Integration Tests")

doLast {
def result = exec {
workingDir INTEGRATION_TEST_DIRECTORY_GRADLE_PLUGIN
commandLine System.getProperty("os.name") ==~ /Windows.*/ ? "..\\..\\gradlew.bat" : "../../gradlew", "clean", "htmlSanityCheck", "-PhtmlSanityCheckVersion=${project.version}"
workingDir INTEGRATION_TEST_DIRECTORY
commandLine((System.getProperty("os.name") ==~ /Windows.*/
? "..\\gradlew.bat"
: "../gradlew"),
"integrationTest")
}
logger.debug "Script output: $result"
assert testIndex.exists()
logger.debug "Script output: ${result}"
}
}
integrationTestGradlePluginOnly.configure {
dependsOn(integrationTestPrepare)
mustRunAfter('publishAllPublicationsToMyLocalRepositoryForFullIntegrationTestsRepository')
}
tasks.register("integrationTestGradlePlugin") {
tasks.register("integrationTest") {
group("Verification")
description("Run overall gradle-plugin integration tests (and publish first)")
description("Run overall integration tests")
}
integrationTestGradlePlugin.dependsOn('publishAllPublicationsToMyLocalRepositoryForFullIntegrationTestsRepository',
'integrationTestGradlePluginOnly')
tasks.register("cleanIntegrationTestGradlePlugin", Delete) {
integrationTestOnly.mustRunAfter(publishAllPublicationsToMyLocalRepositoryForFullIntegrationTestsRepository,
':htmlSanityCheck-cli:installDist')
integrationTest.dependsOn(publishAllPublicationsToMyLocalRepositoryForFullIntegrationTestsRepository,
':htmlSanityCheck-cli:installDist',
integrationTestOnly
)
tasks.register("cleanIntegrationTest", Delete) {
group("Build")
description("Deletes the result directory from gradle-plugin integration tests")

doLast {
delete(file(INTEGRATION_TEST_DIRECTORY_GRADLE_PLUGIN))
}
}

tasks.register("integrationTestCliOnly") {
group("Verification")
description("Run CLI integration tests (only)")

final String BUILD_REPORTS_DIRECTORY = "${Project.DEFAULT_BUILD_DIR_NAME}/reports"
final File testIndex = new File(file(INTEGRATION_TEST_DIRECTORY_CLI), "${BUILD_REPORTS_DIRECTORY}/index.html")

outputs.file testIndex
description("Perform clean for Integration Tests")

doLast {
def result = exec {
workingDir INTEGRATION_TEST_DIRECTORY_CLI
file(BUILD_REPORTS_DIRECTORY).mkdirs()
String hscScriptFileName = "../../htmlSanityCheck-cli/${Project.DEFAULT_BUILD_DIR_NAME}/install/hsc/bin/hsc"
String params = "-r ${BUILD_REPORTS_DIRECTORY} ../common/${Project.DEFAULT_BUILD_DIR_NAME}/docs"
if (System.getProperty("os.name") ==~ /Windows.*/) {
commandLine 'cmd', '/c', "echo off && ${hscScriptFileName.replace('/', '\\')}.bat ${params}"
} else {
commandLine 'sh', '-c', "${hscScriptFileName} ${params}"
}
workingDir INTEGRATION_TEST_DIRECTORY
commandLine((System.getProperty("os.name") ==~ /Windows.*/
? "..\\gradlew.bat"
: "../gradlew"),
"clean")
}
logger.debug "Script output: ${result}"
assert testIndex.exists()
}
}
integrationTestCliOnly.configure {
dependsOn(integrationTestPrepare)
mustRunAfter(':htmlSanityCheck-cli:installDist')
}
tasks.register("integrationTestCli") {
group("Verification")
description("Run overall CLI integration tests (and publish first)")
}
integrationTestCli.configure {
dependsOn(':htmlSanityCheck-cli:installDist', 'integrationTestCliOnly')
}
tasks.register("cleanIntegrationTestCli", Delete) {
group("Build")
description("Deletes the result directory from CLI integration tests")

doLast {
delete(file(INTEGRATION_TEST_DIRECTORY_CLI))
}
}
tasks.register("integrationTestOnly") {
group("Verification")
description("Run overall integration tests (only)")
}
integrationTestOnly.dependsOn(
'integrationTestGradlePluginOnly',
'integrationTestCliOnly'
)
clean.dependsOn(cleanIntegrationTest)

tasks.register("integrationTest") {
group("Verification")
description("Run overall integration tests")
}
integrationTest.dependsOn(
'integrationTestGradlePlugin',
'integrationTestCli'
)

/*
* Copyright Gernot Starke and aim42 contributors.
Expand Down
135 changes: 135 additions & 0 deletions integration-test/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
final String BUILD_DIRECTORY = "${Project.DEFAULT_BUILD_DIR_NAME}"

version = htmlSanityCheckVersion

final String INTEGRATION_TEST_DIRECTORY_COMMON = "common"
final String INTEGRATION_TEST_DIRECTORY_COMMON_BUILD = "common/${BUILD_DIRECTORY}"

final static String gradleCall() {
return System.getProperty("os.name") ==~ /Windows.*/
? "..\\..\\gradlew.bat"
: "../../gradlew"
}

tasks.register("cleanIntegrationTestCommon", Delete) {
group("Build")
description("Deletes the common data for integration tests")

def filesToDelete
= files(INTEGRATION_TEST_DIRECTORY_COMMON_BUILD)

delete(filesToDelete)

outputs.upToDateWhen {
!filesToDelete.files.any { it.exists() }
}
}
tasks.register("integrationTestPrepare") {
group("Verification")
description("Prepare integration tests data")

mustRunAfter(cleanIntegrationTestCommon)

doLast {
def result = exec {
workingDir INTEGRATION_TEST_DIRECTORY_COMMON
commandLine (gradleCall(), "clean", "buildReadmeAll")
}
logger.debug "Script output: $result"
}
}

final String INTEGRATION_TEST_DIRECTORY_GRADLE_PLUGIN = "gradle-plugin"
final String INTEGRATION_TEST_DIRECTORY_GRADLE_PLUGIN_BUILD = "gradle-plugin/${BUILD_DIRECTORY}"

tasks.register("cleanIntegrationTestGradlePlugin", Delete) {
group("Build")
description("Deletes the result directory from gradle-plugin integration tests")

def filesToDelete
= files(INTEGRATION_TEST_DIRECTORY_GRADLE_PLUGIN_BUILD)

delete(filesToDelete)

outputs.upToDateWhen {
!filesToDelete.files.any { it.exists() }
}
}
tasks.register("integrationTestGradlePlugin") {
group("Verification")
description("Run gradle-plugin integration tests (only)")

final String buildReportsDirectory = "${INTEGRATION_TEST_DIRECTORY_GRADLE_PLUGIN_BUILD}/reports"
final File testIndex = new File(file(buildReportsDirectory), "index.html")
outputs.file testIndex

dependsOn(integrationTestPrepare)
mustRunAfter(cleanIntegrationTestGradlePlugin)

doLast {
def result = exec {
workingDir INTEGRATION_TEST_DIRECTORY_GRADLE_PLUGIN
commandLine (gradleCall(), "clean", "htmlSanityCheck", "-PhtmlSanityCheckVersion=${project.version}")
}
logger.debug "Script output: $result"
assert testIndex.exists()
}
}

final String INTEGRATION_TEST_DIRECTORY_CLI = "cli"
final String INTEGRATION_TEST_DIRECTORY_CLI_BUILD = "${INTEGRATION_TEST_DIRECTORY_CLI}/${BUILD_DIRECTORY}"

tasks.register("cleanIntegrationTestCli", Delete) {
group("Build")
description("Deletes the result directory from CLI integration tests")

def filesToDelete
= files(INTEGRATION_TEST_DIRECTORY_CLI_BUILD)

delete(filesToDelete)

outputs.upToDateWhen {
!filesToDelete.files.any { it.exists() }
}
}
tasks.register("integrationTestCli") {
group("Verification")
description("Run CLI integration tests (only)")

final File buildReportsDirectory = file("${INTEGRATION_TEST_DIRECTORY_CLI_BUILD}/reports")
final File testIndex = new File(buildReportsDirectory, "index.html")

outputs.file testIndex

dependsOn(integrationTestPrepare)
mustRunAfter(cleanIntegrationTestCli)

doLast {
def result = exec {
buildReportsDirectory.mkdirs()
final String hscScriptFileName = "../htmlSanityCheck-cli/${BUILD_DIRECTORY}/install/hsc/bin/hsc"
String params = "-r ${buildReportsDirectory} ${INTEGRATION_TEST_DIRECTORY_COMMON_BUILD}/docs"
if (System.getProperty("os.name") ==~ /Windows.*/) {
commandLine 'cmd', '/c', "echo off && ${hscScriptFileName.replace('/', '\\')}.bat ${params}"
} else {
commandLine 'sh', '-c', "${hscScriptFileName} ${params}"
}
}
logger.debug "Script output: ${result}"
assert testIndex.exists()
}
}

tasks.register("integrationTest") {
group("Verification")
description("Run all integration tests (without any installations etc.)")

dependsOn(integrationTestGradlePlugin, integrationTestCli)
}

tasks.register("clean", Delete) {
group("Build")
description("Deletes all builds")

dependsOn(cleanIntegrationTestCommon, cleanIntegrationTestGradlePlugin, cleanIntegrationTestCli)
}
Loading

0 comments on commit 673ff19

Please sign in to comment.