Skip to content

Commit

Permalink
Bump versions
Browse files Browse the repository at this point in the history
  • Loading branch information
erikeelde committed May 10, 2024
1 parent c2253a5 commit 21eb579
Show file tree
Hide file tree
Showing 20 changed files with 207 additions and 25 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,19 @@ jobs:
- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Run app Checks
- name: Run test without shared tests
run: ./gradlew test -Pshared-tests-are-android-tests=false

- name: Run test with shared tests
run: ./gradlew test -Pshared-tests-are-android-tests=true

- name: Run test without shared tests
run: ./gradlew assembleAndroidTest -Pshared-tests-are-android-tests=false

- name: Run test with shared tests
run: ./gradlew assembleAndroidTest -Pshared-tests-are-android-tests=true

- name: Run check
run: ./gradlew check

- name: Run core Checks
Expand All @@ -56,7 +68,6 @@ jobs:
path: '**/build/reports/*'
retention-days: 2


emulator-tests:
runs-on: ubuntu-latest

Expand Down Expand Up @@ -93,4 +104,4 @@ jobs:
with:
name: "Android test results"
path: '**/build/reports/*'
retention-days: 2
retention-days: 2
2 changes: 1 addition & 1 deletion build-logic/conventions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies {
implementation(libs.com.android.tools.build.gradle)
implementation(libs.org.jetbrains.kotlin.kotlin.gradle.plugin)
implementation("com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:1.9.10-1.0.13")

implementation("com.squareup:kotlinpoet:1.16.0")
// https://github.com/gradle/gradle/issues/15383
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
}
2 changes: 1 addition & 1 deletion build-logic/conventions/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ dependencyResolutionManagement {

plugins {
id("com.gradle.develocity") version "3.17.2"
id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0")
id("org.gradle.toolchains.foojay-resolver-convention") version("0.8.0")
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,57 @@ android {
kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get()
}

@Suppress("UnstableApiUsage")
testOptions {
unitTests.isIncludeAndroidResources = true
}

lint {
baseline = file("lint-baseline.xml")
checkReleaseBuilds = true
abortOnError = true
warningsAsErrors = true
lintConfig = File("../lint.xml")
}

testOptions {
animationsDisabled = true
execution = "ANDROIDX_TEST_ORCHESTRATOR"
unitTests {
isReturnDefaultValues = true
isIncludeAndroidResources = true
}
managedDevices {
devices {
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel2api30").apply {
// Use device profiles you typically see in Android Studio.
device = "Pixel 2"
// Use only API levels 30 and higher.
apiLevel = 30
// To include Google services, use "google".
systemImageSource = "aosp"
}
}
}
}

sourceSets {
val sharedTestDir = "src/sharedTest/"
if(project.file(sharedTestDir).exists()) {
val sharedTestSourceDir = sharedTestDir + "java"
val sharedTestResourceDir = sharedTestDir + "resources"
val sharedIsAndroid =
providers.gradleProperty("shared-tests-are-android-tests").get().toBoolean()
if (sharedIsAndroid) {
logger.lifecycle("Shared tests are androidTests")
named("androidTest") {
java.srcDir(sharedTestSourceDir)
resources.srcDir(sharedTestResourceDir)
}
} else {
logger.lifecycle("Shared tests are unitTests")
named("test") {
java.srcDir(sharedTestSourceDir)
resources.srcDir(sharedTestResourceDir)
}
}
}
}
}

