|
| 1 | +name: TestConfigurationSample |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - 'TestConfigurationSample/**' |
| 9 | + pull_request: |
| 10 | + paths: |
| 11 | + - 'TestConfigurationSample/**' |
| 12 | + |
| 13 | +env: |
| 14 | + SAMPLE_PATH: TestConfigurationSample |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + timeout-minutes: 30 |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v2 |
| 24 | + |
| 25 | + - name: Copy CI gradle.properties |
| 26 | + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties |
| 27 | + |
| 28 | + - name: Set up JDK 11 |
| 29 | + uses: actions/setup-java@v1 |
| 30 | + with: |
| 31 | + java-version: 11 |
| 32 | + |
| 33 | + - name: Generate cache key |
| 34 | + run: ./scripts/checksum.sh $SAMPLE_PATH checksum.txt |
| 35 | + |
| 36 | + - uses: actions/cache@v2 |
| 37 | + with: |
| 38 | + path: | |
| 39 | + ~/.gradle/caches/modules-* |
| 40 | + ~/.gradle/caches/jars-* |
| 41 | + ~/.gradle/caches/build-cache-* |
| 42 | + key: gradle-${{ hashFiles('checksum.txt') }} |
| 43 | + |
| 44 | + - name: Build project and run local tests |
| 45 | + working-directory: ${{ env.SAMPLE_PATH }} |
| 46 | + run: ./gradlew spotlessCheck assembleDebug lintDebug testDebug --stacktrace --no-build-cache --rerun-tasks |
| 47 | + |
| 48 | + gradleManagedVirtualDevicesTest: |
| 49 | + needs: build |
| 50 | + runs-on: macOS-latest # enables hardware acceleration in the virtual machine |
| 51 | + timeout-minutes: 90 |
| 52 | + |
| 53 | + steps: |
| 54 | + - name: Checkout |
| 55 | + uses: actions/checkout@v2 |
| 56 | + |
| 57 | + - name: Copy CI gradle.properties |
| 58 | + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties |
| 59 | + |
| 60 | + - name: Set up JDK 11 |
| 61 | + uses: actions/setup-java@v1 |
| 62 | + with: |
| 63 | + java-version: 11 |
| 64 | + |
| 65 | + - name: Generate cache key |
| 66 | + run: ./scripts/checksum.sh $SAMPLE_PATH checksum.txt |
| 67 | + |
| 68 | + - uses: actions/cache@v2 |
| 69 | + with: |
| 70 | + path: | |
| 71 | + ~/.gradle/caches/modules-* |
| 72 | + ~/.gradle/caches/jars-* |
| 73 | + ~/.gradle/caches/build-cache-* |
| 74 | + key: gradle-${{ hashFiles('checksum.txt') }} |
| 75 | + |
| 76 | + - name: AVD cache |
| 77 | + uses: actions/cache@v2 |
| 78 | + id: avd-cache |
| 79 | + with: |
| 80 | + path: | |
| 81 | + ~/.android/gradle/avd/* |
| 82 | + key: avd |
| 83 | + |
| 84 | + - name: Run instrumented tests |
| 85 | + working-directory: ${{ env.SAMPLE_PATH }} |
| 86 | + run: | |
| 87 | + ./gradlew pixel2api29DebugAndroidTest -Pandroid.experimental.androidTest.useUnifiedTestPlatform=true -Pandroid.testInstrumentationRunnerArguments.notAnnotation=com.example.android.testing.testconfigurationsample.TestDeviceLargeScreen |
| 88 | + ./gradlew pixel2api23DebugAndroidTest -Pandroid.experimental.androidTest.useUnifiedTestPlatform=true -Pandroid.testInstrumentationRunnerArguments.annotation=com.example.android.testing.testconfigurationsample.TestDeviceApi23 |
| 89 | + ./gradlew nexus9api29DebugAndroidTest -Pandroid.experimental.androidTest.useUnifiedTestPlatform=true -Pandroid.testInstrumentationRunnerArguments.annotation=com.example.android.testing.testconfigurationsample.TestDeviceLargeScreen |
| 90 | +
|
| 91 | + - name: Upload test reports |
| 92 | + if: always() |
| 93 | + uses: actions/upload-artifact@v2 |
| 94 | + with: |
| 95 | + name: test-reports |
| 96 | + path: ${{ env.SAMPLE_PATH }}/app/build/reports/androidTests |
0 commit comments