Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support Retry Test in CI #486

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.testretry.TestRetryPlugin

/*
* Copyright [2021-present] [ahoo wang <[email protected]> (https://github.com/Ahoo-Wang)].
Expand All @@ -14,6 +15,7 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
*/

plugins {
alias(libs.plugins.testRetry)
alias(libs.plugins.publishPlugin)
alias(libs.plugins.jmhPlugin)
alias(libs.plugins.spotbugsPlugin)
Expand Down Expand Up @@ -42,7 +44,7 @@ val testProject = project(":cosid-test")
val codeCoverageReportProject = project(":code-coverage-report")
val publishProjects = subprojects - serverProjects - codeCoverageReportProject
val libraryProjects = publishProjects - bomProjects

val isInCI = null != System.getenv("CI")
ext.set("libraryProjects", libraryProjects)

allprojects {
Expand Down Expand Up @@ -114,7 +116,7 @@ configure(libraryProjects) {
fork.set(1)
jvmArgs.set(listOf("-Dlogback.configurationFile=${rootProject.rootDir}/config/logback-jmh.xml"))
}

apply<TestRetryPlugin>()
tasks.withType<Test> {
useJUnitPlatform()
testLogging {
Expand All @@ -127,6 +129,13 @@ configure(libraryProjects) {
"--add-opens=java.base/java.util=ALL-UNNAMED",
"--add-opens=java.base/java.lang=ALL-UNNAMED"
)
retry {
if (isInCI) {
maxRetries = 2
maxFailures = 20
}
failOnPassedAfterRetry = true
}
}

dependencies {
Expand Down Expand Up @@ -169,14 +178,6 @@ configure(publishProjects) {
password = System.getenv("GITHUB_TOKEN")
}
}
maven {
name = "LinYiPackages"
url = uri(project.properties["linyiPackageReleaseUrl"].toString())
credentials {
username = project.properties["linyiPackageUsername"]?.toString()
password = project.properties["linyiPackagePwd"]?.toString()
}
}
}
publications {
val publishName = if (isBom) "mavenBom" else "mavenLibrary"
Expand Down Expand Up @@ -217,7 +218,6 @@ configure(publishProjects) {
}

configure<SigningExtension> {
val isInCI = null != System.getenv("CI");
if (isInCI) {
val signingKeyId = System.getenv("SIGNING_KEYID")
val signingKey = System.getenv("SIGNING_SECRETKEY")
Expand Down
3 changes: 2 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ springDoc = "2.2.0"
hamcrest = "2.2"
jmh = "1.37"
# plugins
testRetry= "1.5.6"
publishPlugin = "1.3.0"
jmhPlugin = "0.7.2"
spotbugs = "5.2.3"
Expand All @@ -39,7 +40,7 @@ hamcrest = { module = "org.hamcrest:hamcrest", version.ref = "hamcrest" }
jmhCore = { module = "org.openjdk.jmh:jmh-core", version.ref = "jmh" }
jmhGeneratorAnnprocess = { module = "org.openjdk.jmh:jmh-generator-annprocess", version.ref = "jmh" }
[plugins]

testRetry = { id = "org.gradle.test-retry", version.ref = "testRetry" }
publishPlugin = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "publishPlugin" }
jmhPlugin = { id = "me.champeau.jmh", version.ref = "jmhPlugin" }
spotbugsPlugin = { id = "com.github.spotbugs", version.ref = "spotbugs" }
Expand Down
Loading