Added snapshot and test badges
This commit is contained in:
parent
82640fb4ca
commit
7fc59d781a
2 changed files with 63 additions and 7 deletions
|
@ -1,5 +1,9 @@
|
|||
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
||||
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||
import java.net.URI
|
||||
import java.net.http.HttpClient
|
||||
import java.net.http.HttpRequest
|
||||
import java.net.http.HttpResponse
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
|
@ -60,11 +64,63 @@ tasks {
|
|||
}
|
||||
|
||||
test {
|
||||
val apiKey = project.properties["testsBadgeApiKey"]
|
||||
useJUnitPlatform()
|
||||
testLogging {
|
||||
exceptionFormat = TestExceptionFormat.FULL
|
||||
events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
|
||||
}
|
||||
addTestListener(object : TestListener {
|
||||
override fun beforeTest(p0: TestDescriptor?) = Unit
|
||||
override fun beforeSuite(p0: TestDescriptor?) = Unit
|
||||
override fun afterTest(desc: TestDescriptor, result: TestResult) = Unit
|
||||
override fun afterSuite(desc: TestDescriptor, result: TestResult) {
|
||||
if (desc.parent != null) {
|
||||
val output = result.run {
|
||||
"Results: $resultType (" +
|
||||
"$testCount tests, " +
|
||||
"$successfulTestCount successes, " +
|
||||
"$failedTestCount failures, " +
|
||||
"$skippedTestCount skipped" +
|
||||
")"
|
||||
}
|
||||
val testResultLine = "| $output |"
|
||||
val repeatLength = testResultLine.length
|
||||
val separationLine = "-".repeat(repeatLength)
|
||||
println()
|
||||
println(separationLine)
|
||||
println(testResultLine)
|
||||
println(separationLine)
|
||||
}
|
||||
|
||||
if (desc.parent == null) {
|
||||
val passed = result.successfulTestCount
|
||||
val failed = result.failedTestCount
|
||||
val skipped = result.skippedTestCount
|
||||
|
||||
if (apiKey != null) {
|
||||
val response: HttpResponse<String> = HttpClient.newHttpClient()
|
||||
.send(
|
||||
HttpRequest.newBuilder()
|
||||
.uri(
|
||||
URI(
|
||||
"https://rife2.com/tests-badge/update/com.uwyn.rife2/rife2-renderers?" +
|
||||
"NEW\n?" +
|
||||
"apiKey=$apiKey&" +
|
||||
"passed=$passed&" +
|
||||
"failed=$failed&" +
|
||||
"skipped=$skipped"
|
||||
)
|
||||
)
|
||||
.POST(HttpRequest.BodyPublishers.noBody())
|
||||
.build(), HttpResponse.BodyHandlers.ofString()
|
||||
)
|
||||
println("RESPONSE: " + response.statusCode())
|
||||
println(response.body())
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
javadoc {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue