Skip to content

Commit

Permalink
Splitting test tasks ci (#369)
Browse files Browse the repository at this point in the history
* splitting CI tasks

* incresing the sleep in the task

* increasing the sleep to the output publisher

* removing the executor

* update sample

* update Gradle 7.5
  • Loading branch information
cdsap authored Sep 14, 2023
1 parent f672502 commit 11ccb1b
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 20 deletions.
9 changes: 7 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ jobs:
name: assemble
command: ./gradlew assemble
- run:
name: test
name: test plugins
command: |
java --version
./gradlew collectUnitTest --stacktrace --info
- run:
name: test libs
command: |
java --version
./gradlew collectUnitTest --stacktrace --info
./gradlew collectUnitTestLibs --stacktrace --info
- run:
name: build sample
command: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class TalaiotKotlinLibPlugin : Plugin<Project> {
val extension = extensions.getByType<BaseConfiguration>()
setProjectVersion(extension.version)
setProjectGroup(extension.group, Type.LIBRARY)
collectUnitTest()
collectUnitTestLibs()
setUpPublishing(Type.LIBRARY)
setUpSigning("TalaiotLib")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,30 @@ fun Project.collectUnitTest() = this.run {
val pr = this
testTask.configure(closureOf<TestReport> {
group = "Verification"
description = "Collect all tests"
description = "Collect plugin tests"

val testTask = pr.tasks.find { it.name == "test" }
testTask?.let { reportOn(testTask) }
destinationDir = file("${rootProject.buildDir}/reports/tests")
})

}
}

fun Project.collectUnitTestLibs() = this.run {
val testTask = if (rootProject.tasks.findByPath("collectUnitTestLibs") == null) {
rootProject.tasks.create("collectUnitTestLibs", TestReport::class) {
}
} else {
rootProject.tasks["collectUnitTestLibs"]
}
val pr = this
testTask.configure(closureOf<TestReport> {
group = "Verification"
description = "Collect tests libs modules"

val testTask = pr.tasks.find { it.name == "test" }
testTask?.let { reportOn(testTask) }
destinationDir = file("${rootProject.buildDir}/reports/tests")
})

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import org.gradle.api.services.BuildService
import org.gradle.api.services.BuildServiceParameters
import org.gradle.tooling.events.FinishEvent
import org.gradle.tooling.events.OperationCompletionListener
import java.util.concurrent.Executors

/**
* Tracks information of the tasks executed duting the build.
Expand Down Expand Up @@ -49,19 +48,16 @@ abstract class TalaiotBuildService :

override fun close() {

val executor = Executors.newSingleThreadExecutor()
val end = System.currentTimeMillis()

executor.execute {
parameters.publisher.get().publish(
taskLengthList = taskLengthList,
start = start,
configuraionMs = configurationTime,
end = end,
duration = end - start,
success = taskLengthList.none { it.state == TaskMessageState.FAILED }
)
}
parameters.publisher.get().publish(
taskLengthList = taskLengthList,
start = start,
configuraionMs = configurationTime,
end = end,
duration = end - start,
success = taskLengthList.none { it.state == TaskMessageState.FAILED }
)
}

override fun onFinish(event: FinishEvent?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class DefaultConfigurationSpec : StringSpec({
.withPluginClasspath()
.withGradleVersion(version)
.build()
Thread.sleep(2000)
Thread.sleep(5000)
val reportFile = File(testProjectDir.getRoot(), "build/reports/talaiot/json/data.json")
val report = Gson().fromJson(reportFile.readText(), ExecutionReport::class.java)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class OutputPublisherBuildTest : BehaviorSpec({
.withArguments("assemble")
.withPluginClasspath()
.build()
Thread.sleep(2000)

then("logs are shown in the output with the shrugged") {
assert(result.output.contains("OutputPublisher"))
Expand Down
2 changes: 1 addition & 1 deletion sample/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 11ccb1b

Please sign in to comment.