Skip to content

Commit

Permalink
Change to Gradle managed devices
Browse files Browse the repository at this point in the history
  • Loading branch information
wmontwe committed Feb 19, 2023
1 parent 5d76519 commit 1df1bb3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
24 changes: 7 additions & 17 deletions .github/workflows/ci-pull-request-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,17 @@ jobs:
- name: Setup Android SDK
uses: android-actions/setup-android@v2

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Version
run: ./gradlew --no-daemon --stacktrace versionInfo
run: ./gradlew --stacktrace versionInfo

- name: Build
run: ./gradlew --no-daemon --stacktrace build
run: ./gradlew --stacktrace build

- name: Run Android Device Tests
uses: reactivecircus/android-emulator-runner@v2
env:
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL: 120
with:
api-level: ${{ matrix.api-level }}
target: google_apis
arch: x86
profile: Nexus 5
avd-name: blueprint-${{ matrix.api-level }}
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
disk-size: 2048M
script: ./gradlew --no-daemon --stacktrace connectedCheck
- name: Run Android instrumented tests
run: ./gradlew androidGroupDebugAndroidTest

- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
Expand Down
21 changes: 20 additions & 1 deletion app-android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.android.build.api.dsl.ManagedVirtualDevice
import eu.bitfunk.gradle.plugin.tool.versioning.version
import eu.bitfunk.gradle.plugin.tool.versioning.versionCode

Expand Down Expand Up @@ -54,7 +55,7 @@ android {

packagingOptions {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
excludes += "/META-INF/{AL2.0,LGPL2.1,*.md}"
}
}

Expand All @@ -64,6 +65,23 @@ android {

baseline = file("lint-baseline.xml")
}

testOptions {
managedDevices {
devices {
maybeCreate<ManagedVirtualDevice>("Pixel_2_API_30").apply {
device = "Pixel 2"
apiLevel = 30
systemImageSource = "google-atd"
}
}
groups {
maybeCreate("android").apply {
targetDevices.add(devices["Pixel_2_API_30"])
}
}
}
}
}

dependencies {
Expand All @@ -74,4 +92,5 @@ dependencies {
debugImplementation(libs.bundles.app.android.compose.debug)
testImplementation(libs.bundles.app.android.test)
androidTestImplementation(libs.bundles.app.android.androidTest)
androidTestImplementation(libs.bundles.app.android.androidTest.compose)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ class ExampleInstrumentedTest {
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.example.myapplication", appContext.packageName)
assertEquals("eu.bitfunk.blueprint.mobile.android.app", appContext.packageName)
}
}

0 comments on commit 1df1bb3

Please sign in to comment.