Include repo identity in the /register link

The not-registered job-summary link and the core.notice pointed at the bare
/register URL, so the page replied 'owner and repo are required'. Append
?owner=&repo= from GITHUB_REPOSITORY so the backend can resolve the installation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Daz DeBoer
2026-06-29 11:10:06 -06:00
co-authored by Claude Opus 4.8
parent 294a727064
commit d97d29c992
2 changed files with 56 additions and 21 deletions
+26 -5
View File
@@ -2,7 +2,21 @@ import {CacheCleanupStatus, CacheEntryReport, CacheReport, CacheStatus, ProjectC
const DOCS = 'https://github.com/gradle/actions/blob/main/docs/setup-gradle.md' 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 DISTRIBUTION = 'https://github.com/gradle/actions/blob/main/DISTRIBUTION.md'
const REGISTER = 'https://actions-caching-registration.vercel.app/register' const REGISTER_BASE = 'https://actions-caching-registration.vercel.app/register'
/**
* The `/register` link with the current repo's identity appended, so the backend can resolve the
* installation and route to acceptance. Repo identity comes from `GITHUB_REPOSITORY` (`owner/repo`),
* set by the runner; falls back to the bare link if it is somehow unavailable.
*/
function registerUrl(): string {
const repository = process.env.GITHUB_REPOSITORY
if (!repository?.includes('/')) {
return REGISTER_BASE
}
const [owner, repo] = repository.split('/')
return `${REGISTER_BASE}?${new URLSearchParams({owner, repo}).toString()}`
}
/** /**
* Identifies the caching provider in use, so the report can attribute the cache * Identifies the caching provider in use, so the report can attribute the cache
@@ -29,10 +43,11 @@ const CLEANUP_COPY: Record<CacheCleanupStatus, string> = {
'disabled-readonly': `[Cache cleanup](${DOCS}#configuring-cache-cleanup) is always disabled when the cache is read-only.` 'disabled-readonly': `[Cache cleanup](${DOCS}#configuring-cache-cleanup) is always disabled when the cache is read-only.`
} }
const PROJECT_CACHE_COPY: Record<ProjectCacheStatus, string> = { // 'not-registered' is rendered dynamically (see renderProjectCacheLine) because its /register link
// carries the repo identity, so it is intentionally absent from this static map.
const PROJECT_CACHE_COPY: Record<Exclude<ProjectCacheStatus, 'not-registered'>, string> = {
'not-enabled': ``, 'not-enabled': ``,
'trial-expired': `Project state (build-logic and configuration cache) was not cached - the Develocity caching trial has expired.`, 'trial-expired': `Project state (build-logic and configuration cache) was not cached - the Develocity caching trial has expired.`,
'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.`, '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.` enabled: `Caching of project state (build-logic and configuration cache) was enabled.`
} }
@@ -79,8 +94,14 @@ function renderCleanupLine(cleanup?: CacheCleanupStatus): string | undefined {
} }
function renderProjectCacheLine(projectCache?: ProjectCacheStatus): string | undefined { function renderProjectCacheLine(projectCache?: ProjectCacheStatus): string | undefined {
if (!projectCache) {
return undefined
}
if (projectCache === 'not-registered') {
return `Project state (build-logic and configuration cache) was not cached - this repository is not registered for advanced caching. [Register this repository](${registerUrl()}), or provide a \`develocity-access-key\` and \`develocity-server-url\`.`
}
// PROJECT_CACHE_COPY['not-enabled'] is '', which the .filter(Boolean) at the call site drops. // PROJECT_CACHE_COPY['not-enabled'] is '', which the .filter(Boolean) at the call site drops.
return projectCache ? PROJECT_CACHE_COPY[projectCache] : undefined return PROJECT_CACHE_COPY[projectCache]
} }
/** /**
@@ -94,7 +115,7 @@ export function renderProjectCacheNotice(projectCache?: ProjectCacheStatus): str
} }
return ( return (
'Advanced caching (build-logic and configuration cache) was not enabled: this repository ' + '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 ` + `is not registered. Register it at ${registerUrl()}, or provide a develocity-access-key and ` +
'develocity-server-url.' 'develocity-server-url.'
) )
} }
+30 -16
View File
@@ -114,18 +114,25 @@ describe('renderCachingReport', () => {
expect(md).not.toContain('Project state') expect(md).not.toContain('Project state')
}) })
it('renders the not-registered status with a /register link inside the details', () => { it('renders the not-registered status with a repo-scoped /register link inside the details', () => {
const report: CacheReport = { const saved = process.env.GITHUB_REPOSITORY
status: 'enabled', process.env.GITHUB_REPOSITORY = 'acme/widgets'
cleanup: 'enabled', try {
projectCache: 'not-registered', const report: CacheReport = {
entries: [entry()] status: 'enabled',
} cleanup: 'enabled',
const md = renderCachingReport(report, ENHANCED) projectCache: 'not-registered',
entries: [entry()]
}
const md = renderCachingReport(report, ENHANCED)
const detailsBody = md.slice(md.indexOf('</summary>')) const detailsBody = md.slice(md.indexOf('</summary>'))
expect(detailsBody).toContain('not registered for advanced caching') expect(detailsBody).toContain('not registered for advanced caching')
expect(detailsBody).toContain('/register') expect(detailsBody).toContain('/register?owner=acme&repo=widgets')
} finally {
if (saved === undefined) delete process.env.GITHUB_REPOSITORY
else process.env.GITHUB_REPOSITORY = saved
}
}) })
it('renders a compact disabled report with no note and no details', () => { it('renders a compact disabled report with no note and no details', () => {
@@ -159,11 +166,18 @@ describe('renderCachingReport', () => {
}) })
describe('renderProjectCacheNotice', () => { describe('renderProjectCacheNotice', () => {
it('returns a notice with the /register link for the not-registered status', () => { it('returns a notice with a repo-scoped /register link for the not-registered status', () => {
const notice = renderProjectCacheNotice('not-registered') const saved = process.env.GITHUB_REPOSITORY
expect(notice).toBeDefined() process.env.GITHUB_REPOSITORY = 'acme/widgets'
expect(notice).toContain('not registered') try {
expect(notice).toContain('/register') const notice = renderProjectCacheNotice('not-registered')
expect(notice).toBeDefined()
expect(notice).toContain('not registered')
expect(notice).toContain('/register?owner=acme&repo=widgets')
} finally {
if (saved === undefined) delete process.env.GITHUB_REPOSITORY
else process.env.GITHUB_REPOSITORY = saved
}
}) })
it('is silent for every other status', () => { it('is silent for every other status', () => {