From 5456413e42c5c5aa6d02ef23e4fd208c58949f67 Mon Sep 17 00:00:00 2001 From: usbharu Date: Mon, 16 Sep 2024 23:39:12 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20mastodon=E3=81=A7=E3=82=82=E3=82=AB?= =?UTF-8?q?=E3=83=90=E3=83=AC=E3=83=83=E3=82=B8=E7=8E=87=E3=82=92=E8=A8=88?= =?UTF-8?q?=E6=B8=AC=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/pull-request-merge-check.yml | 76 ++++++++++++++++++- hideout-mastodon/build.gradle.kts | 48 ++++++++++++ 2 files changed, 121 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull-request-merge-check.yml b/.github/workflows/pull-request-merge-check.yml index f751ea1c..701df932 100644 --- a/.github/workflows/pull-request-merge-check.yml +++ b/.github/workflows/pull-request-merge-check.yml @@ -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 diff --git a/hideout-mastodon/build.gradle.kts b/hideout-mastodon/build.gradle.kts index 12ad6ee8..38cd2c58 100644 --- a/hideout-mastodon/build.gradle.kts +++ b/hideout-mastodon/build.gradle.kts @@ -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 { exclude("**/generated/**") doFirst {