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

Commit 914cd52

Browse files
Fix gradle cache in CI.
1 parent fc180e3 commit 914cd52

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

.github/workflows/kotlin.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ env:
99
# Must use $HOME here, NOT a tilde, because of the order in which bash does expansion:
1010
# Tilde happens before variables, so will be used literally, whereas $HOME will be
1111
# recursively expanded.
12-
GRADLE_CACHE_PATH: $HOME/.gradle/caches
12+
GRADLE_HOME: ${{ runner.temp }}/gradle-home
1313

1414
jobs:
1515
assemble:
@@ -29,7 +29,7 @@ jobs:
2929
- name: Cache gradle dependencies
3030
uses: actions/cache@v1
3131
with:
32-
path: ${{ env.GRADLE_CACHE_PATH }}
32+
path: ${{ env.GRADLE_HOME }}/caches
3333
# Include the SHA in the hash so this step always adds a cache entry. If we didn't use the SHA, the artifacts
3434
# would only get cached once for each build config hash.
3535
# Don't use ${{ runner.os }} in the key so we don't re-assemble for UI tests.
@@ -47,13 +47,13 @@ jobs:
4747
# and there's no way to modify the cache after the job that created it finishes.
4848
- name: Clean gradle build cache to assemble fresh
4949
run: |
50-
ls -lhrt $GRADLE_CACHE_PATH || true
51-
rm -rf $GRADLE_CACHE_PATH/build-cache-1
52-
ls -lhrt $GRADLE_CACHE_PATH || true
50+
ls -lhrt "$GRADLE_HOME/caches" || true
51+
rm -rf "$GRADLE_HOME/caches/build-cache-1"
52+
ls -lhrt "$GRADLE_HOME/caches" || true
5353
5454
## Actual task
5555
- name: Assemble with gradle
56-
run: ./gradlew assemble --build-cache --no-daemon --stacktrace
56+
run: ./gradlew assemble --build-cache --no-daemon --stacktrace --gradle-user-home "$GRADLE_HOME"
5757

5858
# Runs all check tasks in parallel.
5959
check:
@@ -84,14 +84,14 @@ jobs:
8484
- name: Cache build artifacts
8585
uses: actions/cache@v1
8686
with:
87-
path: ${{ env.GRADLE_CACHE_PATH }}
87+
path: ${{ env.GRADLE_HOME }}/caches
8888
# Don't set restore-keys so cache is always only valid for the current build config.
8989
# Also don't use ${{ runner.os }} in the key so we don't re-assemble for UI tests.
9090
key: gradle-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/buildSrc/**') }}-${{ github.sha }}
9191

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

9696
instrumentation-tests:
9797
name: Instrumentation tests
@@ -119,7 +119,7 @@ jobs:
119119
- name: Cache build artifacts
120120
uses: actions/cache@v1
121121
with:
122-
path: ${{ env.GRADLE_CACHE_PATH }}
122+
path: ${{ env.GRADLE_HOME }}/caches
123123
# Don't set restore-keys so cache is always only valid for the current build config.
124124
# Also don't use ${{ runner.os }} in the key so we don't re-assemble for UI tests.
125125
key: gradle-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/buildSrc/**') }}-${{ github.sha }}
@@ -130,4 +130,4 @@ jobs:
130130
with:
131131
api-level: ${{ matrix.api-level }}
132132
arch: x86_64
133-
script: ./gradlew connectedCheck --build-cache --no-daemon --stacktrace
133+
script: ./gradlew connectedCheck --build-cache --no-daemon --stacktrace --gradle-user-home "$GRADLE_HOME"

0 commit comments

Comments
 (0)