@@ -179,18 +179,66 @@ tasks.register("integrationTestMavenPlugin") {
179179 }
180180}
181181
182+ final String INTEGRATION_TEST_DIRECTORY_DOCKER = " docker"
183+ final String INTEGRATION_TEST_DIRECTORY_DOCKER_BUILD = " ${ INTEGRATION_TEST_DIRECTORY_DOCKER} /${ BUILD_DIRECTORY} "
184+
185+ tasks. register(" cleanIntegrationTestDocker" , Delete ) {
186+ group(" Build" )
187+ description(" Deletes the result directory from Docker integration tests" )
188+
189+ def filesToDelete = files(INTEGRATION_TEST_DIRECTORY_DOCKER_BUILD )
190+ delete(filesToDelete)
191+ outputs. upToDateWhen { ! filesToDelete. files. any { it. exists() } }
192+ }
193+
194+ tasks. register(" integrationTestDocker" ) {
195+ group(" Verification" )
196+ description(" Run Docker integration tests (only)" )
197+
198+ final File buildReportsDirectory = file(" ${ INTEGRATION_TEST_DIRECTORY_DOCKER_BUILD} /reports" )
199+ final File testIndex = new File (buildReportsDirectory, " index.html" )
200+ outputs. file testIndex
201+
202+ dependsOn(integrationTestPrepare)
203+ mustRunAfter(cleanIntegrationTestDocker)
204+
205+ doLast {
206+ buildReportsDirectory. mkdirs()
207+ // Compute the image tag exactly as in the CLI module: use branch name tag
208+ String currentBranch = " ${ 'git branch --show-current'.execute().text.trim()} "
209+ String branchTag = currentBranch. replaceAll(' /' , ' -' )
210+ String image = " ghcr.io/aim42/hsc:${ branchTag} "
211+
212+ // Prepare absolute paths for volume mounts
213+ String docsDir = file(" ${ INTEGRATION_TEST_DIRECTORY_COMMON_BUILD} /docs" ). absolutePath
214+ String reportsDir = buildReportsDirectory. absolutePath
215+
216+ String params = " --rm -v \" ${ docsDir} :${ docsDir} \" -v \" ${ reportsDir} \" :/reports -w \" ${ docsDir} \" ${ image} -r /reports --exclude https://www.baeldung.com/.*"
217+ def result = exec {
218+ if (System . getProperty(" os.name" ) ==~ / Windows.*/ ) {
219+ // Use cmd to run docker on Windows
220+ commandLine ' cmd' , ' /c' , " docker run ${ params} "
221+ } else {
222+ commandLine ' sh' , ' -c' , " docker run ${ params} "
223+ }
224+ }
225+ logger. debug " Script output: ${ result} "
226+ assert testIndex. exists()
227+ }
228+ }
229+
182230tasks. register(" integrationTest" ) {
183231 group(" Verification" )
184232 description(" Run all integration tests (without any installations etc.)" )
185233
186- dependsOn(integrationTestGradlePlugin, integrationTestCli, integrationTestMavenPlugin)
234+ dependsOn(integrationTestGradlePlugin, integrationTestCli, integrationTestMavenPlugin, integrationTestDocker )
187235}
188236
189237tasks. register(" cleanIntegrationTest" , Delete ) {
190238 group(" Build" )
191239 description(" Deletes all integration test builds" )
192240
193241 dependsOn(cleanIntegrationTestCommon, cleanIntegrationTestGradlePlugin,
194- cleanIntegrationTestCli, cleanIntegrationTestMavenPlugin)
242+ cleanIntegrationTestCli, cleanIntegrationTestMavenPlugin, cleanIntegrationTestDocker )
195243}
196244clean. dependsOn(cleanIntegrationTest)
0 commit comments