Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Always set the GRADLE_USER_HOME env var #300

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/integ-test-cache-cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,20 @@ jobs:
cache-read-only: true
- name: Report Gradle User Home
run: |
du -hc ~/.gradle/caches/modules-2
du -hc ~/.gradle/wrapper/dists
du -hc $GRADLE_USER_HOME/caches/modules-2
du -hc $GRADLE_USER_HOME/wrapper/dists
- name: Verify cleaned cache
shell: bash
run: |
if [ ! -e ~/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-math3/3.1.1 ]; then
if [ ! -e $GRADLE_USER_HOME/caches/modules-2/files-2.1/org.apache.commons/commons-math3/3.1.1 ]; then
echo "::error ::Should find commons-math3 3.1.1 in cache"
exit 1
fi
if [ -e ~/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-math3/3.1 ]; then
if [ -e $GRADLE_USER_HOME/caches/modules-2/files-2.1/org.apache.commons/commons-math3/3.1 ]; then
echo "::error ::Should NOT find commons-math3 3.1 in cache"
exit 1
fi
if [ ! -e ~/.gradle/wrapper/dists/gradle-8.0.2-bin ]; then
if [ ! -e $GRADLE_USER_HOME/wrapper/dists/gradle-8.0.2-bin ]; then
echo "::error ::Should find gradle-8.0.2 in wrapper/dists"
exit 1
fi
2 changes: 1 addition & 1 deletion docs/setup-gradle.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ cache-cleanup: 'on-success' # Valid values are 'never' (default), 'on-success' a

### Overwriting an existing Gradle User Home

When the action detects that the Gradle User Home caches directory already exists (`~/.gradle/caches`), then by default it will not overwrite the existing content of this directory.
When the action detects that the Gradle User Home caches directory already exists (`$GRADLE_USER_HOME/caches`), then by default it will not overwrite the existing content of this directory.
This can occur when a prior action initializes this directory, or when using a self-hosted runner that retains this directory between uses.

In this case, the Job Summary will display a message like:
Expand Down
2 changes: 2 additions & 0 deletions sources/src/setup-gradle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ async function determineGradleUserHome(): Promise<string> {
// Use the default Gradle User Home if it already exists
if (fs.existsSync(defaultGradleUserHome)) {
core.info(`Gradle User Home already exists at ${defaultGradleUserHome}`)
core.exportVariable('GRADLE_USER_HOME', defaultGradleUserHome)
return defaultGradleUserHome
}

Expand All @@ -95,6 +96,7 @@ async function determineGradleUserHome(): Promise<string> {
return fasterGradleUserHome
}

core.exportVariable('GRADLE_USER_HOME', defaultGradleUserHome)
return defaultGradleUserHome
}

Expand Down
Loading