mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-12-25 14:06:18 +08:00
parent
884bca012f
commit
6965e8ed4c
@ -1,6 +1,7 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import {isCacheDisabled, isCacheReadOnly, isCacheWriteOnly} from './cache-utils'
|
import {isCacheDisabled, isCacheReadOnly, isCacheWriteOnly} from './cache-utils'
|
||||||
import {CacheListener} from './cache-reporting'
|
import {CacheListener} from './cache-reporting'
|
||||||
|
import {DaemonController} from './daemon-controller'
|
||||||
import {GradleStateCache} from './cache-base'
|
import {GradleStateCache} from './cache-base'
|
||||||
|
|
||||||
const CACHE_RESTORED_VAR = 'GRADLE_BUILD_ACTION_CACHE_RESTORED'
|
const CACHE_RESTORED_VAR = 'GRADLE_BUILD_ACTION_CACHE_RESTORED'
|
||||||
@ -45,7 +46,11 @@ export async function restore(gradleUserHome: string, cacheListener: CacheListen
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function save(gradleUserHome: string, cacheListener: CacheListener): Promise<void> {
|
export async function save(
|
||||||
|
gradleUserHome: string,
|
||||||
|
cacheListener: CacheListener,
|
||||||
|
daemonController: DaemonController
|
||||||
|
): Promise<void> {
|
||||||
if (isCacheDisabled()) {
|
if (isCacheDisabled()) {
|
||||||
core.info('Cache is disabled: will not save state for later builds.')
|
core.info('Cache is disabled: will not save state for later builds.')
|
||||||
return
|
return
|
||||||
@ -62,6 +67,8 @@ export async function save(gradleUserHome: string, cacheListener: CacheListener)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await daemonController.stopAllDaemons()
|
||||||
|
|
||||||
await core.group('Caching Gradle state', async () => {
|
await core.group('Caching Gradle state', async () => {
|
||||||
return new GradleStateCache(gradleUserHome).save(cacheListener)
|
return new GradleStateCache(gradleUserHome).save(cacheListener)
|
||||||
})
|
})
|
||||||
|
@ -13,7 +13,7 @@ export class DaemonController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async stopAllDaemons(): Promise<void> {
|
async stopAllDaemons(): Promise<void> {
|
||||||
core.info('Stopping all Gradle daemons')
|
core.info('Stopping all Gradle daemons before saving Gradle User Home state')
|
||||||
|
|
||||||
const executions: Promise<number>[] = []
|
const executions: Promise<number>[] = []
|
||||||
const args = ['--stop']
|
const args = ['--stop']
|
||||||
|
@ -59,8 +59,7 @@ export async function complete(): Promise<void> {
|
|||||||
const cacheListener: CacheListener = CacheListener.rehydrate(core.getState(CACHE_LISTENER))
|
const cacheListener: CacheListener = CacheListener.rehydrate(core.getState(CACHE_LISTENER))
|
||||||
const daemonController = new DaemonController(buildResults)
|
const daemonController = new DaemonController(buildResults)
|
||||||
|
|
||||||
await daemonController.stopAllDaemons()
|
await caches.save(gradleUserHome, cacheListener, daemonController)
|
||||||
await caches.save(gradleUserHome, cacheListener)
|
|
||||||
|
|
||||||
if (shouldGenerateJobSummary()) {
|
if (shouldGenerateJobSummary()) {
|
||||||
await writeJobSummary(buildResults, cacheListener)
|
await writeJobSummary(buildResults, cacheListener)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user