World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#12583] improvement(ci): Optimize build test execution (#12584)
Qi Yua80f6fd2e70c
diff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlindex e7f9117c22..2c3f5a5426 100644--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -152,7 +152,7 @@ jobs:strategy:matrix:java-version: [ 17 ]- timeout-minutes: 90+ timeout-minutes: 120needs: changesif: needs.changes.outputs.source_changes == 'true'# Steps represent a sequence of tasks that will be executed as part of the job@@ -192,6 +192,7 @@ jobs:gradle_args=(build+ --max-workers=2-PskipWeb=true-PskipITs-PskipDockerTests=falsediff --git a/build.gradle.kts b/build.gradle.ktsindex 94ca8ac447..e1d288f139 100644--- a/build.gradle.kts+++ b/build.gradle.kts@@ -25,6 +25,8 @@ import com.github.jk1.license.render.ReportRendererimport com.github.vlsi.gradle.dsl.configureEachimport net.ltgt.gradle.errorprone.errorproneimport org.gradle.api.attributes.java.TargetJvmVersion+import org.gradle.api.services.BuildService+import org.gradle.api.services.BuildServiceParametersimport org.gradle.api.tasks.testing.logging.TestExceptionFormatimport org.gradle.internal.hash.ChecksumServiceimport org.gradle.internal.os.OperatingSystem@@ -34,6 +36,8 @@ import java.util.LocaleLocale.setDefault(Locale.US)+abstract class SharedTestEnvironmentLock : BuildService<BuildServiceParameters.None>+plugins {`maven-publish`id("java")@@ -61,6 +65,13 @@ plugins {alias(libs.plugins.errorprone)}+val sharedTestEnvironmentLock = gradle.sharedServices.registerIfAbsent(+ "sharedTestEnvironmentLock",+ SharedTestEnvironmentLock::class+) {+ maxParallelUsages.set(1)+}+val snappyJavaVersion: String = libs.versions.snappy.java.get()val scalaVersion: String = project.properties["scalaVersion"] as? String ?: extra["defaultScalaVersion"].toString()@@ -677,7 +688,11 @@ subprojects {showCauses = trueshowStackTraces = true}- reports.html.outputLocation.set(file("${rootProject.projectDir}/build/reports/"))+ // Distinct outputs let Gradle execute independent test tasks in parallel.+ val testReportPath = path.removePrefix(":").replace(':', '/')+ reports.html.outputLocation.set(+ rootProject.layout.buildDirectory.dir("reports/tests/$testReportPath")+ )val skipTests = project.hasProperty("skipTests")if (!skipTests) {val extraArgs = project.property("extraJvmArgs") as List<String>@@ -1253,6 +1268,22 @@ gradle.projectsEvaluated {subprojectJarOutputDirs.map { it.get().asFile.toPath().toAbsolutePath().normalize() }allprojects {+ val runsIntegrationTestsOnly = rootProject.hasProperty("skipTests")+ val hasDockerTests =+ rootProject.extra["dockerTest"] == true && fileTree("src/test") {+ include("**/*.java", "**/*.kt")+ }.any { it.readText().contains("gravitino-docker-test") }++ // Integration tests in different projects share the same Gravitino server, database,+ // containers, and configuration files. Running them together lets one test stop or reset+ // resources while another test is still using them. Normal builds keep independent unit tests+ // parallel and serialize only projects that contain Docker-tagged tests.+ if (runsIntegrationTestsOnly || hasDockerTests) {+ tasks.withType<Test>().configureEach {+ usesService(sharedTestEnvironmentLock)+ }+ }+tasks.withType<Jar>().configureEach {mustRunAfter(cleanDistributionPackageTask)}