Loading sources/src/caching/cache-cleaner.ts +22 −5 Changes for sources/src/caching/cache-cleaner.ts: 22 added lines, 5 removed lines. Original line number Diff line number Diff line import * as core from '@actions/core' import * as exec from '@actions/exec' import fs from 'fs' import path from 'path' import {provisionAndMaybeExecute} from '../execution/gradle' import * as provisioner from '../execution/provision' export class CacheCleaner { private readonly gradleUserHome: string Loading @@ -24,9 +26,8 @@ export class CacheCleaner { await this.forceCleanupFilesOlderThan(cleanTimestamp) } // Visible for testing async forceCleanupFilesOlderThan(cleanTimestamp: string): Promise<void> { core.info(`Cleaning up caches before ${cleanTimestamp}`) // Run a dummy Gradle build to trigger cache cleanup const cleanupProjectDir = path.resolve(this.tmpDir, 'dummy-cleanup-project') fs.mkdirSync(cleanupProjectDir, {recursive: true}) Loading Loading @@ -54,7 +55,16 @@ export class CacheCleaner { ) fs.writeFileSync(path.resolve(cleanupProjectDir, 'build.gradle'), 'task("noop") {}') await provisionAndMaybeExecute('current', cleanupProjectDir, [ const executable = await provisioner.provisionGradle('current') await core.group('Executing Gradle to clean up caches', async () => { core.info(`Cleaning up caches last used before ${cleanTimestamp}`) await this.executeCleanupBuild(executable!, cleanupProjectDir) }) } private async executeCleanupBuild(executable: string, cleanupProjectDir: string): Promise<void> { const args = [ '-g', this.gradleUserHome, '-I', Loading @@ -65,6 +75,13 @@ export class CacheCleaner { '--build-cache', '-DGITHUB_DEPENDENCY_GRAPH_ENABLED=false', 'noop' ]) ] const result = await exec.getExecOutput(executable, args, { cwd: cleanupProjectDir, silent: true }) core.info(result.stdout) } } sources/src/caching/caches.ts +2 −1 Changes for sources/src/caching/caches.ts: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -92,7 +92,9 @@ export async function save( return } await core.group('Stopping Gradle daemons', async () => { await daemonController.stopAllDaemons() }) if (cacheConfig.isCacheCleanupEnabled()) { if (buildResults.anyConfigCacheHit()) { Loading @@ -113,7 +115,6 @@ export async function save( } async function performCacheCleanup(gradleUserHome: string): Promise<void> { core.info('Forcing cache cleanup.') const cacheCleaner = new CacheCleaner(gradleUserHome, process.env['RUNNER_TEMP']!) try { await cacheCleaner.forceCleanup() Loading sources/src/daemon-controller.ts −2 Changes for sources/src/daemon-controller.ts: 0 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -12,8 +12,6 @@ export class DaemonController { } async stopAllDaemons(): Promise<void> { core.info('Stopping all Gradle daemons before saving Gradle User Home state') const executions: Promise<number>[] = [] const args = ['--stop'] Loading Loading
sources/src/caching/cache-cleaner.ts +22 −5 Changes for sources/src/caching/cache-cleaner.ts: 22 added lines, 5 removed lines. Original line number Diff line number Diff line import * as core from '@actions/core' import * as exec from '@actions/exec' import fs from 'fs' import path from 'path' import {provisionAndMaybeExecute} from '../execution/gradle' import * as provisioner from '../execution/provision' export class CacheCleaner { private readonly gradleUserHome: string Loading @@ -24,9 +26,8 @@ export class CacheCleaner { await this.forceCleanupFilesOlderThan(cleanTimestamp) } // Visible for testing async forceCleanupFilesOlderThan(cleanTimestamp: string): Promise<void> { core.info(`Cleaning up caches before ${cleanTimestamp}`) // Run a dummy Gradle build to trigger cache cleanup const cleanupProjectDir = path.resolve(this.tmpDir, 'dummy-cleanup-project') fs.mkdirSync(cleanupProjectDir, {recursive: true}) Loading Loading @@ -54,7 +55,16 @@ export class CacheCleaner { ) fs.writeFileSync(path.resolve(cleanupProjectDir, 'build.gradle'), 'task("noop") {}') await provisionAndMaybeExecute('current', cleanupProjectDir, [ const executable = await provisioner.provisionGradle('current') await core.group('Executing Gradle to clean up caches', async () => { core.info(`Cleaning up caches last used before ${cleanTimestamp}`) await this.executeCleanupBuild(executable!, cleanupProjectDir) }) } private async executeCleanupBuild(executable: string, cleanupProjectDir: string): Promise<void> { const args = [ '-g', this.gradleUserHome, '-I', Loading @@ -65,6 +75,13 @@ export class CacheCleaner { '--build-cache', '-DGITHUB_DEPENDENCY_GRAPH_ENABLED=false', 'noop' ]) ] const result = await exec.getExecOutput(executable, args, { cwd: cleanupProjectDir, silent: true }) core.info(result.stdout) } }
sources/src/caching/caches.ts +2 −1 Changes for sources/src/caching/caches.ts: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -92,7 +92,9 @@ export async function save( return } await core.group('Stopping Gradle daemons', async () => { await daemonController.stopAllDaemons() }) if (cacheConfig.isCacheCleanupEnabled()) { if (buildResults.anyConfigCacheHit()) { Loading @@ -113,7 +115,6 @@ export async function save( } async function performCacheCleanup(gradleUserHome: string): Promise<void> { core.info('Forcing cache cleanup.') const cacheCleaner = new CacheCleaner(gradleUserHome, process.env['RUNNER_TEMP']!) try { await cacheCleaner.forceCleanup() Loading
sources/src/daemon-controller.ts −2 Changes for sources/src/daemon-controller.ts: 0 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -12,8 +12,6 @@ export class DaemonController { } async stopAllDaemons(): Promise<void> { core.info('Stopping all Gradle daemons before saving Gradle User Home state') const executions: Promise<number>[] = [] const args = ['--stop'] Loading