1name: Main 2 3on: 4 pull_request: 5 push: 6 branches: 7 - main 8 9jobs: 10 validation: 11 runs-on: ubuntu-latest 12 steps: 13 - uses: actions/checkout@v3 14 - uses: gradle/wrapper-validation-action@v1 15 16 checks: 17 runs-on: ubuntu-latest 18 steps: 19 - uses: actions/checkout@v3 20 - uses: actions/setup-java@v3 21 with: 22 java-version: 8 23 distribution: 'zulu' 24 - uses: gradle/gradle-build-action@v2 25 - name: Build project 26 run: ./gradlew build --stacktrace 27 28 instrumentation-tests: 29 runs-on: macos-latest 30 timeout-minutes: 30 31 strategy: 32 # Allow tests to continue on other devices if they fail on one device. 33 fail-fast: false 34 matrix: 35 arch: [ x86_64 ] 36 target: [ google_apis ] 37 channel: [ stable ] 38 api-level: 39 - 21 40 - 23 41 - 26 42 # - 29 flaky 43 include: 44 - arch: x86 45 api-level: 16 46 target: google_apis 47 channel: stable 48 - arch: x86 49 api-level: 19 50 target: google_apis 51 channel: stable 52 # Failing (something about permissions maybe? 53 # - arch: x86 54 # api-level: 30 55 # target: aosp_atd 56 # channel: canary 57 steps: 58 - uses: actions/checkout@v3 59 - uses: actions/setup-java@v3 60 with: 61 java-version: 8 62 distribution: 'zulu' 63 - uses: gradle/gradle-build-action@v2 64 - name: AVD cache 65 uses: actions/cache@v3 66 id: avd-cache 67 with: 68 path: | 69 ~/.android/avd/* 70 ~/.android/adb* 71 key: avd-${{ matrix.api-level }}-${{ matrix.os }}-${{ matrix.target }} 72 - name: Create AVD and generate snapshot for caching 73 if: steps.avd-cache.outputs.cache-hit != 'true' 74 uses: reactivecircus/android-emulator-runner@v2 75 with: 76 api-level: ${{ matrix.api-level }} 77 target: ${{ matrix.target }} 78 arch: ${{ matrix.arch }} 79 force-avd-creation: false 80 emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none 81 disable-animations: false 82 script: echo "Generated AVD snapshot for caching." 83 - name: Instrumentation Tests 84 uses: reactivecircus/android-emulator-runner@v2 85 with: 86 api-level: ${{ matrix.api-level }} 87 target: ${{ matrix.target }} 88 arch: ${{ matrix.arch }} 89 script: | 90 touch emulator.log # create log file 91 chmod 777 emulator.log # allow writing to log file 92 adb logcat >> emulator.log & # pipe all logcat messages into log file as a background process 93 ./gradlew leakcanary-android-core:connectedCheck leakcanary-android:connectedCheck leakcanary-android-instrumentation:connectedCheck --no-build-cache --no-daemon --stacktrace 94 - name: Upload results 95 if: ${{ always() }} 96 uses: actions/upload-artifact@v3 97 with: 98 name: ${{ matrix.api-level }}-${{ matrix.arch }}-instrumentation-test-results 99 path: | 100 emulator.log 101 ./**/build/reports/androidTests/connected/** 102 103 snapshot-deployment: 104 if: github.repository == 'square/leakcanary' && github.event_name == 'push' 105 needs: [ checks, instrumentation-tests ] 106 runs-on: ubuntu-latest 107 steps: 108 - uses: actions/checkout@v3 109 - uses: actions/setup-java@v3 110 with: 111 java-version: 8 112 distribution: 'zulu' 113 - uses: gradle/gradle-build-action@v2 114 - name: Deploy snapshot 115 run: ./gradlew publish 116 env: 117 ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }} 118 ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} 119 - name: Cleanup secrets 120 if: always() 121 run: rm -rf ~/.gradle/gradle.properties 122