From 8c003f5c32383d513b6c1e9c634ced05d75a0eab Mon Sep 17 00:00:00 2001 From: Albin Date: Wed, 13 Sep 2023 22:40:40 +0200 Subject: [PATCH 1/6] Add konsist in dependency and version files --- android/buildSrc/src/main/kotlin/Dependencies.kt | 3 ++- android/buildSrc/src/main/kotlin/Versions.kt | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/android/buildSrc/src/main/kotlin/Dependencies.kt b/android/buildSrc/src/main/kotlin/Dependencies.kt index 2aa2db27d61e..80c33136835d 100644 --- a/android/buildSrc/src/main/kotlin/Dependencies.kt +++ b/android/buildSrc/src/main/kotlin/Dependencies.kt @@ -4,9 +4,10 @@ object Dependencies { const val commonsValidator = "commons-validator:commons-validator:${Versions.commonsValidator}" const val jodaTime = "joda-time:joda-time:${Versions.jodaTime}" const val junit = "junit:junit:${Versions.junit}" + const val konsist = "com.lemonappdev:konsist:${Versions.konsist}" const val leakCanary = "com.squareup.leakcanary:leakcanary-android:${Versions.leakCanary}" - const val turbine = "app.cash.turbine:turbine:${Versions.turbine}" const val mockkWebserver = "com.squareup.okhttp3:mockwebserver:${Versions.mockWebserver}" + const val turbine = "app.cash.turbine:turbine:${Versions.turbine}" object AndroidX { const val appcompat = "androidx.appcompat:appcompat:${Versions.AndroidX.appcompat}" diff --git a/android/buildSrc/src/main/kotlin/Versions.kt b/android/buildSrc/src/main/kotlin/Versions.kt index d10c7e252bab..553c952748e1 100644 --- a/android/buildSrc/src/main/kotlin/Versions.kt +++ b/android/buildSrc/src/main/kotlin/Versions.kt @@ -3,6 +3,7 @@ object Versions { const val jodaTime = "2.12.5" const val junit = "4.13.2" const val jvmTarget = "17" + const val konsist = "0.11.0" const val kotlin = "1.9.10" const val kotlinCompilerExtensionVersion = "1.5.3" const val kotlinx = "1.7.3" From 3505d6f92812639e688846cbb349f165bd2fab9f Mon Sep 17 00:00:00 2001 From: Albin Date: Wed, 13 Sep 2023 22:43:33 +0200 Subject: [PATCH 2/6] Add empty arch test module --- android/settings.gradle.kts | 16 +++++-- android/test/arch/build.gradle.kts | 42 +++++++++++++++++++ .../test/arch/src/test/AndroidManifest.xml | 1 + 3 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 android/test/arch/build.gradle.kts create mode 100644 android/test/arch/src/test/AndroidManifest.xml diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts index 5df9c08f1e07..e47f3c08f950 100644 --- a/android/settings.gradle.kts +++ b/android/settings.gradle.kts @@ -1,5 +1,8 @@ -include(":app", ":service", ":tile") - +include( + ":app", + ":service", + ":tile" +) include( ":lib:common", ":lib:endpoint", @@ -10,5 +13,10 @@ include( ":lib:theme", ":lib:common-test" ) - -include(":test", ":test:common", ":test:e2e", ":test:mockapi") +include( + ":test", + ":test:arch", + ":test:common", + ":test:e2e", + ":test:mockapi" +) diff --git a/android/test/arch/build.gradle.kts b/android/test/arch/build.gradle.kts new file mode 100644 index 000000000000..0a28fd2fab3c --- /dev/null +++ b/android/test/arch/build.gradle.kts @@ -0,0 +1,42 @@ +plugins { + id(Dependencies.Plugin.androidLibraryId) + id(Dependencies.Plugin.kotlinAndroidId) +} + +android { + namespace = "net.mullvad.mullvadvpn.test.arch" + compileSdk = Versions.Android.compileSdkVersion + + defaultConfig { + minSdk = Versions.Android.minSdkVersion + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + kotlinOptions { + jvmTarget = Versions.jvmTarget + } + + lint { + lintConfig = file("${rootProject.projectDir}/config/lint.xml") + abortOnError = true + warningsAsErrors = true + } +} + +androidComponents { + beforeVariants { variantBuilder -> + variantBuilder.apply { + enable = name != "release" + } + } +} + +dependencies { + testImplementation(Dependencies.AndroidX.appcompat) + testImplementation(Dependencies.junit) + testImplementation(Dependencies.konsist) +} diff --git a/android/test/arch/src/test/AndroidManifest.xml b/android/test/arch/src/test/AndroidManifest.xml new file mode 100644 index 000000000000..cc947c567995 --- /dev/null +++ b/android/test/arch/src/test/AndroidManifest.xml @@ -0,0 +1 @@ + From f7b473903419046bfa413075d3376f4784d02a62 Mon Sep 17 00:00:00 2001 From: Albin Date: Wed, 13 Sep 2023 22:43:56 +0200 Subject: [PATCH 3/6] Add simple view model suffix assertion --- .../mullvadvpn/test/arch/ViewModelTests.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/ViewModelTests.kt diff --git a/android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/ViewModelTests.kt b/android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/ViewModelTests.kt new file mode 100644 index 000000000000..35ffe52c312d --- /dev/null +++ b/android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/ViewModelTests.kt @@ -0,0 +1,16 @@ +package net.mullvad.mullvadvpn.test.arch + +import androidx.lifecycle.ViewModel +import com.lemonappdev.konsist.api.Konsist +import com.lemonappdev.konsist.api.ext.list.withAllParentsOf +import com.lemonappdev.konsist.api.verify.assert +import org.junit.Test + +class ViewModelTests { + @Test + fun ensureViewModelsHaveViewModelSuffix() { + Konsist.scopeFromProject().classes().withAllParentsOf(ViewModel::class).assert { + it.name.endsWith("ViewModel") + } + } +} From accd04f1eabf1faa4e312d8437561ca5c555e4d8 Mon Sep 17 00:00:00 2001 From: Albin Date: Wed, 13 Sep 2023 22:45:08 +0200 Subject: [PATCH 4/6] Update gradle lockfile --- android/gradle/verification-metadata.xml | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/android/gradle/verification-metadata.xml b/android/gradle/verification-metadata.xml index 98f3a9dd9452..6aca8d73fad0 100644 --- a/android/gradle/verification-metadata.xml +++ b/android/gradle/verification-metadata.xml @@ -2222,6 +2222,14 @@ + + + + + + + + @@ -3178,6 +3186,11 @@ + + + + + @@ -3451,6 +3464,11 @@ + + + + + @@ -3476,6 +3494,11 @@ + + + + + @@ -3491,6 +3514,11 @@ + + + + + @@ -3516,6 +3544,11 @@ + + + + + @@ -3671,6 +3704,11 @@ + + + + + From e48ab229272964d59c6eb5ba3bb6c1dca6c5794b Mon Sep 17 00:00:00 2001 From: Albin Date: Wed, 13 Sep 2023 22:54:22 +0200 Subject: [PATCH 5/6] Run arch check in actions --- .github/workflows/android-app.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/android-app.yml b/.github/workflows/android-app.yml index f6d56f318b37..1608bff1302b 100644 --- a/.github/workflows/android-app.yml +++ b/.github/workflows/android-app.yml @@ -201,7 +201,16 @@ jobs: uses: burrunan/gradle-cache-action@v1 with: job-id: jdk17 - arguments: testDebugUnitTest + arguments: testDebugUnitTest -x :test:arch:testDebugUnitTest + gradle-version: wrapper + build-root-directory: android + execution-only-caches: true + + - name: Run arch tests + uses: burrunan/gradle-cache-action@v1 + with: + job-id: jdk17 + arguments: :test:arch:test gradle-version: wrapper build-root-directory: android execution-only-caches: true From bc4440546d6581a41db84064beb7920325a6d984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20G=C3=B6ransson?= Date: Fri, 29 Sep 2023 10:07:18 +0200 Subject: [PATCH 6/6] Remove jetifier --- android/gradle.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/android/gradle.properties b/android/gradle.properties index 3f3bea5a6633..4233d36b8265 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,4 +1,3 @@ -android.enableJetifier=true android.enableR8.fullMode=true android.defaults.buildfeatures.buildconfig=true android.nonTransitiveRClass=false