mirror of
https://github.com/gradle/actions.git
synced 2026-09-10 19:28:33 +08:00
Support repo-registration as a second enablement path for project-entry caching
Configuration-cache store/restore is now enabled when EITHER a valid Develocity JWT OR per-repo registration (a GitHub App installation that accepted the T&C) is present. The gate itself lives in the vendored gradle-actions-caching library (refreshed to 0.9.1); this repo wires up the reporting and notice. - ProjectCacheStatus: 'trial-not-licensed' -> 'not-registered'. - caching-report: render the 'not-registered' line with a /register link, and add renderProjectCacheNotice() for a prominent core.notice. - setup-gradle: emit the notice from complete() only when withheld via the registration path; quiet when enabled by either path. - Refresh vendored gradle-actions-caching to 0.9.1. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
b128da9bf0
commit
bc54cf57d1
@@ -32,9 +32,9 @@ export type CacheCleanupStatus =
|
||||
export type ProjectCacheStatus =
|
||||
| 'not-enabled' // the hidden opt-in env var was not set (rendered as nothing)
|
||||
| 'trial-expired' // past the hard trial expiry
|
||||
| 'trial-not-licensed' // Develocity trial token missing or invalid
|
||||
| 'not-registered' // neither entitlement path satisfied (no Develocity trial token, repo not registered)
|
||||
| 'no-encryption-key' // Cannot store due to missing encryption key
|
||||
| 'enabled' // Trial in effect: will attempt to save project state
|
||||
| 'enabled' // Entitled: will attempt to save project state
|
||||
|
||||
export interface CacheEntryReport {
|
||||
entryName: string
|
||||
|
||||
@@ -2,6 +2,7 @@ import {CacheCleanupStatus, CacheEntryReport, CacheReport, CacheStatus, ProjectC
|
||||
|
||||
const DOCS = 'https://github.com/gradle/actions/blob/main/docs/setup-gradle.md'
|
||||
const DISTRIBUTION = 'https://github.com/gradle/actions/blob/main/DISTRIBUTION.md'
|
||||
const REGISTER = 'https://gradle-actions-caching-registration.vercel.app/register'
|
||||
|
||||
/**
|
||||
* Identifies the caching provider in use, so the report can attribute the cache
|
||||
@@ -31,7 +32,7 @@ const CLEANUP_COPY: Record<CacheCleanupStatus, string> = {
|
||||
const PROJECT_CACHE_COPY: Record<ProjectCacheStatus, string> = {
|
||||
'not-enabled': ``,
|
||||
'trial-expired': `Project state (build-logic and configuration cache) was not cached - the Develocity caching trial has expired.`,
|
||||
'trial-not-licensed': `Project state (build-logic and configuration cache) was not cached - a develocity-access-key and develocity-server-url is required.`,
|
||||
'not-registered': `Project state (build-logic and configuration cache) was not cached - this repository is not registered for advanced caching. [Register this repository](${REGISTER}), or provide a \`develocity-access-key\` and \`develocity-server-url\`.`,
|
||||
'no-encryption-key': `Project state (build-logic and configuration cache) was not cached - a [cache-encryption-key](${DOCS}#cache-encryption-key) is required.`,
|
||||
enabled: `Caching of project state (build-logic and configuration cache) was enabled.`
|
||||
}
|
||||
@@ -82,6 +83,22 @@ function renderProjectCacheLine(projectCache?: ProjectCacheStatus): string | und
|
||||
return projectCache ? PROJECT_CACHE_COPY[projectCache] : undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* A plain-text log notice (no markdown) surfaced when advanced caching was withheld because the
|
||||
* repository is not registered. Returns `undefined` for every other status, so callers stay quiet
|
||||
* when the feature is enabled, disabled, or simply not opted in.
|
||||
*/
|
||||
export function renderProjectCacheNotice(projectCache?: ProjectCacheStatus): string | undefined {
|
||||
if (projectCache !== 'not-registered') {
|
||||
return undefined
|
||||
}
|
||||
return (
|
||||
'Advanced caching (build-logic and configuration cache) was not enabled: this repository ' +
|
||||
`is not registered. Register it at ${REGISTER}, or provide a develocity-access-key and ` +
|
||||
'develocity-server-url.'
|
||||
)
|
||||
}
|
||||
|
||||
function renderProviderNote(providerNote?: ProviderNote): string | undefined {
|
||||
if (!providerNote) {
|
||||
return undefined
|
||||
|
||||
@@ -9,6 +9,7 @@ import {setupToken} from './develocity/short-lived-token'
|
||||
|
||||
import {loadBuildResults, markBuildResultsProcessed} from './build-results'
|
||||
import {getCacheService, getProviderNote} from './cache-service-loader'
|
||||
import {renderProjectCacheNotice} from './caching-report'
|
||||
import {CacheOptions} from './cache-service'
|
||||
import {
|
||||
DevelocityConfig,
|
||||
@@ -85,6 +86,14 @@ export async function complete(
|
||||
buildResults,
|
||||
cacheOptionsFrom(cacheConfig, develocityServerUrl, cacheToken)
|
||||
)
|
||||
|
||||
// Surface a prominent notice (with the /register link) only when advanced caching was withheld
|
||||
// because the repo is not registered; stay quiet when enabled by either path.
|
||||
const registrationNotice = renderProjectCacheNotice(cacheReport.projectCache)
|
||||
if (registrationNotice) {
|
||||
core.notice(registrationNotice)
|
||||
}
|
||||
|
||||
await jobSummary.generateJobSummary(buildResults, cacheReport, getProviderNote(cacheConfig), summaryConfig)
|
||||
|
||||
markBuildResultsProcessed()
|
||||
|
||||
Reference in New Issue
Block a user