Skip to content

Commit

Permalink
Merge pull request #120 from Banno/updates
Browse files Browse the repository at this point in the history
Support Gradle configuration cache
  • Loading branch information
joshschriever authored May 8, 2023
2 parents e1c7414 + 1966c38 commit 8ea0963
Show file tree
Hide file tree
Showing 16 changed files with 82 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11
java-version: 17

- uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11
java-version: 17

- uses: actions/checkout@v3

Expand Down
28 changes: 13 additions & 15 deletions gordon-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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")

Expand All @@ -32,6 +27,12 @@ dependencies {
testImplementation("io.mockk:mockk:1.12.0")
}

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "17"
}
}

tasks.withType<Test>().configureEach {
dependsOn(":test_app:assembleDebugAndroidTest")
testLogging.exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
Expand All @@ -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")
2 changes: 1 addition & 1 deletion gordon-plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
group=com.banno.gordon
version=1.8.8
version=1.9.0
6 changes: 3 additions & 3 deletions gordon-plugin/src/main/kotlin/com/banno/gordon/DevicePools.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -112,7 +112,7 @@ internal fun runAllTests(
}

is TestResult.Flaky,
TestResult.Ignored -> result
is TestResult.Ignored -> result
}
}

Expand Down
19 changes: 10 additions & 9 deletions gordon-plugin/src/main/kotlin/com/banno/gordon/TestResults.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ internal fun Map<PoolName, Map<TestCase, TestResult>>.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}"
Expand All @@ -65,17 +65,17 @@ internal fun Map<PoolName, Map<TestCase, TestResult>>.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)
attribute("classname", testCase.fullyQualifiedClassName)
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()
Expand All @@ -84,6 +84,7 @@ internal fun Map<PoolName, Map<TestCase, TestResult>>.junitReports() =
"system-err",
result.failures.concatFailures()
)
is TestResult.Passed -> Unit
}
}
}
Expand All @@ -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<PoolName, Map<TestCase, TestResult>>.htmlReport(): ReportFile {
Expand Down
9 changes: 5 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,12 @@ pluginManagement {
id("com.gradle.plugin-publish") version gradlePluginPublishVersion
}
}

dependencyResolutionManagement {
repositories {
google()
mavenCentral()
}
}

enableFeaturePreview("STABLE_CONFIGURATION_CACHE")
21 changes: 12 additions & 9 deletions test_app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -30,11 +38,6 @@ android {
)
}

repositories {
google()
mavenCentral()
}

dependencies {
implementation("androidx.appcompat:appcompat:1.4.1")
androidTestImplementation("androidx.test:runner:1.4.0")
Expand Down
3 changes: 1 addition & 2 deletions test_app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.banno.android.gordontest">
xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:icon="@android:mipmap/sym_def_app_icon"
Expand Down
19 changes: 11 additions & 8 deletions test_feature/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ plugins {
}

android {
compileSdk = 31
buildToolsVersion = "31.0.0"
namespace = "com.banno.android.gordontest.feature"
compileSdk = 33
buildToolsVersion = "33.0.2"
defaultConfig {
minSdk = 21
minSdk = 26
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
}

repositories {
google()
mavenCentral()
compileOptions {
sourceCompatibility("17")
targetCompatibility("17")
}
kotlinOptions {
jvmTarget = "17"
}
}

dependencies {
Expand Down
3 changes: 1 addition & 2 deletions test_feature/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:dist="http://schemas.android.com/apk/distribution"
package="com.banno.android.gordontest.feature">
xmlns:dist="http://schemas.android.com/apk/distribution">

<dist:module
dist:instant="false"
Expand Down
20 changes: 11 additions & 9 deletions test_library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@ plugins {
}

android {
compileSdk = 31
buildToolsVersion = "31.0.0"
namespace = "com.banno.android.gordontest.library"
compileSdk = 33
buildToolsVersion = "33.0.2"
defaultConfig {
minSdk = 21
targetSdk = 31
minSdk = 26
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility("17")
targetCompatibility("17")
}
kotlinOptions {
jvmTarget = "17"
}
flavorDimensions.add("foo")
productFlavors {
register("bar") {
Expand All @@ -25,11 +32,6 @@ android {
}
}

repositories {
google()
mavenCentral()
}

dependencies {
implementation("androidx.appcompat:appcompat:1.4.1")
androidTestImplementation("androidx.test:runner:1.4.0")
Expand Down
2 changes: 0 additions & 2 deletions test_library/src/main/AndroidManifest.xml

This file was deleted.

0 comments on commit 8ea0963

Please sign in to comment.