Skip to content

Commit

Permalink
Merge pull request #12 from spetrov/jacoco
Browse files Browse the repository at this point in the history
Jacoco test coverage reports
  • Loading branch information
spetrov authored May 3, 2024
2 parents 5a81c56 + 5b46e41 commit fdafb36
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 4 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ jobs:

# Execute forgerock-core debug unit tests
- name: Run forgerock-core debug unit tests
run: ./gradlew :forgerock-core:testDebugUnitTest --stacktrace --no-daemon
run: ./gradlew :forgerock-core:jacocoReport --stacktrace --no-daemon

# Execute forgerock-auth debug unit tests
- name: Run forgerock-auth debug unit tests
run: ./gradlew :forgerock-auth:testDebugUnitTest --stacktrace --no-daemon
run: ./gradlew :forgerock-auth:jacocoReport --stacktrace --no-daemon

# Execute forgerock-authenticator debug unit tests
- name: Run forgerock-authenticator debug unit tests
run: ./gradlew :forgerock-authenticator:testDebugUnitTest --stacktrace --no-daemon
run: ./gradlew :forgerock-authenticator:jacocoReport --stacktrace --no-daemon

# Execute forgerock-authenticator debug unit tests
- name: Run ping-protect debug unit tests
run: ./gradlew :ping-protect:testDebugUnitTest --stacktrace --no-daemon
run: ./gradlew :ping-protect:jacocoReport --stacktrace --no-daemon

# Publish test reports for the unit tests
- name: Publish test results
Expand All @@ -59,6 +59,11 @@ jobs:
fail-on-error: 'true'
reporter: java-junit

- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}

# Send slack notification with result status
- uses: 8398a7/action-slack@v3
with:
Expand Down
30 changes: 30 additions & 0 deletions config/jacoco.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apply plugin: 'jacoco'

jacoco {
toolVersion = "0.8.12"
}

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'
])
}
1 change: 1 addition & 0 deletions forgerock-auth/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ android {

apply("../config/logger.gradle")
apply("../config/kdoc.gradle")
apply("../config/jacoco.gradle")
apply("../config/publish.gradle")
/**
* Dependencies
Expand Down
1 change: 1 addition & 0 deletions forgerock-authenticator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ tasks {
}
}

apply("../config/jacoco.gradle")
apply("../config/logger.gradle")
apply("../config/publish.gradle")

Expand Down
1 change: 1 addition & 0 deletions forgerock-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ android {

apply("../config/logger.gradle")
apply("../config/kdoc.gradle")
apply("../config/jacoco.gradle")
apply("../config/publish.gradle")

val delombok by configurations.creating {
Expand Down
1 change: 1 addition & 0 deletions ping-protect/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ tasks {
}
}

apply("../config/jacoco.gradle")
apply("../config/logger.gradle")
apply("../config/publish.gradle")

Expand Down

0 comments on commit fdafb36

Please sign in to comment.