kotlin {
Expand All @@ -51,4 +90,12 @@ kotlin {

dependencies {
lintChecks(libs.com.slack.lint.compose.compose.lint.checks)

testImplementation(libs.androidx.test.ext.junit)
testImplementation(libs.androidx.test.runner)

androidTestImplementation(libs.androidx.test.ext.junit)
androidTestImplementation(libs.androidx.test.runner)

androidTestUtil(libs.androidx.test.orchestrator)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

plugins {
id("com.android.library")
kotlin("android")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import gradle.kotlin.dsl.accessors._2c8cd94a371784cae42f67a4fea566f3.androidTestImplementation
import gradle.kotlin.dsl.accessors._2c8cd94a371784cae42f67a4fea566f3.androidTestUtil
import gradle.kotlin.dsl.accessors._2c8cd94a371784cae42f67a4fea566f3.testImplementation
import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.kotlin.dsl.kotlin

Expand Down Expand Up @@ -25,6 +28,50 @@ android {
warningsAsErrors = true
lintConfig = File("../../lint.xml")
}

testOptions {
animationsDisabled = true
execution = "ANDROIDX_TEST_ORCHESTRATOR"
unitTests {
isReturnDefaultValues = true
isIncludeAndroidResources = true
}
managedDevices {
devices {
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel2api30").apply {
// Use device profiles you typically see in Android Studio.
device = "Pixel 2"
// Use only API levels 30 and higher.
apiLevel = 30
// To include Google services, use "google".
systemImageSource = "aosp"
}
}
}
}

sourceSets {
val sharedTestDir = "src/sharedTest/"
if(project.file(sharedTestDir).exists()) {
val sharedTestSourceDir = sharedTestDir + "java"
val sharedTestResourceDir = sharedTestDir + "resources"
val sharedIsAndroid =
providers.gradleProperty("shared-tests-are-android-tests").get().toBoolean()
if (sharedIsAndroid) {
logger.lifecycle("Shared tests are androidTests")
named("androidTest") {
java.srcDir(sharedTestSourceDir)
resources.srcDir(sharedTestResourceDir)
}
} else {
logger.lifecycle("Shared tests are unitTests")
named("test") {
java.srcDir(sharedTestSourceDir)
resources.srcDir(sharedTestResourceDir)
}
}
}
}
}

kotlin {
Expand All @@ -35,4 +82,12 @@ kotlin {

dependencies {
lintChecks(libs.com.slack.lint.compose.compose.lint.checks)

testImplementation(libs.androidx.test.ext.junit)
testImplementation(libs.androidx.test.runner)

androidTestImplementation(libs.androidx.test.ext.junit)
androidTestImplementation(libs.androidx.test.runner)

androidTestUtil(libs.androidx.test.orchestrator)
}
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2g -Xms500m -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx12120m

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
Expand Down Expand Up @@ -42,3 +42,5 @@ android.enableJetifier=false
org.gradle.caching=true
org.gradle.configuration-cache=true
org.gradle.configuration-cache.max-problems=5

shared-tests-are-android-tests=true
12 changes: 6 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ org-jetbrains-kotlinx-kotlinx-collections-immutable = "org.jetbrains.kotlinx:kot
org-jetbrains-kotlinx-kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android" }
org-jetbrains-kotlinx-kotlinx-coroutines-bom = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-bom", version.ref = "org-jetbrains-kotlinx" }
org-robolectric = "org.robolectric:robolectric:4.12.1"
se-eelde-toggles-toggles-core = { module = "se.eelde.toggles:toggles-core" }
se-eelde-toggles-toggles-flow = { module = "se.eelde.toggles:toggles-flow" }
se-eelde-toggles-toggles-prefs = { module = "se.eelde.toggles:toggles-prefs" }
#se-eelde-toggles-toggles-core = "se.eelde.toggles:toggles-core:0.0.2"
#se-eelde-toggles-toggles-flow = "se.eelde.toggles:toggles-flow:0.0.1"
#se-eelde-toggles-toggles-prefs = "se.eelde.toggles:toggles-prefs:0.0.1"
#se-eelde-toggles-toggles-core = { module = "se.eelde.toggles:toggles-core" }
#se-eelde-toggles-toggles-flow = { module = "se.eelde.toggles:toggles-flow" }
#se-eelde-toggles-toggles-prefs = { module = "se.eelde.toggles:toggles-prefs" }
se-eelde-toggles-toggles-core = "se.eelde.toggles:toggles-core:0.0.2"
se-eelde-toggles-toggles-flow = "se.eelde.toggles:toggles-flow:0.0.1"
se-eelde-toggles-toggles-prefs = "se.eelde.toggles:toggles-prefs:0.0.1"
[plugins]
com-android-library = { id = "com.android.library", version.ref = "agp" }
com-autonomousapps-dependency-analysis = "com.autonomousapps.dependency-analysis:1.31.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package se.eelde.toggles.applications

import android.app.Application
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

/**
* ./gradlew :modules:applications:pixel2api30DebugAndroidTest -Pshared-tests-are-android-tests=false
* ./gradlew :modules:applications:pixel2api30DebugAndroidTest -Pshared-tests-are-android-tests=true
*/
@RunWith(AndroidJUnit4::class)
class ExampleSharedTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}

@Test
fun useAppContext() {
val context = ApplicationProvider.getApplicationContext<Application>()
assertEquals("se.eelde.toggles.applications.test", context.packageName)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sdk=33
17 changes: 17 additions & 0 deletions scripts/pr_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

cd "$SCRIPT_DIR"/.. || exit

./gradlew detekt
./gradlew test -Pshared-tests-are-android-tests=false
./gradlew test -Pshared-tests-are-android-tests=true
./gradlew assembleAndroidTest -Pshared-tests-are-android-tests=false
./gradlew assembleAndroidTest -Pshared-tests-are-android-tests=true
./gradlew check
./gradlew :toggles-core:check
./gradlew :toggles-flow:check --no-configuration-cache
./gradlew :toggles-flow-noop:check
./gradlew :toggles-prefs:check --no-configuration-cache
./gradlew :toggles-prefs-noop:check
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pluginManagement {

plugins {
id("com.gradle.develocity") version "3.17.2"
id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0")
id("org.gradle.toolchains.foojay-resolver-convention") version("0.8.0")
}

buildCache {
Expand Down
1 change: 0 additions & 1 deletion toggles-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,4 @@ dependencies {
androidTestImplementation(libs.androidx.test.ext.junit)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.compose.ui.ui.test.junit4)
androidTestUtil(libs.androidx.test.orchestrator)
}
2 changes: 1 addition & 1 deletion toggles-core/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pluginManagement {

plugins {
id("com.gradle.develocity") version "3.17.2"
id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0")
id("org.gradle.toolchains.foojay-resolver-convention") version("0.8.0")
}

dependencyResolutionManagement {
Expand Down
2 changes: 1 addition & 1 deletion toggles-flow-noop/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pluginManagement {

plugins {
id("com.gradle.develocity") version "3.17.2"
id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0")
id("org.gradle.toolchains.foojay-resolver-convention") version("0.8.0")
}

dependencyResolutionManagement {
Expand Down
2 changes: 1 addition & 1 deletion toggles-flow/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pluginManagement {

plugins {
id("com.gradle.develocity") version "3.17.2"
id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0")
id("org.gradle.toolchains.foojay-resolver-convention") version("0.8.0")
}

dependencyResolutionManagement {
Expand Down
2 changes: 1 addition & 1 deletion toggles-prefs-noop/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pluginManagement {

plugins {
id("com.gradle.develocity") version "3.17.2"
id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0")
id("org.gradle.toolchains.foojay-resolver-convention") version("0.8.0")
}

dependencyResolutionManagement {
Expand Down
2 changes: 1 addition & 1 deletion toggles-prefs/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pluginManagement {

plugins {
id("com.gradle.develocity") version "3.17.2"
id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0")
id("org.gradle.toolchains.foojay-resolver-convention") version("0.8.0")
}

dependencyResolutionManagement {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package se.eelde.toggles.applications

import android.app.Application
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class ExampleSharedTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}

@Test
fun useAppContext() {
val context = ApplicationProvider.getApplicationContext<Application>()
assertEquals("se.eelde.toggles.example.debug", context.packageName)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sdk=33

0 comments on commit 21eb579

Please sign in to comment.