Some checks are pending
Verify generated outputs / check (push) Waiting to run
Test different action inputs / action-inputs (push) Waiting to run
Test caching / seed-build (macos-latest) (push) Waiting to run
Test caching / seed-build (ubuntu-latest) (push) Waiting to run
Test caching / seed-build (windows-latest) (push) Waiting to run
Test caching / dependencies-cache (macos-latest) (push) Blocked by required conditions
Test caching / dependencies-cache (ubuntu-latest) (push) Blocked by required conditions
Test caching / dependencies-cache (windows-latest) (push) Blocked by required conditions
Test caching / build-cache (macos-latest) (push) Blocked by required conditions
Test caching / build-cache (ubuntu-latest) (push) Blocked by required conditions
Test caching / build-cache (windows-latest) (push) Blocked by required conditions
Test caching / configuration-cache (macos-latest) (push) Blocked by required conditions
Test caching / configuration-cache (ubuntu-latest) (push) Blocked by required conditions
Test caching / configuration-cache (windows-latest) (push) Blocked by required conditions
Test caching / no-bundles-restored (push) Blocked by required conditions
Test Gradle execution / gradle-execution (macos-latest) (push) Waiting to run
Test Gradle execution / gradle-execution (ubuntu-latest) (push) Waiting to run
Test Gradle execution / gradle-execution (windows-latest, .bat) (push) Waiting to run
Test Gradle execution / gradle-versions (macos-latest) (push) Waiting to run
Test Gradle execution / gradle-versions (ubuntu-latest) (push) Waiting to run
Test Gradle execution / gradle-versions (windows-latest, .bat) (push) Waiting to run
Test caching with a custom GRADLE_USER_HOME / seed-build (push) Waiting to run
Test caching with a custom GRADLE_USER_HOME / dependencies-cache (push) Blocked by required conditions
Test caching with a custom GRADLE_USER_HOME / build-cache (push) Blocked by required conditions
Test caching with Kotlin DSL / seed-build (push) Waiting to run
Test caching with Kotlin DSL / verify-build (push) Blocked by required conditions
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import {GradleUserHomeCache} from './cache-gradle-user-home'
|
|
import {ProjectDotGradleCache} from './cache-project-dot-gradle'
|
|
import * as core from '@actions/core'
|
|
import {isCacheDisabled, isCacheReadOnly} from './cache-utils'
|
|
|
|
const BUILD_ROOT_DIR = 'BUILD_ROOT_DIR'
|
|
|
|
export async function restore(buildRootDirectory: string): Promise<void> {
|
|
if (isCacheDisabled()) {
|
|
core.info(
|
|
'Cache is disabled: will not restore state from previous builds.'
|
|
)
|
|
return
|
|
}
|
|
|
|
await core.group('Restore Gradle state from cache', async () => {
|
|
core.saveState(BUILD_ROOT_DIR, buildRootDirectory)
|
|
return Promise.all([
|
|
new GradleUserHomeCache(buildRootDirectory).restore(),
|
|
new ProjectDotGradleCache(buildRootDirectory).restore()
|
|
])
|
|
})
|
|
}
|
|
|
|
export async function save(): Promise<void> {
|
|
if (isCacheReadOnly()) {
|
|
core.info(
|
|
'Cache is read-only: will not save state for use in subsequent builds.'
|
|
)
|
|
return
|
|
}
|
|
|
|
await core.group('Caching Gradle state', async () => {
|
|
const buildRootDirectory = core.getState(BUILD_ROOT_DIR)
|
|
return Promise.all([
|
|
new GradleUserHomeCache(buildRootDirectory).save(),
|
|
new ProjectDotGradleCache(buildRootDirectory).save()
|
|
])
|
|
})
|
|
}
|