From 90c72ec01376023f8ed0c306e725c1e1f7edcb46 Mon Sep 17 00:00:00 2001 From: Ricki Hirner Date: Fri, 17 Nov 2023 15:14:04 +0100 Subject: [PATCH] Cache app/build to speed up builds --- .github/workflows/codeql.yml | 8 ++++++++ .github/workflows/test-dev.yml | 36 ++++++++++++++++++++++++++++++++++ gradle.properties | 10 ++++++---- 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 82594423..0f3124fa 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -35,6 +35,14 @@ jobs: java-version: 17 - uses: gradle/gradle-build-action@v2 + - name: Use app/build and gradle configuration cache + uses: actions/cache/restore@v3 + with: + key: app_build-tests-without-emulator + path: | + .gradle/configuration-cache + app/build + # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v2 diff --git a/.github/workflows/test-dev.yml b/.github/workflows/test-dev.yml index 7aa25df8..decedc84 100644 --- a/.github/workflows/test-dev.yml +++ b/.github/workflows/test-dev.yml @@ -16,6 +16,15 @@ jobs: java-version: 17 - uses: gradle/gradle-build-action@v2 + - name: Use app/build and gradle configuration cache + if: ${{ github.ref != 'refs/heads/dev-ose' }} + uses: actions/cache/restore@v3 + with: + key: app_build-tests-without-emulator + path: | + .gradle/configuration-cache + app/build + - name: Run lint and unit tests run: ./gradlew app:check - name: Archive results @@ -26,6 +35,15 @@ jobs: app/build/outputs/lint* app/build/reports + - name: Cache app/build and gradle configuration + if: ${{ github.ref == 'refs/heads/dev-ose' }} + uses: actions/cache/save@v3 + with: + key: app_build-tests-without-emulator + path: | + .gradle/configuration-cache + app/build + test_on_emulator: name: Tests with emulator runs-on: ubuntu-latest-4-cores @@ -40,6 +58,15 @@ jobs: java-version: 17 - uses: gradle/gradle-build-action@v2 + - name: Use app/build and gradle configuration cache + if: ${{ github.ref != 'refs/heads/dev-ose' }} + uses: actions/cache/restore@v3 + with: + key: app_build-tests-with-emulator + path: | + .gradle/configuration-cache + app/build + - name: Enable KVM group perms run: | echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules @@ -76,6 +103,15 @@ jobs: disable-animations: true script: ./gradlew app:connectedCheck + - name: Cache app/build and gradle configuration + if: ${{ github.ref == 'refs/heads/dev-ose' }} + uses: actions/cache/save@v3 + with: + key: app_build-tests-with-emulator + path: | + .gradle/configuration-cache + app/build + - name: Archive results if: always() uses: actions/upload-artifact@v2 diff --git a/gradle.properties b/gradle.properties index bc2da09e..06a66e71 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,11 +1,13 @@ -# [https://developer.android.com/build/optimize-your-build#optimize] +# https://developer.android.com/build/optimize-your-build org.gradle.daemon=true org.gradle.jvmargs=-Xmx4g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=512m org.gradle.parallel=true -# configuration cache [https://developer.android.com/build/optimize-your-build#use-the-configuration-cache-experimental] -org.gradle.unsafe.configuration-cache=true -org.gradle.unsafe.configuration-cache-problems=warn +org.gradle.configuration-cache=true +org.gradle.configuration-cache.problems=warn + +# https://docs.gradle.org/current/userguide/build_cache.html +org.gradle.caching=true # Android android.useAndroidX=true