Use monolithic cache for Gradle User Home

- Do not restore cache when GUH exists
- Include RUNNER_OS in the cache key
- Do not save cache on exact hit
- Only save cache in the final post action
- Log before saving cache
This commit is contained in:
Daz DeBoer 2021-08-22 20:14:47 -06:00
parent b3afdc78a7
commit c211be411e
No known key found for this signature in database
GPG key ID: DD6B9F0B06683D5D
7 changed files with 247 additions and 22 deletions

View file

@ -2,13 +2,15 @@ import * as core from '@actions/core'
import * as path from 'path'
import {parseArgsStringToArgv} from 'string-argv'
import * as cacheWrapper from './cache-wrapper'
import * as cacheGradleUserHome from './cache-gradle-user-home'
import * as execution from './execution'
import * as gradlew from './gradlew'
import * as provision from './provision'
// Invoked by GitHub Actions
export async function run(): Promise<void> {
await cacheGradleUserHome.restore()
try {
const workspaceDirectory = process.env[`GITHUB_WORKSPACE`] || ''
const buildRootDirectory = resolveBuildRootDirectory(workspaceDirectory)
@ -47,11 +49,6 @@ async function resolveGradleExecutable(
const gradleExecutable = core.getInput('gradle-executable')
if (gradleExecutable !== '') {
if (gradleExecutable.endsWith(gradlew.wrapperFilename())) {
await cacheWrapper.restoreCachedWrapperDist(
path.resolve(gradleExecutable, '..')
)
}
return path.resolve(workspaceDirectory, gradleExecutable)
}
@ -62,8 +59,6 @@ async function resolveGradleExecutable(
: buildRootDirectory
gradlew.validateGradleWrapper(gradlewDirectory)
await cacheWrapper.restoreCachedWrapperDist(gradlewDirectory)
return path.resolve(gradlewDirectory, gradlew.wrapperFilename())
}