From ce3a3ea16c2e73b1a9f41b9fb034a2649bcdd6df Mon Sep 17 00:00:00 2001 From: Fidel Montesino Date: Thu, 2 Jul 2020 17:57:48 +0100 Subject: [PATCH] [Chore] Setup JaCoCo (#8) * Setup jacoco and Codecov on github actions * Update readme to reflect the latest changes * Add codecov.yaml * EOFNL * Add missing jacoco Hilt rule --- .github/workflows/android.yml | 9 ++++++++- README.md | 22 ++++++++++++++++++---- app/build.gradle | 2 ++ build.gradle | 1 + buildSrc/src/main/kotlin/Libs.kt | 7 +++++++ buildSrc/src/main/kotlin/Versions.kt | 2 ++ codecov.yaml | 14 ++++++++++++++ jacoco.gradle | 23 +++++++++++++++++++++++ 8 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 codecov.yaml create mode 100644 jacoco.gradle diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 1c67c3b..c2b23f1 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -21,4 +21,11 @@ jobs: java-version: 1.8 - name: Run Unit Tests - run: ./gradlew testDebugUnitTest + run: ./gradlew jacocoTestReportDebug + + - name: Upload Report to Codecov + uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ./app/build/reports/jacoco/debug/jacoco.xml + flags: unittests diff --git a/README.md b/README.md index 9b5a09d..5464ec7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ -![PR Check](https://github.com/theappbusiness/android-proxy-toggle/workflows/PR%20Check/badge.svg?branch=main) -[![API](https://img.shields.io/badge/API-21%2B-blue.svg?style=flat)](https://android-arsenal.com/api?level=21) +![Build Check](https://img.shields.io/github/workflow/status/theappbusiness/android-proxy-toggle/PR%20Check/main) +![Codecov report](https://img.shields.io/codecov/c/github/theappbusiness/android-proxy-toggle/main) +[![Android API](https://img.shields.io/badge/API-21%2B-blue)](https://android-arsenal.com/api?level=21) +![License](https://img.shields.io/github/license/theappbusiness/android-proxy-toggle) # Proxy Toggle @@ -23,8 +25,9 @@ This app supports Android 5.0 and above. ### Architecture -The project is split in different feature modules that provide an encapsulated piece of work. -The app follows MVVM Clean Architecture. +Due to the simplicity of the app, the project has a single `app` module and the different features can be found under the `feature` package. + +The app follows MVVM Clean Architecture principles. ### Dependency Injection @@ -35,6 +38,7 @@ Each ViewModel must be injected using `@ViewModelInject` in order to be provided ### Testing We use Github Actions to execute all Unit Tests in the project for every PR against the `main` branch. +JaCoCo is setup to run test coverage. ### Features @@ -51,6 +55,16 @@ In order to gran these permissions, every time you install the application, conn adb shell pm grant com.kinandcarta.create.proxytoggle android.permission.WRITE_SECURE_SETTINGS ``` +#### Home Screen Widget + +The app features a Home Screen widget that the user can use to quickly toggle the proxy with the last used setup, without having to even open the app. +It will also allow the user to launch the app to configure the proxy settings, if needed. + +#### Quick Setting Tile + +Similarly to the widget, Android 7.0 and above users will have the option to add a Quick Settings Tile in their Notification Drawer. +This tile will allow the users to toggle the proxy even without having to leave the current application they are using. + ## License Proxy Toggle is available under the MIT license. See the [LICENSE](LICENSE.md) file for more info. diff --git a/app/build.gradle b/app/build.gradle index 557c71d..9ae4d94 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,6 +6,8 @@ plugins { id 'dagger.hilt.android.plugin' } +apply from: rootProject.file("jacoco.gradle") + android { compileSdkVersion 29 buildToolsVersion "30.0.0" diff --git a/build.gradle b/build.gradle index aaa0517..dd91084 100644 --- a/build.gradle +++ b/build.gradle @@ -13,6 +13,7 @@ buildscript { classpath Libs.de_fayard_buildsrcversions_gradle_plugin classpath Libs.detekt_gradle_plugin classpath Libs.hilt_android_gradle_plugin + classpath Libs.gradle_android_junit_jacoco_plugin } } diff --git a/buildSrc/src/main/kotlin/Libs.kt b/buildSrc/src/main/kotlin/Libs.kt index c7c7253..28edb8a 100644 --- a/buildSrc/src/main/kotlin/Libs.kt +++ b/buildSrc/src/main/kotlin/Libs.kt @@ -102,6 +102,13 @@ object Libs { "de.fayard.buildSrcVersions:de.fayard.buildSrcVersions.gradle.plugin:" + Versions.de_fayard_buildsrcversions_gradle_plugin + /** + * http://github.com/vanniktech/gradle-android-junit-jacoco-plugin/ + */ + const val gradle_android_junit_jacoco_plugin: String = + "com.vanniktech:gradle-android-junit-jacoco-plugin:" + + Versions.gradle_android_junit_jacoco_plugin + /** * http://tools.android.com */ diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index d6cadfa..f1a1c9c 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -32,6 +32,8 @@ object Versions { const val de_fayard_buildsrcversions_gradle_plugin: String = "0.7.0" + const val gradle_android_junit_jacoco_plugin: String = "0.16.0" + const val constraintlayout: String = "1.1.3" const val espresso_core: String = "3.2.0" diff --git a/codecov.yaml b/codecov.yaml new file mode 100644 index 0000000..694170f --- /dev/null +++ b/codecov.yaml @@ -0,0 +1,14 @@ +coverage: + status: + project: + default: + target: auto + threshold: 0% + base: auto + patch: off + +comment: + layout: "diff, files" + require_changes: false + require_base: no + require_head: no diff --git a/jacoco.gradle b/jacoco.gradle new file mode 100644 index 0000000..fdfea70 --- /dev/null +++ b/jacoco.gradle @@ -0,0 +1,23 @@ +apply plugin: "com.vanniktech.android.junit.jacoco" + +junitJacoco { + jacocoVersion = '0.8.5' + excludes = [ + // Android + "**/*BuildConfig*", + // Hilt files + "**/*_Hilt*", + "**/*Hilt_*", + "**/*ModuleDeps*", + "**/*_Factory*", + "**/*_AssistedFactory*", + "**/*_MembersInjector*", + // ViewBinding + "**/databinding/*.*", + // Custom + "**/injection/*.*", + "**/extensions/*.*" + ] + includeNoLocationClasses = true + includeInstrumentationCoverageInMergedReport = false +}