Added tests badge
This commit is contained in:
parent
9003f95df3
commit
58c0f62604
3 changed files with 42 additions and 3 deletions
2
.github/workflows/gradle.yml
vendored
2
.github/workflows/gradle.yml
vendored
|
@ -46,7 +46,7 @@ jobs:
|
|||
${{ runner.os }}-gradle-${{ matrix.java-version }}-
|
||||
|
||||
- name: Test with Gradle
|
||||
run: ./gradlew build check --stacktrace
|
||||
run: ./gradlew build check --stacktrace -PtestsBadgeApiKey=${{ secrets.TESTS_BADGE_API_KEY }}
|
||||
|
||||
- name: SonarCloud
|
||||
if: success() && matrix.java-version == env.SONAR_JDK
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
[](https://opensource.org/licenses/Apache-2.0)
|
||||
[](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/urlencoder/)
|
||||
[](https://github.com/ethauvin/urlencoder/releases/latest)
|
||||
[](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/urlencoder)
|
||||
|
||||
[//]: # ([](https://github.com/ethauvin/urlencoder/releases/latest))
|
||||
[//]: # ([](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/urlencoder))
|
||||
[](https://sonarcloud.io/dashboard?id=ethauvin_urlencoder)
|
||||
[](https://github.com/ethauvin/urlencoder/actions/workflows/gradle.yml)
|
||||
[](https://github.com/ethauvin/urlencoder/actions/workflows/gradle.yml)
|
||||
|
||||
# URL Encoder for Kotlin and Java
|
||||
|
||||
|
|
|
@ -2,6 +2,11 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
|||
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||
import org.jetbrains.dokka.gradle.DokkaTask
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import java.net.URI
|
||||
import java.net.http.HttpClient
|
||||
import java.net.http.HttpRequest
|
||||
import java.net.http.HttpResponse
|
||||
|
||||
|
||||
plugins {
|
||||
id("application")
|
||||
|
@ -82,6 +87,39 @@ tasks {
|
|||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
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 passed = result.successfulTestCount
|
||||
val failed = result.failedTestCount
|
||||
val skipped = result.skippedTestCount
|
||||
|
||||
if (project.properties["testsBadgeApiKey"] != null) {
|
||||
val apiKey = project.properties["testsBadgeApiKey"]
|
||||
val response: HttpResponse<String> = HttpClient.newHttpClient()
|
||||
.send(
|
||||
HttpRequest.newBuilder()
|
||||
.uri(
|
||||
URI(
|
||||
"https://rife2.com/tests-badge/update/com.uwyn/urlencoder?" +
|
||||
"apiKey=$apiKey&" +
|
||||
"passed=$passed&" +
|
||||
"failed=$failed&" +
|
||||
"skipped=$skipped"
|
||||
)
|
||||
)
|
||||
.POST(HttpRequest.BodyPublishers.noBody())
|
||||
.build(), HttpResponse.BodyHandlers.ofString()
|
||||
)
|
||||
println("RESPONSE: ${response.statusCode()}")
|
||||
println(response.body())
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
withType<Test> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue