Skip to content

Commit

Permalink
[build] Parallelize tests (#3764)
Browse files Browse the repository at this point in the history
Introduces parallel gradle execution of all the modules. Also, runs
JUnit tests in parallel.

With this change the JUnit tests run faster. This removes the need for
separating "slow" tests in CI and during publishing. Also, because the
modules are executed in parallel, the overall time is better. As an
expected outcome, our Gradle workflow files should be simplified.

Resolves #2270
  • Loading branch information
chemicL committed Mar 20, 2024
1 parent cf81b2f commit 0c0493a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 38 deletions.
20 changes: 3 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ jobs:
echo -e " \033[38;5;0;48;5;255m ./gradlew japicmp \033[0m"
echo ""
exit -1
core-fast:
name: core fast tests
core:
name: core tests
runs-on: ubuntu-latest
needs: preliminary
steps:
Expand All @@ -52,21 +52,7 @@ jobs:
- uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # tag=v3
name: gradle
with:
arguments: :reactor-core:test --no-daemon -Pjunit-tags=!slow
core-slow:
name: core slower tests
runs-on: ubuntu-latest
needs: preliminary
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4
- uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # tag=v3
with:
distribution: 'temurin'
java-version: 8
- uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # tag=v3
name: gradle
with:
arguments: :reactor-core:test --no-daemon -Pjunit-tags=slow
arguments: :reactor-core:test --no-daemon
other:
name: other tests
runs-on: ubuntu-latest
Expand Down
25 changes: 4 additions & 21 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,13 @@ jobs:
id: checks
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # tag=v3
with:
arguments: check -Pjunit-tags=!slow -x jcstress

slowerChecks:
# similar limitations as in prepare, but we parallelize slower tests here
name: slowerChecks
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4
- name: setup java
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # tag=v3
with:
distribution: 'temurin'
java-version: 8
- name: run slower tests
id: slowerTests
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # tag=v3
with:
arguments: reactor-core:test -Pjunit-tags=slow -Pjcstress.mode=sanity
arguments: check -x jcstress

#deploy the snapshot artifacts to Artifactory
deploySnapshot:
name: deploySnapshot
runs-on: ubuntu-20.04
needs: [ prepare, slowerChecks ]
needs: prepare
if: needs.prepare.outputs.versionType == 'SNAPSHOT'
environment: snapshots
steps:
Expand All @@ -77,7 +60,7 @@ jobs:
deployMilestone:
name: deployMilestone
runs-on: ubuntu-20.04
needs: [ prepare, slowerChecks ]
needs: prepare
if: needs.prepare.outputs.versionType == 'MILESTONE'
environment: releases
steps:
Expand All @@ -99,7 +82,7 @@ jobs:
deployRelease:
name: deployRelease
runs-on: ubuntu-20.04
needs: [ prepare, slowerChecks ]
needs: prepare
if: needs.prepare.outputs.versionType == 'RELEASE'
environment: releases
steps:
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
version=3.4.37-SNAPSHOT
bomVersion=2020.0.42

org.gradle.parallel=true
1 change: 1 addition & 0 deletions reactor-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ task loops(type: Test, group: 'verification') {
}

test {
maxParallelForks = Math.max(Runtime.runtime.availableProcessors() - 1, 1)
def tags = rootProject.findProperty("junit-tags")
if (tags != null) {
println "junit5 tags for core: $tags"
Expand Down
3 changes: 3 additions & 0 deletions reactor-tools/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ javaAgentTest {
}
project.tasks.check.dependsOn(javaAgentTest)

// This is required when org.gradle.parallel=true as tests in this module conflict with
// concurrently running BlockHound tests.
project.tasks.each {it.mustRunAfter(":reactor-core:blockHoundTest")}
project.tasks.buildPluginTest.mustRunAfter(shadowJar)
project.tasks.buildPluginTest.dependsOn(shadowJar)

Expand Down

0 comments on commit 0c0493a

Please sign in to comment.