Skip to content

Commit

Permalink
feat: add coverage checks with min 80% threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
ttypic committed Nov 28, 2024
1 parent d178c6e commit eea472a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
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
41 changes: 41 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Coverage

on:
push:
branches:
- main
pull_request:

jobs:
coverage:
runs-on: ubuntu-latest

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/gradle-build-action@v2

- name: Run tests and generate coverage report
run: ./gradlew koverXmlReport

- name: Extract coverage from XML
run: |
COVERAGE=$(grep -oP 'line-rate="([0-9.]+)"' build/reports/kover/report.xml | head -1 | grep -oP '[0-9.]+')
echo "Coverage: ${COVERAGE}"
echo "coverage=${COVERAGE}" >> $GITHUB_ENV
- name: Fail if coverage is too low
run: |
MIN_COVERAGE=0.80
if (( $(echo "$COVERAGE < $MIN_COVERAGE" | bc -l) )); then
echo "Coverage ($COVERAGE) is below the minimum threshold ($MIN_COVERAGE)."
exit 1
fi
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" }

0 comments on commit eea472a

Please sign in to comment.