mirror of
https://github.com/gradle/actions.git
synced 2026-08-20 21:02:50 +00:00
Support experimental project-entry caching (configuration-cache + build-logic) (#994)
Pass develocityAccessToken and develocityServerUrl the `gradle-actions-caching`: required to support project-entry caching (build-logic + configuration-cache), which has experimental support in 'gradle-actions-cache@v0.8.0. This support is not yet released and will be available as a restricted trial. --------- 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
bbaaec0da2
commit
9c445f57df
@@ -79,37 +79,39 @@ describe('renderCachingReport', () => {
|
||||
expect(md).toContain('<summary>Entries: 1 restored, 0 saved - Expand for more details</summary>')
|
||||
})
|
||||
|
||||
it('renders the configuration-cache status line inside the details', () => {
|
||||
it('renders the project-cache status line inside the details', () => {
|
||||
const report: CacheReport = {
|
||||
status: 'enabled',
|
||||
cleanup: 'enabled',
|
||||
configurationCache: 'restored',
|
||||
projectCache: 'enabled',
|
||||
entries: [entry()]
|
||||
}
|
||||
const md = renderCachingReport(report, ENHANCED)
|
||||
|
||||
const detailsBody = md.slice(md.indexOf('</summary>'))
|
||||
expect(detailsBody).toContain('Configuration cache state was restored from the cache.')
|
||||
expect(detailsBody).toContain(
|
||||
'Caching of project state (build-logic and configuration cache) was enabled.'
|
||||
)
|
||||
})
|
||||
|
||||
it('explains an inactive configuration cache with a link to the encryption key docs', () => {
|
||||
it('renders nothing for the not-enabled project-cache status', () => {
|
||||
const report: CacheReport = {
|
||||
status: 'enabled',
|
||||
cleanup: 'enabled',
|
||||
configurationCache: 'not-active',
|
||||
projectCache: 'not-enabled',
|
||||
entries: [entry()]
|
||||
}
|
||||
const md = renderCachingReport(report, ENHANCED)
|
||||
|
||||
expect(md).toContain('Configuration cache state was not cached')
|
||||
expect(md).toContain('#cache-encryption-key')
|
||||
expect(md).not.toContain('Project state')
|
||||
expect(md).not.toContain('build-logic')
|
||||
})
|
||||
|
||||
it('omits the configuration-cache line when the status is absent', () => {
|
||||
it('omits the project-cache line when the status is absent', () => {
|
||||
const report: CacheReport = {status: 'enabled', cleanup: 'enabled', entries: [entry()]}
|
||||
const md = renderCachingReport(report, ENHANCED)
|
||||
|
||||
expect(md).not.toContain('Configuration cache state')
|
||||
expect(md).not.toContain('Project state')
|
||||
})
|
||||
|
||||
it('renders a compact disabled report with no note and no details', () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import nock from "nock";
|
||||
import {describe, expect, it} from '@jest/globals'
|
||||
|
||||
import {DevelocityAccessCredentials, getToken} from "../../src/develocity/short-lived-token";
|
||||
import {DevelocityAccessCredentials, getToken, resolveTokenForServer} from "../../src/develocity/short-lived-token";
|
||||
|
||||
describe('short lived tokens', () => {
|
||||
it('parse valid access key should return an object', async () => {
|
||||
@@ -134,3 +134,42 @@ describe('short lived tokens with retry', () => {
|
||||
.toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('resolveTokenForServer', () => {
|
||||
const credentials = (...pairs: [string, string][]): DevelocityAccessCredentials =>
|
||||
DevelocityAccessCredentials.of(pairs.map(([hostname, key]) => ({hostname, key})))
|
||||
|
||||
it('returns the token matching the server host from a full URL', () => {
|
||||
const tokens = credentials(['ge.example.com', 'key1'], ['other', 'key2'])
|
||||
expect(resolveTokenForServer(tokens, 'https://ge.example.com')).toBe('key1')
|
||||
})
|
||||
|
||||
it('matches on hostname, ignoring scheme, port and path', () => {
|
||||
const tokens = credentials(['ge.example.com', 'key1'])
|
||||
expect(resolveTokenForServer(tokens, 'https://ge.example.com:8443/path')).toBe('key1')
|
||||
})
|
||||
|
||||
it('tolerates a bare hostname with no scheme', () => {
|
||||
const tokens = credentials(['ge.example.com', 'key1'])
|
||||
expect(resolveTokenForServer(tokens, 'ge.example.com')).toBe('key1')
|
||||
})
|
||||
|
||||
it('selects the matching token when multiple are present', () => {
|
||||
const tokens = credentials(['dev', 'key1'], ['ge.example.com', 'key2'])
|
||||
expect(resolveTokenForServer(tokens, 'https://ge.example.com')).toBe('key2')
|
||||
})
|
||||
|
||||
it('returns undefined when no token matches the server host', () => {
|
||||
const tokens = credentials(['ge.example.com', 'key1'])
|
||||
expect(resolveTokenForServer(tokens, 'https://other.example.com')).toBeUndefined()
|
||||
})
|
||||
|
||||
it('returns undefined for an empty server URL', () => {
|
||||
const tokens = credentials(['ge.example.com', 'key1'])
|
||||
expect(resolveTokenForServer(tokens, '')).toBeUndefined()
|
||||
})
|
||||
|
||||
it('returns undefined when there are no tokens', () => {
|
||||
expect(resolveTokenForServer(credentials(), 'https://ge.example.com')).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user