diff --git a/.github/actions/restore-cache/action.yml b/.github/actions/restore-cache/action.yml new file mode 100644 index 00000000..eac03ed9 --- /dev/null +++ b/.github/actions/restore-cache/action.yml @@ -0,0 +1,46 @@ +name: Restore Gradle Cache + +runs: + using: composite + steps: + - name: Restore Dependencies Cache + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: | + ~/.gradle/caches/modules-2/files-2.1/ + ~/.gradle/caches/modules-2/metadata-2.107/ + key: gradle-dependencies-${{ runner.os }}-${{ hashFiles('**/*.gradle*', 'gradle/*.versions.toml') }} + restore-keys: | + gradle-dependencies-${{ runner.os }}- + - name: Restore Gradle Kotlin DSL Cache + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: | + ~/.gradle/caches/*/kotlin-dsl + key: gradle-kotlin-dsl-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }} + restore-keys: | + gradle-kotlin-dsl-${{ runner.os }}- + - name: Restore Gradle Transforms Cache + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: | + ~/.gradle/caches/*/transforms + key: gradle-transforms-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }} + restore-keys: | + gradle-transforms-${{ runner.os }}- + - name: Restore Gradle Generated JARs Cache + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: | + ~/.gradle/caches/*/generated-gradle-jars + key: gradle-generated-gradle-jars-${{ runner.os }}-${{ hashFiles('**/gradle-wrapper.properties') }} + restore-keys: | + gradle-generated-gradle-jars-${{ runner.os }}- + - name: Restore Gradle Wrapper Cache + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: | + ~/.gradle/wrapper + key: gradle-wrapper-${{ runner.os }}-${{ hashFiles('**/gradle-wrapper.properties') }} + restore-keys: | + gradle-wrapper-${{ runner.os }}- diff --git a/.github/actions/save-cache/action.yml b/.github/actions/save-cache/action.yml new file mode 100644 index 00000000..b2bbdfb3 --- /dev/null +++ b/.github/actions/save-cache/action.yml @@ -0,0 +1,36 @@ +name: Save Gradle Cache + +runs: + using: composite + steps: + - name: Save Dependencies Cache + uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: | + ~/.gradle/caches/modules-2/files-2.1/ + ~/.gradle/caches/modules-2/metadata-2.107/ + key: gradle-dependencies-${{ runner.os }}-${{ hashFiles('**/*.gradle*', 'gradle/*.versions.toml') }} + - name: Save Gradle Kotlin DSL Cache + uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: | + ~/.gradle/caches/*/kotlin-dsl + key: gradle-kotlin-dsl-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }} + - name: Save Gradle Transforms Cache + uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: | + ~/.gradle/caches/*/transforms + key: gradle-transforms-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }} + - name: Save Gradle Generated JARs Cache + uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: | + ~/.gradle/caches/*/generated-gradle-jars + key: gradle-generated-gradle-jars-${{ runner.os }}-${{ hashFiles('**/gradle-wrapper.properties') }} + - name: Save Gradle Wrapper Cache + uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: | + ~/.gradle/wrapper + key: gradle-wrapper-${{ runner.os }}-${{ hashFiles('**/gradle-wrapper.properties') }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3f10490d..75268750 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,14 +55,7 @@ jobs: - name: Validate Gradle Wrapper uses: gradle/actions/wrapper-validation@3f131e8634966bd73d06cc69884922b02e6faf92 # v6.2.0 - name: Restore Cache - uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- + uses: ./.github/actions/restore-cache - name: Export AboutLibraries library definitions # Used to run only once if: matrix.variant == 'debug' @@ -100,10 +93,5 @@ jobs: if: ${{ matrix.variant == 'release' }} run: ./gradlew :android-app:assembleRelease $CI_GRADLE_ARG_PROPERTIES - name: Save Cache - uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + uses: ./.github/actions/save-cache if: github.event_name != 'pull_request' - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} diff --git a/.github/workflows/codestyle.yml b/.github/workflows/codestyle.yml index 0aa23ffd..ba6e0baa 100644 --- a/.github/workflows/codestyle.yml +++ b/.github/workflows/codestyle.yml @@ -50,14 +50,7 @@ jobs: - name: Validate Gradle Wrapper uses: gradle/actions/wrapper-validation@3f131e8634966bd73d06cc69884922b02e6faf92 # v6.2.0 - name: Restore Cache - uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- + uses: ./.github/actions/restore-cache - name: Run Debug Android Lints run: ./gradlew lintDebug $CI_GRADLE_ARG_PROPERTIES --continue - name: Upload reports @@ -67,13 +60,8 @@ jobs: path: | **/build/reports/**/*.* - name: Save Cache - uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + uses: ./.github/actions/save-cache if: github.event_name != 'pull_request' - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} detekt: name: Detekt @@ -107,14 +95,7 @@ jobs: - name: Validate Gradle Wrapper uses: gradle/actions/wrapper-validation@3f131e8634966bd73d06cc69884922b02e6faf92 # v6.2.0 - name: Restore Cache - uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- + uses: ./.github/actions/restore-cache - name: Run Detekt run: ./gradlew detekt $CI_GRADLE_ARG_PROPERTIES - name: Upload reports @@ -124,13 +105,8 @@ jobs: path: | **/build/reports/**/*.* - name: Save Cache - uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + uses: ./.github/actions/save-cache if: github.event_name != 'pull_request' - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} # Only run codestyle report comments on PRs from this repository instead of a fork # Fork PRs should check for the run result instead diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e829ac13..19a693b2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,25 +48,13 @@ jobs: distribution: 'temurin' java-version: '21' - name: Restore Cache - uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- + uses: ./.github/actions/restore-cache - name: Run all tests # -Pandroid.enableBuildConfigAsBytecode=false due to https://issuetracker.google.com/issues/363031540 run: ./gradlew allTests :koverXmlReport -Pandroid.enableBuildConfigAsBytecode=false $CI_GRADLE_ARG_PROPERTIES - name: Save Cache - uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + uses: ./.github/actions/save-cache if: github.event_name != 'pull_request' - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - name: Codecov uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0 with: