Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add coverage checks with min 80% threshold #70

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ jobs:
distribution: 'temurin'
java-version: '17'

- name: Set up Gradle
uses: gradle/gradle-build-action@v2

- name: Run Gradle check
run: ./gradlew check
37 changes: 37 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Coverage

on:
pull_request:
push:
branches:
- main

jobs:
coverage:
runs-on: ubuntu-latest
ttypic marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3

- name: Run tests and generate coverage report
run: ./gradlew koverXmlReport
ttypic marked this conversation as resolved.
Show resolved Hide resolved

- name: Add coverage report to PR
id: kover
uses: mi-kas/kover-report@v1
with:
path: |
${{ github.workspace }}/chat-android/build/reports/kover/report.xml
title: Code Coverage
Comment on lines +29 to +34
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve path handling in coverage report step

The current path handling could be more robust:

  1. Use path variables for reusability
  2. Add path existence check
       - name: Add coverage report to PR
         id: kover
         uses: mi-kas/kover-report@v1
+        env:
+          REPORT_PATH: chat-android/build/reports/kover/report.xml
         with:
           path: |
-            ${{ github.workspace }}/chat-android/build/reports/kover/report.xml
+            ${{ github.workspace }}/${{ env.REPORT_PATH }}
+        if: |
+          hashFiles(format('{0}/{1}', github.workspace, env.REPORT_PATH)) != ''

Committable suggestion skipped: line range outside the PR's diff.

update-comment: true
min-coverage-overall: 80
coverage-counter-type: LINE
1 change: 1 addition & 0 deletions chat-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.android.kotlin)
alias(libs.plugins.build.config)
alias(libs.plugins.kover)
}

val version = libs.versions.ably.chat.get()
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ android-library = { id = "com.android.library", version.ref = "agp" }
android-application = { id = "com.android.application", version.ref = "agp" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
build-config = { id = "com.github.gmazzo.buildconfig", version.ref = "build-config" }
kover = { id = "org.jetbrains.kotlinx.kover", version = "0.9.0-RC" }