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

Fix CI emulator run #27

Merged
merged 6 commits into from
Feb 19, 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
47 changes: 17 additions & 30 deletions .github/workflows/ci-pull-request-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,10 @@ jobs:

runs-on: macos-latest

strategy:
matrix:
api-level: [ 30 ]

concurrency:
group: validation-${{ github.head_ref }}
cancel-in-progress: true

env:
GITHUB_PACKAGE_DOWNLOAD_USER: ${{ github.actor }}
GITHUB_PACKAGE_DOWNLOAD_KEY: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PACKAGE_UPLOAD_USER: ${{ github.actor }}
GITHUB_PACKAGE_UPLOAD_KEY: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3
with:
Expand All @@ -38,42 +28,39 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
distribution: temurin
java-version: 11

- name: Setup Android SDK
uses: bitfunk/[email protected]
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: bitfunk/[email protected]
with:
api-level: ${{ matrix.api-level }}
target: google_apis
arch: x86_64
profile: Nexus 5
avd-name: blueprint-${{ matrix.api-level }}
force-avd-creation: false
emulator-options: -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: ./gradlew --no-daemon --stacktrace connectedCheck
- name: Run Android instrumented tests
run: ./gradlew cleanManagedDevices --unused-only &&
./gradlew --stacktrace androidGroupDebugAndroidTest
-Dorg.gradle.workers.max=1
-Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect"

- name: Publish Test Report
- name: Publish test report
uses: mikepenz/action-junit-report@v3
if: always()
with:
report_paths: '**/build/test-results/test/TEST-*.xml'
report_paths: '**/build/test-results/**/TEST-*.xml'

- name: Analyze
if: ${{ false }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew --no-daemon --stacktrace testCodeCoverageReport sonarqube
run: ./gradlew --stacktrace :app-android:createDebugUnitTestCoverageReport sonar

- name: Publish Development Version
run: echo "TODO"
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ See [changeset](https://github.com/wmontwe/blueprint-mobile/compare/v0.1.0...mai

- Bitfunk Versioning 0.1.2

### Changed

- Change emulator to Gradle managed devices for local and CI builds

### Bumped

- Gradle 7.5.1 -> 8.0.1
Expand Down
24 changes: 23 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 All @@ -23,6 +24,9 @@ android {
}

buildTypes {
getByName("debug") {
enableUnitTestCoverage = true
}
getByName("release") {
isMinifyEnabled = false
proguardFiles(
Expand Down Expand Up @@ -54,7 +58,7 @@ android {

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

Expand All @@ -64,6 +68,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 +95,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)
}
}