Skip to content

Commit

Permalink
Fix local/GH Action build problems
Browse files Browse the repository at this point in the history
  • Loading branch information
ascheman committed Mar 29, 2024
1 parent b7fdd3f commit fadf6ae
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 26 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/gradle-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,18 @@ jobs:
coverage_report_title: JaCoCo
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Artifacts
- name: Upload (Maven) Artifacts
uses: actions/upload-artifact@v4
with:
name: maven-repo
path: build/maven-repo

- name: Upload (CLI) Artifacts
uses: actions/upload-artifact@v4
with:
name: CLI
path: htmlSanityCheck-cli/build/install

- name: Trigger Test Matrix Workflow
uses: benc-uk/workflow-dispatch@v1
with:
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/test-java-os-mix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,20 @@ jobs:
- name: Check out
uses: actions/checkout@v4

- name: Download Artifacts
- name: Download (Maven) Artifacts
uses: dawidd6/action-download-artifact@v3
with:
workflow: gradle-build.yml
name: maven-repo
path: build/maven-repo

- name: Download (CLI) Artifacts
uses: dawidd6/action-download-artifact@v3
with:
workflow: gradle-build.yml
name: CLI
path: htmlSanityCheck-cli/build/install

- name: Setup JDK
uses: actions/setup-java@v4
with:
Expand Down
79 changes: 55 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,23 @@ configure(subprojects) {
}
}

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_GRADLE_PLUGIN = "${INTEGRATION_TEST_DIRECTORY}/gradle-plugin"
final String INTEGRATION_TEST_DIRECTORY_CLI = "${INTEGRATION_TEST_DIRECTORY}/cli"

static void cleanBuild(String baseDirectory) {
File integrationTestBuildDir = new File("${baseDirectory}/${Project.DEFAULT_BUILD_DIR_NAME}")
static void cleanBuild(final File baseDirectory) {
File integrationTestBuildDir = new File(baseDirectory, "${Project.DEFAULT_BUILD_DIR_NAME}")
if (integrationTestBuildDir.exists()) {
integrationTestBuildDir.eachFileRecurse { file ->
file.delete()
Expand All @@ -105,71 +116,91 @@ static void cleanBuild(String baseDirectory) {
assert !integrationTestBuildDir.exists()
}

tasks.register("integrationTestGradlePlugin") {
tasks.register("integrationTestGradlePluginOnly") {
group("Verification")
description("Run gradle-plugin integration tests")
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

doLast {
def result = exec {
workingDir INTEGRATION_TEST_DIRECTORY_GRADLE_PLUGIN
commandLine "./gradlew", "clean", "htmlSanityCheck", "-PhtmlSanityCheckVersion=${project.version}"
commandLine System.getProperty("os.name") ==~ /Windows.*/ ? "gradlew.bat" : "./gradlew", "clean", "htmlSanityCheck", "-PhtmlSanityCheckVersion=${project.version}"
}
logger.debug "Script output: $result"
final File testIndex = new File(INTEGRATION_TEST_DIRECTORY_GRADLE_PLUGIN, "${Project.DEFAULT_BUILD_DIR_NAME}/reports/index.html")
assert testIndex.exists()
}
}
integrationTestGradlePlugin.dependsOn(
':htmlSanityCheck-core:publishAllPublicationsToMyLocalRepositoryForFullIntegrationTestsRepository',
':htmlSanityCheck-gradle-plugin:publishAllPublicationsToMyLocalRepositoryForFullIntegrationTestsRepository'
)
integrationTestGradlePlugin.configure {
shouldRunAfter(':htmlSanityCheck-gradle-plugin:check')
integrationTestGradlePluginOnly.configure {
mustRunAfter('publishAllPublicationsToMyLocalRepositoryForFullIntegrationTestsRepository')
}
tasks.register("integrationTestGradlePlugin") {
group("Verification")
description("Run overall gradle-plugin integration tests (and publish first)")
}
integrationTestGradlePlugin.dependsOn('publishAllPublicationsToMyLocalRepositoryForFullIntegrationTestsRepository',
'integrationTestGradlePluginOnly')
tasks.register("cleanIntegrationTestGradlePlugin", Delete) {
group("Build")
description("Deletes the result directory from gradle-plugin integration tests")

doLast {
cleanBuild INTEGRATION_TEST_DIRECTORY_GRADLE_PLUGIN
cleanBuild file(INTEGRATION_TEST_DIRECTORY_GRADLE_PLUGIN)
}
}
clean.dependsOn cleanIntegrationTestGradlePlugin

tasks.register("integrationTestCli") {
tasks.register("integrationTestCliOnly") {
group("Verification")
description("Run CLI integration tests")
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

doLast {
def result = exec {
workingDir INTEGRATION_TEST_DIRECTORY_CLI
new File(BUILD_REPORTS_DIRECTORY).mkdirs()
commandLine "../../htmlSanityCheck-cli/${Project.DEFAULT_BUILD_DIR_NAME}/install/hsc/bin/hsc", "-r", BUILD_REPORTS_DIRECTORY, "../common/src/test/resources"
file(BUILD_REPORTS_DIRECTORY).mkdirs()
String hscScriptFileName = "../../htmlSanityCheck-cli/${Project.DEFAULT_BUILD_DIR_NAME}/install/hsc/bin/hsc"
commandLine System.getProperty("os.name") ==~ /Windows.*/ ? "${hscScriptFileName}.bat" : hscScriptFileName,
"-r", BUILD_REPORTS_DIRECTORY, "../common/src/test/resources"
}
logger.debug "Script output: ${result}"
final File testIndex = new File(INTEGRATION_TEST_DIRECTORY_CLI, "${BUILD_REPORTS_DIRECTORY}/index.html")
assert testIndex.exists()
}
}
integrationTestCli.dependsOn(
':htmlSanityCheck-cli:installDist'
)
integrationTestCliOnly.configure {
mustRunAfter(':htmlSanityCheck-cli:installDist')
}
tasks.register("integrationTestCli") {
group("Verification")
description("Run overall CLI integration tests (and publish first)")
}
integrationTestCli.configure {
shouldRunAfter(':htmlSanityCheck-cli:check')
dependsOn(':htmlSanityCheck-cli:installDist', 'integrationTestCliOnly')
}
tasks.register("cleanIntegrationTestCli", Delete) {
group("Build")
description("Deletes the result directory from CLI integration tests")

doLast {
cleanBuild INTEGRATION_TEST_DIRECTORY_CLI
cleanBuild file(INTEGRATION_TEST_DIRECTORY_CLI)
}
}
//noinspection GroovyAssignabilityCheck
clean.dependsOn cleanIntegrationTestCli
integrationTestCli.dependsOn cleanIntegrationTestCli
//integrationTestCli.dependsOn cleanIntegrationTestCli
tasks.register("integrationTestOnly") {
group("Verification")
description("Run overall integration tests (only)")
}
integrationTestOnly.dependsOn(
'integrationTestGradlePluginOnly',
'integrationTestCliOnly'
)

tasks.register("integrationTest") {
group("Verification")
Expand Down

0 comments on commit fadf6ae

Please sign in to comment.