diff --git a/.github/workflows/ci-pull-request-validation.yml b/.github/workflows/ci-pull-request-validation.yml index 8c485cd..4b9c531 100644 --- a/.github/workflows/ci-pull-request-validation.yml +++ b/.github/workflows/ci-pull-request-validation.yml @@ -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: @@ -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/setup-android@v1.0.0 + 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/android-emulator-runner@v1.0.0 - 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" diff --git a/CHANGELOG.md b/CHANGELOG.md index ef6d7b0..a86d388 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/app-android/build.gradle.kts b/app-android/build.gradle.kts index 61d4db3..e7351d4 100644 --- a/app-android/build.gradle.kts +++ b/app-android/build.gradle.kts @@ -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 @@ -23,6 +24,9 @@ android { } buildTypes { + getByName("debug") { + enableUnitTestCoverage = true + } getByName("release") { isMinifyEnabled = false proguardFiles( @@ -54,7 +58,7 @@ android { packagingOptions { resources { - excludes += "/META-INF/{AL2.0,LGPL2.1}" + excludes += "/META-INF/{AL2.0,LGPL2.1,*.md}" } } @@ -64,6 +68,23 @@ android { baseline = file("lint-baseline.xml") } + + testOptions { + managedDevices { + devices { + maybeCreate("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 { @@ -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) } diff --git a/app-android/src/androidTest/java/eu/bitfunk/blueprint/mobile/android/app/ExampleInstrumentedTest.kt b/app-android/src/androidTest/java/eu/bitfunk/blueprint/mobile/android/app/ExampleInstrumentedTest.kt index 1e03af3..43eb7fb 100644 --- a/app-android/src/androidTest/java/eu/bitfunk/blueprint/mobile/android/app/ExampleInstrumentedTest.kt +++ b/app-android/src/androidTest/java/eu/bitfunk/blueprint/mobile/android/app/ExampleInstrumentedTest.kt @@ -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) } }