diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml
index 575ca5f2..c7a00988 100644
--- a/.github/workflows/run-test.yml
+++ b/.github/workflows/run-test.yml
@@ -87,6 +87,8 @@ jobs:
android-tests:
name: Run UI tests on Firebase Test Lab
runs-on: ubuntu-20.04
+ permissions:
+ pull-requests: write
steps:
- name: Checkout
@@ -143,13 +145,16 @@ jobs:
--timeout="20m" \
--results-dir="${{ steps.generate-dir.outputs.results_dir }}" \
--results-bucket="${{ steps.generate-dir.outputs.bucket }}" \
- --environment-variables "clearPackageData=true,coverage=true,coverageFilePath=/sdcard/Download/"
+ --environment-variables "clearPackageData=true,coverage=true,coverageFilePath=/sdcard/Download/" \
+ --directories-to-pull /sdcard/Download
- name: Download test results from Firebase Test Lab
if: always()
run: |-
mkdir "app/build/test-results"
+ mkdir "app/build/test-results/instrumentation_results"
gsutil cp -r "gs://${{ steps.generate-dir.outputs.bucket }}/${{ steps.generate-dir.outputs.results_dir }}/Pixel2.arm-33-en-portrait/test_result_1.xml" "app/build/test-results/results.xml"
+ gsutil cp -r "gs://${{ steps.generate-dir.outputs.bucket }}/${{ steps.generate-dir.outputs.results_dir }}/Pixel2.arm-33-en-portrait/artifacts/sdcard/Download/*.ec" "app/build/test-results/instrumentation_results"
- name: Upload tests results
if: always()
@@ -160,6 +165,31 @@ jobs:
*/build/test-results/**
retention-days: 5
+ - name: Run instrumentation code coverage
+ run: ./gradlew instrumentationCodeCoverage
+ 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/instrumentationCodeCoverage/html/**
+
+ - name: Add coverage to PR
+ if: ${{ github.event_name != 'schedule' }}
+ id: jacoco
+ uses: madrapps/jacoco-report@v1.6.1
+ with:
+ paths: |
+ */build/reports/jacoco/instrumentationCodeCoverage/instrumentationCodeCoverage.xml
+ token: ${{ secrets.GITHUB_TOKEN }}
+
test-license-headers:
name: Ensure license headers are added
runs-on: ubuntu-20.04
diff --git a/app/build.gradle b/app/build.gradle
index 97ab3dd8..c918a000 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -33,7 +33,7 @@ android {
versionName "1.0"
testInstrumentationRunner "com.appunite.loudius.util.InstrumentationTestRunner"
- testInstrumentationRunnerArguments clearPackageData: 'true'
+ testInstrumentationRunnerArguments clearPackageData: 'true', coverage: 'true', coverageFilePath: '/sdcard/Download/'
vectorDrawables {
useSupportLibrary true
}
@@ -54,6 +54,7 @@ android {
}
debug{
enableUnitTestCoverage true
+ testCoverageEnabled true
}
}
compileOptions {
@@ -145,6 +146,44 @@ tasks.register('codeCoverage', JacocoReport) {
}
+tasks.register('instrumentationCodeCoverage', JacocoReport) {
+
+ reports {
+ html.required.set(true)
+ xml.required.set(true)
+ }
+
+ classDirectories.setFrom(
+ fileTree(project.buildDir) {
+ include("**/tmp/kotlin-classes/debug/**")
+ exclude(
+ '**/R.class',
+ '**/R$*.class',
+ '**/BuildConfig.*',
+ "**/*Application.*",
+ '**/Manifest*.*',
+ '**/*Test*.*',
+ '**/android/**/*.*',
+ '**/androidx/**/*.*',
+ '**/airbnb/**/*.*',
+ "**/di/**/*.*",
+ '**/*Dagger*.*',
+ "**/*Screen*"
+ )
+ }
+ )
+
+ sourceDirectories.setFrom(fileTree(
+ dir: project.projectDir,
+ includes: [
+ "src/main/java/**",
+ "src/main/kotlin/**"
+ ]))
+
+ executionData.setFrom(
+ fileTree(dir: "${buildDir}/test-results/instrumentation_results", includes: ['*.ec']))
+}
+
dependencies {
api project(':components')
diff --git a/components/README.md b/components/README.md
index 4eb383eb..8d5203f2 100644
--- a/components/README.md
+++ b/components/README.md
@@ -60,4 +60,4 @@ Topbar is a component on the top of the screen.
| Variant | Snapshot |
|--------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **Topbar with back navigation**
[Source Code](../components/src/main/java/com/appunite/loudius/components/components/LoudiusTopAppBar.kt#L61-L70) | |
-| **Topbar with no navigation**
[Source Code](../components/src/main/java/com/appunite/loudius/components/components/LoudiusTopAppBar.kt#L72-L80) | |
\ No newline at end of file
+| **Topbar with no navigation**
[Source Code](../components/src/main/java/com/appunite/loudius/components/components/LoudiusTopAppBar.kt#L72-L80) | |