Skip to content
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

Add konsist for arch testing #5154

Merged
merged 6 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/android-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion android/buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
1 change: 1 addition & 0 deletions android/buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
android.enableJetifier=true
android.enableR8.fullMode=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
Expand Down
38 changes: 38 additions & 0 deletions android/gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2222,6 +2222,14 @@
<sha256 value="b29c1c21e52ed6238cd3fed39d880a17ecf2360118604548cea8821be6801e1c" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.lemonappdev" name="konsist" version="0.11.0">
<artifact name="konsist-0.11.0.jar">
<sha256 value="6b60badd6cf1d49a7b76fee18fe7265bd96d98fd4b9fe065470a5fdf8dacc7bd" origin="Generated by Gradle"/>
</artifact>
<artifact name="konsist-0.11.0.module">
<sha256 value="243b6b46fbacea79349ea05e5dba20d6ee72103361e74c8d5102270fc956b986" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.linkedin.dexmaker" name="dexmaker" version="2.28.1">
<artifact name="dexmaker-2.28.1.jar">
<sha256 value="824a109b2352138c3699760e1683385d0ed50ce526fc7982f8d65757743374bf" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -3178,6 +3186,11 @@
<sha256 value="2c28fa5d7c47e01c4eace2276e05e8d119a9f0b26cce98720781df36b792c821" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains.kotlin" name="kotlin-compiler" version="1.9.10">
<artifact name="kotlin-compiler-1.9.10.jar">
<sha256 value="a2718d75fb90075fb401d924013453ea97859aec6e189ebb9e6c83c630efe7f7" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains.kotlin" name="kotlin-compiler-embeddable" version="1.8.20">
<artifact name="kotlin-compiler-embeddable-1.8.20.jar">
<sha256 value="5655386be55d45a78d887372bbd59d03e06750f7756108d14139e8d7e4b2e179" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -3451,6 +3464,11 @@
<sha256 value="f78c5d8c09db985912ab83a1de3c3b53ddf208d7b151f06a72358ea3e137d01b" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains.kotlin" name="kotlin-stdlib" version="1.7.10">
<artifact name="kotlin-stdlib-1.7.10.jar">
<sha256 value="e771fe74250a943e8f6346713201ff1d8cb95c3a5d1a91a22b65a9e04f6a8901" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains.kotlin" name="kotlin-stdlib" version="1.8.20">
<artifact name="kotlin-stdlib-1.8.20.jar">
<sha256 value="4395647b1961d9fb730a34e8dbe56c293157bc0759004cca63d9b5ee6653e5c7" origin="Generated by Gradle"/>
Expand All @@ -3476,6 +3494,11 @@
<sha256 value="812cf197d9c4c67e1f47f95e2d72a9b600f0d1124560617bfe9850773eccbcff" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains.kotlin" name="kotlin-stdlib-common" version="1.7.10">
<artifact name="kotlin-stdlib-common-1.7.10.jar">
<sha256 value="19f102efe9629f8eabc63853ad15c533e47c47f91fca09285c5bde86e59f91d4" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains.kotlin" name="kotlin-stdlib-common" version="1.8.20">
<artifact name="kotlin-stdlib-common-1.8.20.jar">
<sha256 value="fa20188abaa8ecf1d0035e93a969b071f10e45a1c8378c314521eade73f75fd5" origin="Generated by Gradle"/>
Expand All @@ -3491,6 +3514,11 @@
<sha256 value="cde3341ba18a2ba262b0b7cf6c55b20c90e8d434e42c9a13e6a3f770db965a88" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains.kotlin" name="kotlin-stdlib-jdk7" version="1.6.0">
<artifact name="kotlin-stdlib-jdk7-1.6.0.jar">
<sha256 value="870d35fd266b2daf64c1080fe51824d3c368f7995384a8d7c5fc2fdc40eb7b3a" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains.kotlin" name="kotlin-stdlib-jdk7" version="1.6.21">
<artifact name="kotlin-stdlib-jdk7-1.6.21.jar">
<sha256 value="f1b0634dbb94172038463020bb2dd45ca26849f8ce29d625acb0f1569d11dbee" origin="Generated by Gradle"/>
Expand All @@ -3516,6 +3544,11 @@
<sha256 value="ac6361bf9ad1ed382c2103d9712c47cdec166232b4903ed596e8876b0681c9b7" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains.kotlin" name="kotlin-stdlib-jdk8" version="1.6.0">
<artifact name="kotlin-stdlib-jdk8-1.6.0.jar">
<sha256 value="ab0547c495953214a5f2b28150014f4e02133678d52b77d76375ea235e443dbd" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains.kotlin" name="kotlin-stdlib-jdk8" version="1.6.21">
<artifact name="kotlin-stdlib-jdk8-1.6.21.jar">
<sha256 value="dab45489b47736d59fce44b80676f1947a9b6bcab10fd60e878a83bd82a6954c" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -3671,6 +3704,11 @@
<sha256 value="48dfd8139edee5481bcc8b25e24d7586aca615f0d1ed2beb242dc7478ed4cee0" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains.kotlinx" name="kotlinx-coroutines-core" version="1.5.0">
<artifact name="kotlinx-coroutines-core-1.5.0.module">
<sha256 value="d8a26a896da32fb1f8c3f13fe41cb798a612a1c1ddf3a555d82ee1ff16ef13d3" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains.kotlinx" name="kotlinx-coroutines-core" version="1.6.1">
<artifact name="kotlinx-coroutines-core-1.6.1.module">
<sha256 value="79fe6569a9fffb409e51c64d5f8c54d27c4aa3735886155899d28ed2c9dfbc48" origin="Generated by Gradle"/>
Expand Down
16 changes: 12 additions & 4 deletions android/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
include(":app", ":service", ":tile")

include(
":app",
":service",
":tile"
)
include(
":lib:common",
":lib:endpoint",
Expand All @@ -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"
)
42 changes: 42 additions & 0 deletions android/test/arch/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
}
1 change: 1 addition & 0 deletions android/test/arch/src/test/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<manifest />
Original file line number Diff line number Diff line change
@@ -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")
}
}
}
Loading