From 1966c383e17cb7b23a562327807b5553e5536f14 Mon Sep 17 00:00:00 2001 From: Joshua Schriever Date: Mon, 8 May 2023 10:59:40 -0500 Subject: [PATCH] update dependencies, enable configuration cache --- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 2 +- gordon-plugin/build.gradle.kts | 28 +++++++++---------- gordon-plugin/gradle.properties | 2 +- .../kotlin/com/banno/gordon/DevicePools.kt | 6 ++-- .../com/banno/gordon/TestDistributor.kt | 4 +-- .../kotlin/com/banno/gordon/TestResults.kt | 19 +++++++------ gradle.properties | 9 +++--- gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle.kts | 9 ++++++ test_app/build.gradle.kts | 21 ++++++++------ test_app/src/main/AndroidManifest.xml | 3 +- test_feature/build.gradle.kts | 19 +++++++------ test_feature/src/main/AndroidManifest.xml | 3 +- test_library/build.gradle.kts | 20 +++++++------ test_library/src/main/AndroidManifest.xml | 2 -- 16 files changed, 82 insertions(+), 69 deletions(-) delete mode 100644 test_library/src/main/AndroidManifest.xml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1a7e125..8e90cf2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: 11 + java-version: 17 - uses: actions/checkout@v3 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 53d5c1b..c6493cd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: 11 + java-version: 17 - uses: actions/checkout@v3 diff --git a/gordon-plugin/build.gradle.kts b/gordon-plugin/build.gradle.kts index 0896e8a..30a0ab8 100644 --- a/gordon-plugin/build.gradle.kts +++ b/gordon-plugin/build.gradle.kts @@ -1,28 +1,23 @@ +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + plugins { `kotlin-dsl` - `java-gradle-plugin` id("com.gradle.plugin-publish") - `maven-publish` kotlin("plugin.serialization") id("org.jmailen.kotlinter") } -repositories { - google() - mavenCentral() -} - val androidGradlePluginVersion: String by project val aapt2Version: String by project dependencies { implementation(gradleKotlinDsl()) implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0") implementation("org.jetbrains.kotlinx:kotlinx-html:0.7.3") implementation("com.android.tools.build:gradle:$androidGradlePluginVersion") - implementation("com.android.tools.build:bundletool:1.8.2") + implementation("com.android.tools.build:bundletool:1.14.1") implementation("com.google.guava:guava:30.1.1-jre") implementation("org.smali:dexlib2:2.5.2") @@ -32,6 +27,12 @@ dependencies { testImplementation("io.mockk:mockk:1.12.0") } +tasks.withType().configureEach { + kotlinOptions { + jvmTarget = "17" + } +} + tasks.withType().configureEach { dependsOn(":test_app:assembleDebugAndroidTest") testLogging.exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL @@ -49,21 +50,18 @@ mapOf( } gradlePlugin { + website.set("https://github.com/Banno/Gordon") + vcsUrl.set("https://github.com/Banno/Gordon") plugins { register("gordon") { id = "com.banno.gordon" implementationClass = "com.banno.gordon.GordonPlugin" displayName = "Gordon" description = "Android instrumentation test runner designed for speed, simplicity, and reliability" + tags.set(setOf("android", "instrumentation", "test", "runner")) } } } -pluginBundle { - website = "https://github.com/Banno/Gordon" - vcsUrl = "https://github.com/Banno/Gordon" - tags = setOf("android", "instrumentation", "test", "runner") -} - extra["gradle.publish.key"] = System.getenv("GRADLE_PLUGIN_PUBLISH_KEY") extra["gradle.publish.secret"] = System.getenv("GRADLE_PLUGIN_PUBLISH_SECRET") diff --git a/gordon-plugin/gradle.properties b/gordon-plugin/gradle.properties index 639dcab..22aaa80 100644 --- a/gordon-plugin/gradle.properties +++ b/gordon-plugin/gradle.properties @@ -1,2 +1,2 @@ group=com.banno.gordon -version=1.8.8 +version=1.9.0 diff --git a/gordon-plugin/src/main/kotlin/com/banno/gordon/DevicePools.kt b/gordon-plugin/src/main/kotlin/com/banno/gordon/DevicePools.kt index 472aa76..7dbce5a 100644 --- a/gordon-plugin/src/main/kotlin/com/banno/gordon/DevicePools.kt +++ b/gordon-plugin/src/main/kotlin/com/banno/gordon/DevicePools.kt @@ -20,11 +20,11 @@ internal fun calculatePools( val allDevices = adb.getAllDevices().bind() when (strategy) { - PoolingStrategy.PoolPerDevice -> allDevices.map { DevicePool(it.serialNumber, listOf(it)) } + is PoolingStrategy.PoolPerDevice -> allDevices.map { DevicePool(it.serialNumber, listOf(it)) } - PoolingStrategy.SinglePool -> listOf(DevicePool("All-Devices", allDevices.toList())) + is PoolingStrategy.SinglePool -> listOf(DevicePool("All-Devices", allDevices.toList())) - PoolingStrategy.PhonesAndTablets -> { + is PoolingStrategy.PhonesAndTablets -> { val deviceAndIsTablet = allDevices.map { it to it.isTablet(tabletShortestWidthDp).bind() } listOf( diff --git a/gordon-plugin/src/main/kotlin/com/banno/gordon/TestDistributor.kt b/gordon-plugin/src/main/kotlin/com/banno/gordon/TestDistributor.kt index 24b958e..6851bc7 100644 --- a/gordon-plugin/src/main/kotlin/com/banno/gordon/TestDistributor.kt +++ b/gordon-plugin/src/main/kotlin/com/banno/gordon/TestDistributor.kt @@ -93,7 +93,7 @@ internal fun runAllTests( val existingResult = testResults[testCase] when (result) { - TestResult.NotRun -> if (existingResult is TestResult.Failed) existingResult else result + is TestResult.NotRun -> if (existingResult is TestResult.Failed) existingResult else result is TestResult.Failed -> { if (existingResult is TestResult.Failed) { @@ -112,7 +112,7 @@ internal fun runAllTests( } is TestResult.Flaky, - TestResult.Ignored -> result + is TestResult.Ignored -> result } } diff --git a/gordon-plugin/src/main/kotlin/com/banno/gordon/TestResults.kt b/gordon-plugin/src/main/kotlin/com/banno/gordon/TestResults.kt index cc6be55..9a8331c 100644 --- a/gordon-plugin/src/main/kotlin/com/banno/gordon/TestResults.kt +++ b/gordon-plugin/src/main/kotlin/com/banno/gordon/TestResults.kt @@ -44,11 +44,11 @@ internal fun Map>.summary(): String { "Test Results", "----------------", allResults.count { it is TestResult.Passed }.let { "Passed: $it" }, - allResults.count { it == TestResult.Ignored }.takeIf { it > 0 }?.let { "Ignored: $it" }, + allResults.count { it is TestResult.Ignored }.takeIf { it > 0 }?.let { "Ignored: $it" }, allResults.count { it is TestResult.Flaky }.takeIf { it > 0 }?.let { "Flaky: $it" }, - allResults.count { it == TestResult.NotRun }.takeIf { it > 0 }?.let { "Unable to run: $it" }, + allResults.count { it is TestResult.NotRun }.takeIf { it > 0 }?.let { "Unable to run: $it" }, allResults.count { it is TestResult.Failed }.takeIf { it > 0 }?.let { "Failed: $it" }, - *mapValues { poolResults -> poolResults.value.filterValues { it == TestResult.NotRun || it is TestResult.Failed } } + *mapValues { poolResults -> poolResults.value.filterValues { it is TestResult.NotRun || it is TestResult.Failed } } .flatMap { (poolName, poolResults) -> poolResults.map { "$poolName: ${it.key.fullyQualifiedClassName.substringAfterLast('.')}.${it.key.methodName}" @@ -65,8 +65,8 @@ internal fun Map>.junitReports() = xmlDocument("testsuite") { attribute("name", poolName) attribute("tests", "1") - attribute("skipped", if (result == TestResult.Ignored) "1" else "0") - attribute("errors", if (result == TestResult.NotRun) "1" else "0") + attribute("skipped", if (result is TestResult.Ignored) "1" else "0") + attribute("errors", if (result is TestResult.NotRun) "1" else "0") attribute("failures", if (result is TestResult.Failed) "1" else "0") element("testcase") { attribute("name", testCase.methodName) @@ -74,8 +74,8 @@ internal fun Map>.junitReports() = result.duration()?.let { attribute("time", it.toString()) } when (result) { - TestResult.Ignored -> element("skipped") - TestResult.NotRun -> element("error", "Unable to run test") + is TestResult.Ignored -> element("skipped") + is TestResult.NotRun -> element("error", "Unable to run test") is TestResult.Failed -> element( "failure", result.failures.concatFailures() @@ -84,6 +84,7 @@ internal fun Map>.junitReports() = "system-err", result.failures.concatFailures() ) + is TestResult.Passed -> Unit } } } @@ -104,8 +105,8 @@ private fun TestResult.duration(): Float? = when (this) { is TestResult.Passed -> duration is TestResult.Failed -> failures.mapNotNull { it.duration }.sum() is TestResult.Flaky -> failures.mapNotNull { it.duration }.sum() + (passedDuration ?: 0f) - TestResult.NotRun, - TestResult.Ignored -> null + is TestResult.NotRun, + is TestResult.Ignored -> null } internal fun Map>.htmlReport(): ReportFile { diff --git a/gradle.properties b/gradle.properties index 2c4fce8..0044c6a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,10 @@ -androidGradlePluginVersion=7.1.1 -aapt2Version=7.1.1-7984345 -kotlinVersion=1.6.10 +androidGradlePluginVersion=8.0.0 +aapt2Version=8.0.0-9289358 +kotlinVersion=1.8.10 kotlinterVersion=3.8.0 -gradlePluginPublishVersion=0.20.0 +gradlePluginPublishVersion=1.2.0 org.gradle.caching=true +org.gradle.configuration-cache=true org.gradle.daemon=true org.gradle.jvmargs=-Xmx1536m org.gradle.parallel=true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f338a88..dba0b08 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip diff --git a/settings.gradle.kts b/settings.gradle.kts index 55572ae..15d5821 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -23,3 +23,12 @@ pluginManagement { id("com.gradle.plugin-publish") version gradlePluginPublishVersion } } + +dependencyResolutionManagement { + repositories { + google() + mavenCentral() + } +} + +enableFeaturePreview("STABLE_CONFIGURATION_CACHE") diff --git a/test_app/build.gradle.kts b/test_app/build.gradle.kts index c0bd1bf..4a6cca4 100644 --- a/test_app/build.gradle.kts +++ b/test_app/build.gradle.kts @@ -6,16 +6,24 @@ plugins { } android { - compileSdk = 31 - buildToolsVersion = "31.0.0" + namespace = "com.banno.android.gordontest" + compileSdk = 33 + buildToolsVersion = "33.0.2" defaultConfig { - minSdk = 21 - targetSdk = 31 + minSdk = 26 + targetSdk = 33 applicationId = "com.banno.android.gordontest" versionCode = 1 versionName = "1.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } + compileOptions { + sourceCompatibility("17") + targetCompatibility("17") + } + kotlinOptions { + jvmTarget = "17" + } val debugSigningConfig = signingConfigs.register("debugSigningConfig") { storeFile = file("debug.keystore") storePassword = "bigbago" @@ -30,11 +38,6 @@ android { ) } -repositories { - google() - mavenCentral() -} - dependencies { implementation("androidx.appcompat:appcompat:1.4.1") androidTestImplementation("androidx.test:runner:1.4.0") diff --git a/test_app/src/main/AndroidManifest.xml b/test_app/src/main/AndroidManifest.xml index 83f305a..575a0b4 100644 --- a/test_app/src/main/AndroidManifest.xml +++ b/test_app/src/main/AndroidManifest.xml @@ -1,7 +1,6 @@ + xmlns:android="http://schemas.android.com/apk/res/android"> + xmlns:dist="http://schemas.android.com/apk/distribution"> -