Skip to content

Commit

Permalink
ci: add jacoco config
Browse files Browse the repository at this point in the history
  • Loading branch information
AkagiYui committed Apr 25, 2024
1 parent 166cdfd commit b48a2dc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
- name: Test with Gradle
run: ./gradlew test --no-daemon --warning-mode all --scan

- name: Test with Gradle
run: ./gradlew jacocoTestReport --no-daemon --warning-mode all --scan

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
Expand All @@ -52,7 +55,7 @@ jobs:
build/test-results
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: AkagiYui/KenkoDrive
15 changes: 15 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
java // Gradle 内置的 Java 插件,提供 Java 项目的构建支持
jacoco // 代码覆盖率
id("org.springframework.boot") version "3.2.4" // Spring Boot
id("io.spring.dependency-management") version "1.1.4" // Spring Boot 相关依赖关系管理
kotlin("jvm") version "1.9.23" // Kotlin 支持
Expand Down Expand Up @@ -112,6 +113,20 @@ dependencies {
testImplementation("com.h2database:h2") // H2 数据库,用于测试
}

// Jacoco 配置
tasks.jacocoTestReport {
reports {
xml.apply { isEnabled = true }
csv.apply { isEnabled = false }
html.apply { isEnabled = true }
}
}

tasks.named("check") {
dependsOn("jacocoTestReport")
}


// gradle test 任务配置
tasks.withType<Test> {
// 设置 Spring Boot 的测试配置文件
Expand Down

0 comments on commit b48a2dc

Please sign in to comment.