Skip to content

Commit

Permalink
coverage report
Browse files Browse the repository at this point in the history
  • Loading branch information
lordrio committed Dec 17, 2024
1 parent 3bdf27c commit 383448e
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/sdk_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ jobs:
echo "Free space:"
df -h
- name: Run Coverage
run: ./gradlew :xendit-android:jacocoReport

- name: Grant execute permission for gradlew
run: chmod +x gradlew

Expand All @@ -72,6 +75,16 @@ jobs:
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: ./gradlew :xendit-android:connectedCheck --stacktrace

- name: Add coverage to PR
id: jacoco
uses: madrapps/[email protected]
with:
paths: |
${{ github.workspace }}/**/build/reports/coverage/androidTest/debug/connected/report.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 40
min-coverage-changed-files: 60

# notify-slack:
# needs: unit-test
# runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ buildscript {
classpath 'com.android.tools.build:gradle:8.2.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0'
//Jacoco Plugin
classpath "org.jacoco:org.jacoco.core:0.8.10"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
26 changes: 26 additions & 0 deletions jacoco.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apply plugin: 'jacoco'

task jacocoReport(type: JacocoReport, dependsOn: 'testDebugUnitTest') {
reports {
csv { enabled false } // change if needed
xml { enabled true } // change if needed
html {
enabled true
destination file("${buildDir}/coverage-report")
}
}

// Setup the .class, source, and execution directories
final fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', 'android/**/*.*']

// Include this if you use Kotlin
final kotlinTree = fileTree(dir: "${project.buildDir}/tmp/kotlin-classes/debug", excludes: fileFilter)
final javacTree = fileTree(dir: "${project.buildDir}/intermediates/javac/debug", excludes: fileFilter)
final mainSrc = "${project.projectDir}/src/main/java"

sourceDirectories.setFrom files([mainSrc])
classDirectories.setFrom files([kotlinTree, javacTree])
executionData.setFrom fileTree(dir: project.buildDir, includes: [
'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec'
])
}
4 changes: 4 additions & 0 deletions xendit-android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'jacoco'
apply from: "$project.rootDir/jacoco.gradle"

group 'com.xendit'
version '4.2.2'
Expand Down Expand Up @@ -49,6 +51,8 @@ android {
}
debug {
minifyEnabled false
enableUnitTestCoverage true
testCoverageEnabled true
consumerProguardFiles 'proguard-rules.pro'
buildConfigField('long', 'VERSION_CODE', "${defaultConfig.versionCode}")
buildConfigField('String','VERSION_NAME', "\"${defaultConfig.versionName}\"")
Expand Down

0 comments on commit 383448e

Please sign in to comment.