Skip to content

Commit

Permalink
Merge pull request #201 from appunite/feature/merge_coverage
Browse files Browse the repository at this point in the history
[LD-147] Add merged code coverage.
  • Loading branch information
nowakweronika authored Jan 30, 2024
2 parents dab6a2c + 583ad2d commit 82ddaf3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 78 deletions.
56 changes: 29 additions & 27 deletions .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,14 @@ jobs:
uses: ./.github/actions/prepare-android-env

- name: Run test
run: ./gradlew codeCoverage
run: ./gradlew testDebugUnitTest
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
if: ${{ github.event_name != 'schedule' }}
id: jacoco
uses: madrapps/[email protected]
with:
paths: |
*/build/reports/jacoco/codeCoverage/codeCoverage.xml
token: ${{ secrets.GITHUB_TOKEN }}

- name: Upload tests results
if: always()
uses: actions/upload-artifact@v3
Expand All @@ -82,6 +66,8 @@ jobs:
path: |
*/build/test-results/**
*/build/paparazzi/failures/**
*/build/outputs/**
*/build/tmp/kotlin-classes/**
retention-days: 5

android-tests:
Expand Down Expand Up @@ -165,29 +151,45 @@ 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 }}
code-coverage:
name: Merged code coverage
runs-on: ubuntu-20.04
permissions:
pull-requests: write
needs:
- android-tests
- unit-tests

steps:

- name: Checkout
uses: actions/checkout@v4

- name: Prepare Android Environment
uses: ./.github/actions/prepare-android-env

- name: Download tests results for both jobs
uses: actions/download-artifact@v3
with:
name: test-results

- name: Run code coverage
run: ./gradlew codeCoverage

- name: Store HTML coverage report
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: |
*/build/reports/jacoco/instrumentationCodeCoverage/html/**
app/build/reports/jacoco/codeCoverage
- name: Add coverage to PR
if: ${{ github.event_name != 'schedule' }}
id: jacoco
uses: madrapps/[email protected]
with:
paths: |
*/build/reports/jacoco/instrumentationCodeCoverage/instrumentationCodeCoverage.xml
app/build/reports/jacoco/codeCoverage/codeCoverage.xml
token: ${{ secrets.GITHUB_TOKEN }}

test-license-headers:
Expand Down
57 changes: 6 additions & 51 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ android {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug{
debug {
enableUnitTestCoverage true
testCoverageEnabled true
}
Expand Down Expand Up @@ -103,7 +103,6 @@ android {
}

tasks.register('codeCoverage', JacocoReport) {
dependsOn 'testDebugUnitTest'

reports {
html.required.set(true)
Expand All @@ -130,58 +129,14 @@ tasks.register('codeCoverage', JacocoReport) {
}
)

sourceDirectories.setFrom(fileTree(
dir: project.projectDir,
includes: [
"src/main/java/**",
"src/main/kotlin/**"
]))

executionData.setFrom(fileTree(
dir: project.buildDir,
includes: [
"**/*.exec",
"**/*.ec"
]))

}

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/**"])
)

sourceDirectories.setFrom(fileTree(
dir: project.projectDir,
includes: [
"src/main/java/**",
"src/main/kotlin/**"
]))

executionData.setFrom(
fileTree(dir: "${buildDir}/test-results/instrumentation_results", includes: ['*.ec']))
fileTree(dir: "${buildDir}/test-results/instrumentation_results", includes: ['*.ec']),
fileTree(dir: "${buildDir}/outputs/unit_test_code_coverage", includes: ["**/*.exec", "**/*.ec"])
)
}

dependencies {
Expand Down

0 comments on commit 82ddaf3

Please sign in to comment.