Skip to content
This repository was archived by the owner on Feb 5, 2021. It is now read-only.

Commit 28479e6

Browse files
Fix gradle cache in CI.
Most of the tests in this repo are UI tests, so it would be really nice to not build the entire codebase twice to start running them. I decreased the timeout as well since test shards no longer need to re-build.
1 parent fc180e3 commit 28479e6

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

.github/workflows/kotlin.yml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ on:
66
pull_request:
77

88
env:
9-
# Must use $HOME here, NOT a tilde, because of the order in which bash does expansion:
10-
# Tilde happens before variables, so will be used literally, whereas $HOME will be
11-
# recursively expanded.
12-
GRADLE_CACHE_PATH: $HOME/.gradle/caches
9+
GRADLE_HOME: ${{ github.workspace }}/gradle-home
1310

1411
jobs:
1512
assemble:
@@ -29,7 +26,7 @@ jobs:
2926
- name: Cache gradle dependencies
3027
uses: actions/cache@v1
3128
with:
32-
path: ${{ env.GRADLE_CACHE_PATH }}
29+
path: ${{ env.GRADLE_HOME }}/caches
3330
# Include the SHA in the hash so this step always adds a cache entry. If we didn't use the SHA, the artifacts
3431
# would only get cached once for each build config hash.
3532
# Don't use ${{ runner.os }} in the key so we don't re-assemble for UI tests.
@@ -47,13 +44,13 @@ jobs:
4744
# and there's no way to modify the cache after the job that created it finishes.
4845
- name: Clean gradle build cache to assemble fresh
4946
run: |
50-
ls -lhrt $GRADLE_CACHE_PATH || true
51-
rm -rf $GRADLE_CACHE_PATH/build-cache-1
52-
ls -lhrt $GRADLE_CACHE_PATH || true
47+
ls -lhrt "$GRADLE_HOME/caches" || true
48+
rm -rf "$GRADLE_HOME/caches/build-cache-1"
49+
ls -lhrt "$GRADLE_HOME/caches" || true
5350
5451
## Actual task
5552
- name: Assemble with gradle
56-
run: ./gradlew assemble --build-cache --no-daemon --stacktrace
53+
run: ./gradlew assemble --build-cache --no-daemon --stacktrace --gradle-user-home "$GRADLE_HOME"
5754

5855
# Runs all check tasks in parallel.
5956
check:
@@ -84,20 +81,20 @@ jobs:
8481
- name: Cache build artifacts
8582
uses: actions/cache@v1
8683
with:
87-
path: ${{ env.GRADLE_CACHE_PATH }}
84+
path: ${{ env.GRADLE_HOME }}/caches
8885
# Don't set restore-keys so cache is always only valid for the current build config.
8986
# Also don't use ${{ runner.os }} in the key so we don't re-assemble for UI tests.
9087
key: gradle-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/buildSrc/**') }}-${{ github.sha }}
9188

9289
## Actual task
9390
- name: Check with Gradle
94-
run: ./gradlew ${{ matrix.gradle-task }} --build-cache --no-daemon --stacktrace
91+
run: ./gradlew ${{ matrix.gradle-task }} --build-cache --no-daemon --stacktrace --gradle-user-home "$GRADLE_HOME"
9592

9693
instrumentation-tests:
9794
name: Instrumentation tests
9895
needs: assemble
9996
runs-on: macos-latest
100-
timeout-minutes: 20
97+
timeout-minutes: 15
10198
strategy:
10299
# Allow tests to continue on other devices if they fail on one device.
103100
fail-fast: false
@@ -119,7 +116,7 @@ jobs:
119116
- name: Cache build artifacts
120117
uses: actions/cache@v1
121118
with:
122-
path: ${{ env.GRADLE_CACHE_PATH }}
119+
path: ${{ env.GRADLE_HOME }}/caches
123120
# Don't set restore-keys so cache is always only valid for the current build config.
124121
# Also don't use ${{ runner.os }} in the key so we don't re-assemble for UI tests.
125122
key: gradle-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/buildSrc/**') }}-${{ github.sha }}
@@ -130,4 +127,4 @@ jobs:
130127
with:
131128
api-level: ${{ matrix.api-level }}
132129
arch: x86_64
133-
script: ./gradlew connectedCheck --build-cache --no-daemon --stacktrace
130+
script: ./gradlew connectedCheck --build-cache --no-daemon --stacktrace --gradle-user-home "$GRADLE_HOME"

0 commit comments

Comments
 (0)