Files
actions/sources/src/cache-service.ts
T
Daz DeBoer 3283118ee4 Mirror project-cache type and report changes from the caching library
Prepares the consumer for the gated project-entry caching feature in the
gradle-actions-caching library. Source-only; the vendored bundle is refreshed
in a later commit.

- cache-service.ts: add develocityAccessToken / develocityServerUrl to the
  local CacheOptions mirror; replace ConfigurationCacheStatus (4 values) with
  the 9-value ProjectCacheStatus (not-active retired); rename
  CacheReport.configurationCache to projectCache.
- caching-report.ts: PROJECT_CACHE_COPY is an exhaustive
  Record<ProjectCacheStatus, string> so a missed status fails compilation;
  not-enabled maps to '' (dropped by the existing .filter(Boolean)).
  renderConfigCacheLine becomes renderProjectCacheLine, reading
  report.projectCache.
- Tests updated for the renamed field and new copy, including a not-enabled
  case that renders nothing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-13 14:42:39 -06:00

73 lines
1.9 KiB
TypeScript

import {BuildResult} from './build-results'
export interface CacheOptions {
disabled: boolean
readOnly: boolean
writeOnly: boolean
overwriteExisting: boolean
strictMatch: boolean
cleanup: string
encryptionKey?: string
develocityAccessToken?: string
develocityServerUrl?: string
includes: string[]
excludes: string[]
}
export type CacheStatus =
| 'enabled'
| 'read-only'
| 'write-only'
| 'disabled'
| 'disabled-existing-home'
| 'not-available'
export type CacheCleanupStatus =
| 'enabled'
| 'disabled-param'
| 'disabled-failure'
| 'disabled-config-cache-hit'
| 'disabled-readonly'
// Mirrors ProjectCacheStatus in the gradle-actions-caching library. The first three are set on
// restore (ungated); the rest on save, reflecting the opt-in + Develocity trial gate.
export type ProjectCacheStatus =
| 'restore-incomplete'
| 'restored'
| 'not-restored'
| 'not-enabled'
| 'trial-expired'
| 'trial-not-licensed'
| 'not-stored-no-develocity-plugin'
| 'stored'
| 'stored-no-configuration-cache'
export interface CacheEntryReport {
entryName: string
requestedKey?: string
restoredKey?: string
restoredSize?: number
restoredTime?: number
restoredOutcome: string
savedKey?: string
savedSize?: number
savedTime?: number
savedOutcome: string
}
/**
* Structured result of a cache save operation. Rendering this into a human-readable
* Job Summary is handled centrally by `caching-report.ts`.
*/
export interface CacheReport {
status: CacheStatus
cleanup?: CacheCleanupStatus
projectCache?: ProjectCacheStatus
entries: CacheEntryReport[]
}
export interface CacheService {
restore(gradleUserHome: string, cacheOptions: CacheOptions): Promise<void>
save(gradleUserHome: string, buildResults: BuildResult[], cacheOptions: CacheOptions): Promise<CacheReport>
}