This is an automated email from the ASF dual-hosted git repository.

jamesfredley pushed a commit to branch improve-gh-ci-speed
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit 2e51260400e9207a06a9a16483efae096b971834
Author: James Fredley <[email protected]>
AuthorDate: Fri Jan 23 20:23:52 2026 -0500

    Optimize CI workflow to reduce build time
    
    Replace --rerun-tasks with cleanTest to leverage Develocity cache while
    still ensuring tests always run.
    
    Changes:
    - Replace --rerun-tasks with cleanTest pattern (enables compilation caching)
    - Add --configuration-cache-problems=warn for faster Gradle startup
    - Increase maxParallelForks from 3 to 4 (matches GitHub runner cores)
    - Increase forkEvery from 10-25 to 50 (reduces JVM restart overhead)
    - Enable Develocity test distribution for CI builds
    
    Ref: 
https://github.com/apache/grails-core/commit/a78c0225059468f4d66bb13b72f813be2e78a66c
---
 .github/workflows/gradle.yml        | 19 +++++++++----------
 build.gradle                        |  2 +-
 gradle/test-config.gradle           |  6 +++++-
 grails-test-suite-uber/build.gradle |  2 +-
 grails-test-suite-web/build.gradle  |  2 +-
 5 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml
index 27216b1a14..26fa01c79f 100644
--- a/.github/workflows/gradle.yml
+++ b/.github/workflows/gradle.yml
@@ -59,10 +59,10 @@ jobs:
         if: ${{ !contains(github.event.head_commit.message, '[skip tests]') }}
         working-directory: 'grails-gradle'
         run: >
-          ./gradlew build
+          ./gradlew cleanTest build
           --continue
           --stacktrace
-          --rerun-tasks
+          --configuration-cache-problems=warn
           -PskipCodeStyle
   build:
     if: ${{ !contains(github.event.head_commit.message, '[skip tests]') }}
@@ -89,9 +89,8 @@ jobs:
           develocity-access-key: ${{ secrets.GRAILS_DEVELOCITY_ACCESS_KEY  }}
       - name: "🔨 Build project"
         run: >
-          ./gradlew build :grails-shell-cli:installDist groovydoc
+          ./gradlew cleanTest build :grails-shell-cli:installDist groovydoc
           --continue
-          --rerun-tasks
           --stacktrace
           -PonlyCoreTests
           -PskipCodeStyle
@@ -129,10 +128,10 @@ jobs:
         if: ${{ !contains(github.event.head_commit.message, '[skip tests]') }}
         working-directory: 'grails-forge'
         run: >
-          ./gradlew build
+          ./gradlew cleanTest build
           --continue
-          --rerun-tasks
           --stacktrace
+          --configuration-cache-problems=warn
           -PskipCodeStyle
       - name: "✅ Verify combined CLI"
         run: |
@@ -174,10 +173,10 @@ jobs:
           develocity-access-key: ${{ secrets.GRAILS_DEVELOCITY_ACCESS_KEY  }}
       - name: "🏃 Run Functional Tests"
         run: >
-          ./gradlew bootJar check
+          ./gradlew bootJar cleanTest check
           --continue
-          --rerun-tasks
           --stacktrace
+          --configuration-cache-problems=warn
           -PgebAtCheckWaiting
           -PonlyFunctionalTests
           -PskipCodeStyle
@@ -212,8 +211,8 @@ jobs:
         run: >
           ./gradlew bootJar cleanTest check
           --continue
-          --rerun-tasks
           --stacktrace
+          --configuration-cache-problems=warn
           -PonlyMongodbTests
           -PmongodbContainerVersion=${{ matrix.mongodb-version }}
           -PskipCodeStyle
@@ -245,8 +244,8 @@ jobs:
         run: >
           ./gradlew bootJar cleanTest check
           --continue
-          --rerun-tasks
           --stacktrace
+          --configuration-cache-problems=warn
           -PonlyHibernate5Tests
           -PskipCodeStyle
   publishGradle:
diff --git a/build.gradle b/build.gradle
index 2338d4bac6..ae6246d0e9 100644
--- a/build.gradle
+++ b/build.gradle
@@ -32,7 +32,7 @@ ext {
             DateTimeFormatter.ISO_DATE.format(LocalDate.ofInstant(buildInstant 
as Instant, ZoneOffset.UTC))
     buildDate = (buildInstant as Instant).atZone(ZoneOffset.UTC) // for 
reproducible builds
     isCiBuild = System.getenv().get('CI') as Boolean
-    configuredTestParallel = findProperty('maxTestParallel') as Integer ?: 
(isCiBuild ? 3 : Runtime.runtime.availableProcessors() * 3 / 4 as int ?: 1)
+    configuredTestParallel = findProperty('maxTestParallel') as Integer ?: 
(isCiBuild ? 4 : Runtime.runtime.availableProcessors() * 3 / 4 as int ?: 1)
     excludeUnusedTransDeps = findProperty('excludeUnusedTransDeps')
 
     testProjectsStartWith = [
diff --git a/gradle/test-config.gradle b/gradle/test-config.gradle
index c30db8a746..a601c07f4b 100644
--- a/gradle/test-config.gradle
+++ b/gradle/test-config.gradle
@@ -52,6 +52,10 @@ tasks.withType(Test).configureEach {
             maxFailures = 20
             failOnPassedAfterRetry = true
         }
+        testDistribution {
+            enabled = isCiBuild
+            maxLocalExecutors = configuredTestParallel
+        }
     }
     testLogging {
         events('passed', 'skipped', 'failed')
@@ -63,7 +67,7 @@ tasks.withType(Test).configureEach {
     excludes = ['**/*TestCase.class', '**/*$*.class']
     maxParallelForks = configuredTestParallel
     maxHeapSize = isCiBuild ? '768m' : '1024m'
-    forkEvery = hasProperty('forkEveryUnitTest') ? 
getProperty('forkEveryUnitTest') as long : (isCiBuild ? 20 : 100)
+    forkEvery = hasProperty('forkEveryUnitTest') ? 
getProperty('forkEveryUnitTest') as long : (isCiBuild ? 50 : 100)
     if (System.getProperty('debug.tests')) {
         jvmArgs += debugArguments
     }
diff --git a/grails-test-suite-uber/build.gradle 
b/grails-test-suite-uber/build.gradle
index a2c1ce91fd..f92621756c 100644
--- a/grails-test-suite-uber/build.gradle
+++ b/grails-test-suite-uber/build.gradle
@@ -149,7 +149,7 @@ tasks.withType(Test).configureEach {
     }
     useJUnitPlatform()
     maxParallelForks = configuredTestParallel
-    forkEvery = isCiBuild ? 25 : 100
+    forkEvery = isCiBuild ? 50 : 100
     maxHeapSize = isCiBuild ? '768m' : '1024m'
     jvmArgs('--add-opens=java.base/java.lang=ALL-UNNAMED', 
'--add-opens=java.base/java.util=ALL-UNNAMED')
 }
diff --git a/grails-test-suite-web/build.gradle 
b/grails-test-suite-web/build.gradle
index 2da78fd033..85e128897a 100644
--- a/grails-test-suite-web/build.gradle
+++ b/grails-test-suite-web/build.gradle
@@ -50,7 +50,7 @@ dependencies {
 
 def defaultTestConfig = {
     maxParallelForks = configuredTestParallel
-    forkEvery = isCiBuild ? 10 : 100
+    forkEvery = isCiBuild ? 50 : 100
     excludes = ['**/*TestCase.class', '**/*$*.class']
 }
 

Reply via email to