From 4e53a52d840014acfb398a572fcd377e839640d1 Mon Sep 17 00:00:00 2001 From: Jolanda Verhoef Date: Wed, 6 Oct 2021 14:20:29 +0200 Subject: [PATCH] [ConfigSample] Try out caching --- .../workflows/TestConfigurationSample.yaml | 32 ++++++++--------- .../MainActivityLargeScreenTests.kt | 34 ------------------- .../MainActivityTests.kt | 10 ++++-- 3 files changed, 24 insertions(+), 52 deletions(-) delete mode 100644 TestConfigurationSample/app/src/androidTest/java/com/example/android/testing/testconfigurationsample/MainActivityLargeScreenTests.kt diff --git a/.github/workflows/TestConfigurationSample.yaml b/.github/workflows/TestConfigurationSample.yaml index 14ce9b309..d23e82f60 100644 --- a/.github/workflows/TestConfigurationSample.yaml +++ b/.github/workflows/TestConfigurationSample.yaml @@ -47,8 +47,8 @@ jobs: gradleManagedVirtualDevicesTest: needs: build - runs-on: macOS-latest # enables hardware acceleration in the virtual machine - timeout-minutes: 90 + runs-on: macos-latest + timeout-minutes: 30 steps: - name: Checkout @@ -62,7 +62,7 @@ jobs: with: java-version: 11 - - name: Generate cache key + - name: Generate cache key for Gradle cache run: ./scripts/checksum.sh $SAMPLE_PATH checksum.txt - uses: actions/cache@v2 @@ -73,25 +73,25 @@ jobs: ~/.gradle/caches/build-cache-* key: gradle-${{ hashFiles('checksum.txt') }} - - name: AVD cache + - name: Cache pixel2api29 system image uses: actions/cache@v2 - id: avd-cache with: path: | - ~/.android/gradle/avd/* - key: avd + ~/.android/gradle/avd/dev29_aosp_x86_Pixel_2.ini + ~/.android/gradle/avd/dev29_aosp_x86_Pixel_2.avd + key: pixel2api29 - name: Run all tests working-directory: ${{ env.SAMPLE_PATH }} - run: ./gradlew -i pixel2api29DebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.notAnnotation=com.example.android.testing.testconfigurationsample.TestDeviceLargeScreen - - - name: Run regression tests - working-directory: ${{ env.SAMPLE_PATH }} - run: ./gradlew -i pixel2api26DebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.annotation=com.example.android.testing.testconfigurationsample.TestDeviceApi26 - - - name: Run large screen tests - working-directory: ${{ env.SAMPLE_PATH }} - run: ./gradlew -i nexus9api29DebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.annotation=com.example.android.testing.testconfigurationsample.TestDeviceLargeScreen + run: ./gradlew pixel2api29DebugAndroidTest + +# - name: Run regression tests +# working-directory: ${{ env.SAMPLE_PATH }} +# run: ./gradlew -i pixel2api26DebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.annotation=com.example.android.testing.testconfigurationsample.TestDeviceApi26 +# +# - name: Run large screen tests +# working-directory: ${{ env.SAMPLE_PATH }} +# run: ./gradlew -i nexus9api29DebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.annotation=com.example.android.testing.testconfigurationsample.TestDeviceLargeScreen - name: Upload test reports if: always() diff --git a/TestConfigurationSample/app/src/androidTest/java/com/example/android/testing/testconfigurationsample/MainActivityLargeScreenTests.kt b/TestConfigurationSample/app/src/androidTest/java/com/example/android/testing/testconfigurationsample/MainActivityLargeScreenTests.kt deleted file mode 100644 index 202b455ca..000000000 --- a/TestConfigurationSample/app/src/androidTest/java/com/example/android/testing/testconfigurationsample/MainActivityLargeScreenTests.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.example.android.testing.testconfigurationsample - -import androidx.compose.ui.test.junit4.createAndroidComposeRule -import androidx.compose.ui.test.onNodeWithText -import androidx.test.ext.junit.runners.AndroidJUnit4 -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -class MainActivityLargeScreenTests { - @get:Rule - val composeTestRule = createAndroidComposeRule() - - @Test @TestDeviceLargeScreen - fun testLargeScreenText() { - composeTestRule.onNodeWithText("Hi Large Screen!").assertExists() - } -} diff --git a/TestConfigurationSample/app/src/androidTest/java/com/example/android/testing/testconfigurationsample/MainActivityTests.kt b/TestConfigurationSample/app/src/androidTest/java/com/example/android/testing/testconfigurationsample/MainActivityTests.kt index 76c427890..6c7553e6f 100644 --- a/TestConfigurationSample/app/src/androidTest/java/com/example/android/testing/testconfigurationsample/MainActivityTests.kt +++ b/TestConfigurationSample/app/src/androidTest/java/com/example/android/testing/testconfigurationsample/MainActivityTests.kt @@ -19,7 +19,6 @@ import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.test.ext.junit.runners.AndroidJUnit4 import kotlinx.coroutines.delay import kotlinx.coroutines.runBlocking -import org.junit.Assert import org.junit.Assert.assertTrue import org.junit.Rule import org.junit.Test @@ -58,6 +57,13 @@ class MainActivityTests { assertTrue(true) } + @Test + fun sampleTest5() { + // Add instrumented tests here + runBlocking { delay(10000) } + assertTrue(true) + } + /** * When you find an issue with a specific device or API level, * you can create an annotation for it and add it to your test. @@ -70,6 +76,6 @@ class MainActivityTests { fun regressionTestKnownIssueApi26() { // Add instrumented tests here runBlocking { delay(10000) } - Assert.assertTrue(true) + assertTrue(true) } }