Skip to content

Commit

Permalink
Add docker check to gradle to prevent cryptic test failures due to do…
Browse files Browse the repository at this point in the history
…cker not started
  • Loading branch information
fhennig authored and corneliusroemer committed Sep 27, 2024
1 parent d907642 commit 47b76d2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,25 @@ dependencies {
}
}

// Check if the docker engine is running and reachable
task checkDocker {
doLast {
def process = "docker info".execute()
def output = new StringWriter()
def error = new StringWriter()
process.consumeProcessOutput(output, error)
process.waitFor()

if (process.exitValue() != 0) {
throw new GradleException("Docker is not running: ${error.toString()}")
}
println "Docker is running."
}
}

tasks.named('test') {
// Docker is required to start the testing database
dependsOn checkDocker
useJUnitPlatform()
testLogging {
events TestLogEvent.FAILED
Expand Down

0 comments on commit 47b76d2

Please sign in to comment.