diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c00526ab..587ee5a08 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: distribution: 'zulu' java-version: '17' - name: 'Cache Bazel files' - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.cache/bazel key: ${{ runner.os }}-${{ env.cache-version }}-bazel-build-${{ github.sha }} @@ -75,7 +75,7 @@ jobs: distribution: 'zulu' java-version: '17' - name: 'Cache Bazel files' - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.cache/bazel key: ${{ runner.os }}-${{ env.cache-version }}-bazel-test-${{ github.sha }} @@ -110,9 +110,31 @@ jobs: run: | echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules sudo udevadm control --reload-rules - sudo udevadm trigger --name-match=kvm + sudo udevadm trigger --name-match=kvm + - name: Set ANDROID_USER_HOME + run: echo "ANDROID_USER_HOME=$HOME/.android" >> $GITHUB_ENV - name: 'Cache Gradle files' uses: gradle/gradle-build-action@v2 + # Saving the GMD snapshot to cache is expensive + # Theoretically we only need to update the cache if the snapshot is changed, + # which should only happen if emulator version or system image has changed. + # As a workaround, encorporate the year and week to the cache key, so + # the snapshot cache gets regenerated every week + # http://man7.org/linux/man-pages/man1/date.1.html + - name: Get Date + id: get-date + run: | + echo "date=$(/bin/date -u "+%Y%U")" >> $GITHUB_OUTPUT + shell: bash + - name: 'Cache GMD snapshot' + uses: actions/cache@v4 + with: + path: | + ~/.android/avd/gradle-managed/* + ~/.android/adb* + # use combination of date (to cover case where emulator or system image version changed) and + # hash of top-level build.gradle (to cover case where AGP or android API level changed) + key: ${{ runner.os }}-${{ env.cache-version }}-gmd-${{ steps.get-date.outputs.date }}-${{ hashFiles('gradle-tests/build.gradle') }} - name: 'Download local snapshot for tests' uses: actions/download-artifact@v4 with: @@ -137,4 +159,3 @@ jobs: name: test-reports path: gradle-tests/**/build/reports/androidTests/ -