From 763bc0e3096d1f1b1d618b334a368b98b7db5258 Mon Sep 17 00:00:00 2001 From: Goooler Date: Tue, 1 Mar 2022 21:58:37 +0800 Subject: [PATCH 1/4] Use gradle-build-action on CI --- .github/workflows/ci.yml | 51 ++++++++++------------------------- .github/workflows/release.yml | 10 +++---- 2 files changed, 17 insertions(+), 44 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 36e201c83..31d0f31ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,16 +35,12 @@ jobs: with: distribution: 'zulu' java-version: 17 - - uses: actions/cache@v2 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/**.gradle', '**/**.gradle.kts', '**/gradle/wrapper/gradle-wrapper.properties', '**/buildSrc/src/main/kotlin/**.kt') }} - name: Validate Gradle Wrapper uses: gradle/wrapper-validation-action@v1 - name: Check style - run: ./gradlew ktlintCheck + uses: gradle/gradle-build-action@v2 + with: + arguments: ktlintCheck unit-tests: name: Unit tests @@ -56,14 +52,10 @@ jobs: with: distribution: 'zulu' java-version: 17 - - uses: actions/cache@v2 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/**.gradle', '**/**.gradle.kts', '**/gradle/wrapper/gradle-wrapper.properties', '**/buildSrc/src/main/kotlin/**.kt') }} - name: Unit tests - run: ./gradlew test + uses: gradle/gradle-build-action@v2 + with: + arguments: test instrumentation-tests: name: Instrumentation tests @@ -79,20 +71,6 @@ jobs: with: distribution: 'zulu' java-version: 17 - - uses: actions/cache@v2 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/**.gradle', '**/**.gradle.kts', '**/gradle/wrapper/gradle-wrapper.properties', '**/buildSrc/src/main/kotlin/**.kt') }} - - name: AVD cache - uses: actions/cache@v2 - id: avd-cache - with: - path: | - ~/.android/avd/* - ~/.android/adb* - key: avd-${{ matrix.api-level }} - name: Create AVD and generate snapshot for caching if: steps.avd-cache.outputs.cache-hit != 'true' uses: reactivecircus/android-emulator-runner@v2 @@ -102,14 +80,17 @@ jobs: emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: false script: echo "Generated AVD snapshot for caching." - - name: Instrumentation tests + - name: Prepare instrumentation uses: reactivecircus/android-emulator-runner@v2 with: api-level: ${{ matrix.api-level }} force-avd-creation: false emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: true - script: ./gradlew connectedDebugAndroidTest + - name: Instrumentation tests + uses: gradle/gradle-build-action@v2 + with: + arguments: connectedDebugAndroidTest build: name: Build @@ -123,14 +104,10 @@ jobs: with: distribution: 'zulu' java-version: 17 - - uses: actions/cache@v2 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/**.gradle', '**/**.gradle.kts', '**/gradle/wrapper/gradle-wrapper.properties', '**/buildSrc/src/main/kotlin/**.kt') }} - name: Build - run: ./gradlew app:assemble + uses: gradle/gradle-build-action@v2 + with: + arguments: app:assemble - uses: actions/upload-artifact@v2 if: matrix.os == 'ubuntu-latest' with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e211a2869..9f87d45de 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,14 +15,10 @@ jobs: with: distribution: 'zulu' java-version: 17 - - uses: actions/cache@v2 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/**.gradle', '**/**.gradle.kts', '**/gradle/wrapper/gradle-wrapper.properties', '**/buildSrc/src/main/kotlin/**.kt') }} - name: Build APK - run: ./gradlew app:assembleProdRelease + uses: gradle/gradle-build-action@v2 + with: + arguments: app:assembleProdRelease - name: Create Release uses: ncipollo/release-action@v1 with: From 8f12d64002a0b3b7f70c30fcda6793eda526cde1 Mon Sep 17 00:00:00 2001 From: Goooler Date: Tue, 1 Mar 2022 22:45:23 +0800 Subject: [PATCH 2/4] Use gradle-build-action before android-emulator-runner --- .github/workflows/ci.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 31d0f31ac..69f8ab443 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,6 +71,7 @@ jobs: with: distribution: 'zulu' java-version: 17 + - uses: gradle/gradle-build-action@v2 - name: Create AVD and generate snapshot for caching if: steps.avd-cache.outputs.cache-hit != 'true' uses: reactivecircus/android-emulator-runner@v2 @@ -80,17 +81,14 @@ jobs: emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: false script: echo "Generated AVD snapshot for caching." - - name: Prepare instrumentation + - name: Instrumentation tests uses: reactivecircus/android-emulator-runner@v2 with: api-level: ${{ matrix.api-level }} force-avd-creation: false emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: true - - name: Instrumentation tests - uses: gradle/gradle-build-action@v2 - with: - arguments: connectedDebugAndroidTest + script: ./gradlew connectedDebugAndroidTest build: name: Build From 8596626b94d4c4596cb7ca2cb0ecabb46daa8105 Mon Sep 17 00:00:00 2001 From: Goooler Date: Tue, 1 Mar 2022 22:54:46 +0800 Subject: [PATCH 3/4] Add avd-cache id --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 69f8ab443..1d401d72f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,6 +72,7 @@ jobs: distribution: 'zulu' java-version: 17 - uses: gradle/gradle-build-action@v2 + id: avd-cache - name: Create AVD and generate snapshot for caching if: steps.avd-cache.outputs.cache-hit != 'true' uses: reactivecircus/android-emulator-runner@v2 From fcc0cad39f4166fa6a7196c3ed8a0ee50ecca28b Mon Sep 17 00:00:00 2001 From: Goooler Date: Tue, 1 Mar 2022 23:05:17 +0800 Subject: [PATCH 4/4] Add AVD cache back --- .github/workflows/ci.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d401d72f..9fd93cd6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,8 +71,16 @@ jobs: with: distribution: 'zulu' java-version: 17 - - uses: gradle/gradle-build-action@v2 + - name: Gradle cache + uses: gradle/gradle-build-action@v2 + - name: AVD cache + uses: actions/cache@v2 id: avd-cache + with: + path: | + ~/.android/avd/* + ~/.android/adb* + key: avd-${{ matrix.api-level }} - name: Create AVD and generate snapshot for caching if: steps.avd-cache.outputs.cache-hit != 'true' uses: reactivecircus/android-emulator-runner@v2