Skip to content

Commit

Permalink
Trying to parallelize everything except performance tests (#1588)
Browse files Browse the repository at this point in the history
  • Loading branch information
oxisto authored Jun 13, 2024
1 parent e8a6f10 commit 6d83bf8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ jobs:
run: |
if [ "$SONAR_TOKEN" != "" ]
then
./gradlew -Pversion=$VERSION spotlessCheck -x spotlessApply build -x distZip -x distTar sonar performanceTest integrationTest \
./gradlew --parallel -Pversion=$VERSION spotlessCheck -x spotlessApply build -x distZip -x distTar sonar performanceTest integrationTest \
-Dsonar.projectKey=Fraunhofer-AISEC_cpg \
-Dsonar.organization=fraunhofer-aisec \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.token=$SONAR_TOKEN
else
./gradlew -Pversion=$VERSION spotlessCheck -x spotlessApply build -x distZip -x distTar performanceTest integrationTest
./gradlew --parallel -Pversion=$VERSION spotlessCheck -x spotlessApply build -x distZip -x distTar performanceTest integrationTest
fi
id: build
env:
Expand Down
24 changes: 13 additions & 11 deletions buildSrc/src/main/kotlin/cpg.common-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ tasks.test {
}

maxHeapSize = "4048m"
shouldRunAfter(performanceTest)
}

val integrationTest = tasks.register<Test>("integrationTest") {
Expand All @@ -145,22 +144,25 @@ val performanceTest = tasks.register<Test>("performanceTest") {

maxHeapSize = "4048m"

usesService(provider)
// do not parallelize tests within the task
maxParallelForks = 1
// make sure that several performance tests (e.g. in different frontends) also do NOT run in parallel
usesService(serialExecutionService)

mustRunAfter(tasks.getByPath(":sonar"))
}

// A build service that ensures serial execution of a group of tasks
abstract class SerialExecutionService : BuildService<BuildServiceParameters.None>
val serialExecutionService =
gradle.sharedServices.registerIfAbsent("serialExecution", SerialExecutionService::class.java) {
this.maxParallelUsages.set(1)
}

kover {
currentProject {
instrumentation {
disabledForTestTasks.add("performanceTest")
}
}
}

// this should limit the performance test to non-parallel but does not work yet
abstract class LimitExecutionService : BuildService<BuildServiceParameters.None> {

}

val provider = project.getGradle().getSharedServices().registerIfAbsent<LimitExecutionService, BuildServiceParameters.None>("limit", LimitExecutionService::class.java, {
getMaxParallelUsages().set(0)
})

0 comments on commit 6d83bf8

Please sign in to comment.