chore: mastodonでもカバレッジ率を計測するように

This commit is contained in:
usbharu 2024-09-16 23:39:12 +09:00
parent 375113f384
commit 5456413e42
Signed by: usbharu
GPG Key ID: 95CBCF7046307B77
2 changed files with 121 additions and 3 deletions

View File

@ -76,7 +76,36 @@ jobs:
gradle-home-cache-cleanup: true
- name: Build
run: ./gradlew classes --no-daemon
run: ./gradlew :hideout-core:classes --no-daemon
hideout-mastodon-setup:
needs:
- change
if: github.event.pull_request.draft == false && needs.change.outputs.mastodon == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
- name: Gradle Wrapper Validation
uses: gradle/actions/wrapper-validation@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
cache-read-only: false
gradle-home-cache-cleanup: true
- name: Build
run: ./gradlew :hideout-mastodon:classes --no-daemon
hideout-core-unit-test:
needs:
@ -117,22 +146,62 @@ jobs:
name: 'hideout-core.xml'
path: 'hideout-core/build/reports/kover/hideout-core.xml'
hideout-mastodon-unit-test:
needs:
- hideout-mastodon-setup
- change
if: github.event.pull_request.draft == false && needs.change.outputs.mastodon == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
cache-read-only: false
gradle-home-cache-cleanup: true
- name: Unit Test
run: ./hideout-mastodon/gradlew :hideout-mastodon:koverXmlReport
- name: JUnit Test Report
uses: mikepenz/action-junit-report@v4
with:
report_paths: '**/TEST-*.xml'
check_name: 'hideout-core JUnit Test Report'
- name: Upload Coverage Report
uses: actions/upload-artifact@v4
with:
name: 'hideout-core.xml'
path: 'hideout-core/build/reports/kover/hideout-mastodon.xml'
coverage:
needs:
- change
- hideout-core-unit-test
- hideout-mastodon-unit-test
runs-on: ubuntu-latest
steps:
- name: Download Coverage Report
uses: actions/download-artifact@v4
with:
name: 'hideout-core.xml'
path: 'hideout-core/build/reports/kover/'
- name: Report Coverage
uses: madrapps/jacoco-report@v1.7.0
with:
paths: |
${{ github.workspace }}/hideout-core/build/reports/kover/hideout-core.xml
${{ github.workspace }}/hideout-core/build/reports/kover/**.xml
token: ${{ secrets.GITHUB_TOKEN }}
title: Code Coverage
update-comment: true
@ -143,6 +212,7 @@ jobs:
needs:
- change
- hideout-core-setup
- hideout-mastodon-setup
runs-on: ubuntu-latest
permissions:
contents: write

View File

@ -1,3 +1,4 @@
import kotlinx.kover.gradle.plugin.dsl.CoverageUnit
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask
plugins {
@ -6,6 +7,7 @@ plugins {
alias(libs.plugins.spring.boot)
alias(libs.plugins.kotlin.spring)
alias(libs.plugins.detekt)
alias(libs.plugins.kover)
}
@ -131,6 +133,52 @@ configurations.matching { it.name == "detekt" }.all {
}
}
project.gradle.taskGraph.whenReady {
if (this.hasTask(":koverGenerateArtifact")) {
val task = this.allTasks.find { it.name == "test" }
val verificationTask = task as VerificationTask
verificationTask.ignoreFailures = true
}
}
kover {
currentProject {
sources {
}
}
reports {
verify {
rule {
bound {
minValue = 50
coverageUnits = CoverageUnit.INSTRUCTION
}
}
}
total {
xml {
xmlFile = file("$buildDir/reports/kover/hideout-core.xml")
}
}
filters {
excludes {
annotatedBy("org.springframework.context.annotation.Configuration")
annotatedBy("org.springframework.boot.context.properties.ConfigurationProperties")
packages(
"dev.usbharu.hideout.controller.mastodon.generated",
"dev.usbharu.hideout.domain.mastodon.model.generated"
)
packages("org.springframework")
packages("org.jetbrains")
}
}
}
}
tasks.withType<io.gitlab.arturbosch.detekt.Detekt> {
exclude("**/generated/**")
doFirst {