-
Notifications
You must be signed in to change notification settings - Fork 1
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
[LD-139] chore: test coverage report #162
Changes from 8 commits
cc1a50f
1a2db58
3506171
a6f123a
88b733d
9c8baa7
bf84b88
13f4e3f
fc7dca8
5060651
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,8 @@ jobs: | |
unit-tests: | ||
name: Unit Tests | ||
runs-on: ubuntu-20.04 | ||
permissions: | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Checkout | ||
|
@@ -36,14 +38,30 @@ jobs: | |
uses: ./.github/actions/prepare-android-env | ||
|
||
- name: Run test | ||
run: ./gradlew test | ||
run: ./gradlew codeCoverage | ||
env: | ||
LOUDIUS_CLIENT_SECRET: ${{ secrets.LOUDIUS_CLIENT_SECRET }} | ||
LOUDIUS_CLIENT_ID: ${{ secrets.LOUDIUS_CLIENT_ID }} | ||
LOUDIUS_GITHUB_USER_PASSWORD: ${{ secrets.LOUDIUS_GITHUB_USER_PASSWORD }} | ||
LOUDIUS_GITHUB_USER_NAME: ${{ secrets.LOUDIUS_GITHUB_USER_NAME }} | ||
LOUDIUS_GITHUB_USER_OTP_SECRET: ${{ secrets.LOUDIUS_GITHUB_USER_OTP_SECRET }} | ||
|
||
- name: Store HTML coverage report | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: coverage-report | ||
path: | | ||
*/build/reports/jacoco/codeCoverage/html/** | ||
|
||
- name: Add coverage to PR | ||
id: jacoco | ||
uses: madrapps/[email protected] | ||
with: | ||
paths: | | ||
*/build/reports/jacoco/codeCoverage/codeCoverage.xml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here we pass the path to the codeCoverage report in xml format to the action |
||
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: why we have here: |
||
debug-mode: true | ||
|
||
- name: Upload tests results | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ plugins { | |
id 'com.android.application' | ||
id 'kotlin-kapt' | ||
id 'org.jetbrains.kotlin.android' | ||
id 'jacoco' | ||
id 'org.jlleitschuh.gradle.ktlint' version '11.6.1' | ||
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.0' | ||
} | ||
|
@@ -43,6 +44,9 @@ android { | |
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
debug{ | ||
enableUnitTestCoverage true | ||
} | ||
} | ||
compileOptions { | ||
coreLibraryDesugaringEnabled true | ||
|
@@ -88,6 +92,50 @@ android { | |
} | ||
} | ||
|
||
tasks.register('codeCoverage', JacocoReport) { | ||
dependsOn 'testDebugUnitTest' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dependsOn means that it will execute testDebugUnitTest when triggering codeCoverage and then all that is defined here |
||
|
||
reports { | ||
html.required.set(true) | ||
xml.required.set(true) | ||
} | ||
|
||
classDirectories.setFrom( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. : The compiled class files without instrumentation. Execution data references instructions in these classes, so they're necessary for locating the actual instructions. |
||
fileTree(project.buildDir) { | ||
include("**/tmp/kotlin-classes/debug/**") | ||
exclude( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can exclude some classes so that we they are not included in the code coverage report |
||
'**/R.class', | ||
'**/R$*.class', | ||
'**/BuildConfig.*', | ||
"**/*Application.*", | ||
'**/Manifest*.*', | ||
'**/*Test*.*', | ||
'**/android/**/*.*', | ||
'**/androidx/**/*.*', | ||
'**/airbnb/**/*.*', | ||
"**/di/**/*.*", | ||
'**/*Dagger*.*', | ||
"**/*Screen*" | ||
) | ||
} | ||
) | ||
|
||
sourceDirectories.setFrom(fileTree( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the location of the original source code files. Optional, but allows the reporter to map bytecode instructions back to the original sources in order to include them into the report with coverage annotations. |
||
dir: project.projectDir, | ||
includes: [ | ||
"src/main/java/**", | ||
"src/main/kotlin/**" | ||
])) | ||
|
||
executionData.setFrom(fileTree( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The location of "execution data", i.e. the coverage data collected by the unit test runner when running the tests against classes instrumented by the JaCoCo agent. |
||
dir: project.buildDir, | ||
includes: [ | ||
"**/*.exec", | ||
"**/*.ec" | ||
])) | ||
|
||
} | ||
|
||
dependencies { | ||
api project(':components') | ||
//Desugaring for use of java.time in api lower then 26 | ||
|
@@ -141,11 +189,12 @@ dependencies { | |
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.1") | ||
testImplementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.1") | ||
|
||
|
||
//retrofit & okhttp | ||
implementation 'com.squareup.okhttp3:okhttp:4.11.0' | ||
implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0' | ||
|
||
|
||
|
||
testImplementation project(":app-shared-tests") | ||
androidTestImplementation(project(":app-shared-tests")) { | ||
exclude group: 'org.robolectric', module: 'robolectric' | ||
|
@@ -164,4 +213,4 @@ tasks.withType(Test) { | |
|
||
kapt { | ||
correctErrorTypes true | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Why is this removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is replaced by a task that I created codeCoverage