mirror of
https://github.com/gradle/actions.git
synced 2026-06-13 23:20:44 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 72714db355 |
@@ -26,7 +26,7 @@ jobs:
|
|||||||
cache-dependency-path: sources/package-lock.json
|
cache-dependency-path: sources/package-lock.json
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
# Use a released version to avoid breakages
|
# Use a released version to avoid breakages
|
||||||
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
|
uses: gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # v6.2.0
|
||||||
env:
|
env:
|
||||||
ALLOWED_GRADLE_WRAPPER_CHECKSUMS: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 # Invalid wrapper jar used for testing
|
ALLOWED_GRADLE_WRAPPER_CHECKSUMS: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 # Invalid wrapper jar used for testing
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ jobs:
|
|||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
if: steps.changes.outputs.any_changed == 'true' || github.event_name != 'pull_request'
|
if: steps.changes.outputs.any_changed == 'true' || github.event_name != 'pull_request'
|
||||||
# Use a released version to avoid breakages
|
# Use a released version to avoid breakages
|
||||||
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
|
uses: gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # v6.2.0
|
||||||
env:
|
env:
|
||||||
ALLOWED_GRADLE_WRAPPER_CHECKSUMS: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 # Invalid wrapper jar used for testing
|
ALLOWED_GRADLE_WRAPPER_CHECKSUMS: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 # Invalid wrapper jar used for testing
|
||||||
- name: Run integration tests
|
- name: Run integration tests
|
||||||
|
|||||||
@@ -12,6 +12,6 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||||
- uses: gradle/actions/wrapper-validation@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
|
- uses: gradle/actions/wrapper-validation@3f131e8634966bd73d06cc69884922b02e6faf92 # v6.2.0
|
||||||
with:
|
with:
|
||||||
allow-checksums: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
allow-checksums: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as setupGradle from '../../setup-gradle'
|
import * as setupGradle from '../../setup-gradle'
|
||||||
|
|
||||||
import {CacheConfig, DevelocityConfig, SummaryConfig} from '../../configuration'
|
import {CacheConfig, SummaryConfig} from '../../configuration'
|
||||||
import {handlePostActionError} from '../../errors'
|
import {handlePostActionError} from '../../errors'
|
||||||
import {forceExit} from '../../force-exit'
|
import {forceExit} from '../../force-exit'
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ process.on('uncaughtException', e => handlePostActionError(e))
|
|||||||
*/
|
*/
|
||||||
export async function run(): Promise<void> {
|
export async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await setupGradle.complete(new CacheConfig(), new DevelocityConfig(), new SummaryConfig())
|
await setupGradle.complete(new CacheConfig(), new SummaryConfig())
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handlePostActionError(error)
|
handlePostActionError(error)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as setupGradle from '../../setup-gradle'
|
import * as setupGradle from '../../setup-gradle'
|
||||||
import * as dependencyGraph from '../../dependency-graph'
|
import * as dependencyGraph from '../../dependency-graph'
|
||||||
|
|
||||||
import {CacheConfig, DependencyGraphConfig, DevelocityConfig, SummaryConfig} from '../../configuration'
|
import {CacheConfig, DependencyGraphConfig, SummaryConfig} from '../../configuration'
|
||||||
import {handlePostActionError} from '../../errors'
|
import {handlePostActionError} from '../../errors'
|
||||||
import {emitDeprecationWarnings, restoreDeprecationState} from '../../deprecation-collector'
|
import {emitDeprecationWarnings, restoreDeprecationState} from '../../deprecation-collector'
|
||||||
import {forceExit} from '../../force-exit'
|
import {forceExit} from '../../force-exit'
|
||||||
@@ -19,7 +19,7 @@ export async function run(): Promise<void> {
|
|||||||
restoreDeprecationState()
|
restoreDeprecationState()
|
||||||
emitDeprecationWarnings()
|
emitDeprecationWarnings()
|
||||||
|
|
||||||
if (await setupGradle.complete(new CacheConfig(), new DevelocityConfig(), new SummaryConfig())) {
|
if (await setupGradle.complete(new CacheConfig(), new SummaryConfig())) {
|
||||||
// Only submit the dependency graphs once per job
|
// Only submit the dependency graphs once per job
|
||||||
await dependencyGraph.complete(new DependencyGraphConfig())
|
await dependencyGraph.complete(new DependencyGraphConfig())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ export interface CacheOptions {
|
|||||||
strictMatch: boolean
|
strictMatch: boolean
|
||||||
cleanup: string
|
cleanup: string
|
||||||
encryptionKey?: string
|
encryptionKey?: string
|
||||||
develocityAccessToken?: string
|
|
||||||
develocityServerUrl?: string
|
|
||||||
includes: string[]
|
includes: string[]
|
||||||
excludes: string[]
|
excludes: string[]
|
||||||
}
|
}
|
||||||
@@ -29,18 +27,7 @@ export type CacheCleanupStatus =
|
|||||||
| 'disabled-config-cache-hit'
|
| 'disabled-config-cache-hit'
|
||||||
| 'disabled-readonly'
|
| 'disabled-readonly'
|
||||||
|
|
||||||
// Mirrors ProjectCacheStatus in the gradle-actions-caching library. The first three are set on
|
export type ConfigurationCacheStatus = 'not-active' | 'restored' | 'not-restored' | 'restore-incomplete'
|
||||||
// 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 {
|
export interface CacheEntryReport {
|
||||||
entryName: string
|
entryName: string
|
||||||
@@ -62,7 +49,7 @@ export interface CacheEntryReport {
|
|||||||
export interface CacheReport {
|
export interface CacheReport {
|
||||||
status: CacheStatus
|
status: CacheStatus
|
||||||
cleanup?: CacheCleanupStatus
|
cleanup?: CacheCleanupStatus
|
||||||
projectCache?: ProjectCacheStatus
|
configurationCache?: ConfigurationCacheStatus
|
||||||
entries: CacheEntryReport[]
|
entries: CacheEntryReport[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {CacheCleanupStatus, CacheEntryReport, CacheReport, CacheStatus, ProjectCacheStatus} from './cache-service'
|
import {CacheCleanupStatus, CacheEntryReport, CacheReport, CacheStatus, ConfigurationCacheStatus} from './cache-service'
|
||||||
|
|
||||||
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'
|
||||||
@@ -28,19 +28,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> = {
|
const CONFIG_CACHE_COPY: Record<ConfigurationCacheStatus, string> = {
|
||||||
// Restore (ungated).
|
'not-active': `Configuration cache state was not cached — set a [cache-encryption-key](${DOCS}#cache-encryption-key) to enable configuration-cache caching.`,
|
||||||
'restore-incomplete': `Project state was not restored — the Gradle User Home was not fully restored.`,
|
restored: `Configuration cache state was restored from the cache.`,
|
||||||
restored: `Project state (build-logic and configuration cache) was restored from the cache.`,
|
'not-restored': `Configuration cache state was not restored — no cached data was available (e.g. the first run for this cache key).`,
|
||||||
'not-restored': `Project state was not restored — no cached data was available (e.g. the first run for this cache key).`,
|
'restore-incomplete': `Configuration cache state was not restored — the Gradle User Home was not fully restored.`
|
||||||
// Save, Tier A gate. 'not-enabled' renders nothing (dropped by the .filter(Boolean) below).
|
|
||||||
'not-enabled': ``,
|
|
||||||
'trial-expired': `Project state was not cached — the Develocity caching trial has expired.`,
|
|
||||||
'trial-not-licensed': `Project state was not cached — a valid Develocity trial token is required.`,
|
|
||||||
// Save, post-gate outcomes.
|
|
||||||
'not-stored-no-develocity-plugin': `Project state was not cached — applying the Develocity plugin is required to cache build-logic and configuration-cache state.`,
|
|
||||||
stored: `Project state (build-logic and configuration cache) was saved to the cache.`,
|
|
||||||
'stored-no-configuration-cache': `Build-logic state was cached. Storing configuration-cache data requires a build running Gradle >= 8.6 and a [valid encryption key](${DOCS}#cache-encryption-key).`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,9 +76,8 @@ function renderCleanupLine(cleanup?: CacheCleanupStatus): string | undefined {
|
|||||||
return cleanup ? CLEANUP_COPY[cleanup] : undefined
|
return cleanup ? CLEANUP_COPY[cleanup] : undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderProjectCacheLine(projectCache?: ProjectCacheStatus): string | undefined {
|
function renderConfigCacheLine(configurationCache?: ConfigurationCacheStatus): string | undefined {
|
||||||
// PROJECT_CACHE_COPY['not-enabled'] is '', which the .filter(Boolean) at the call site drops.
|
return configurationCache ? CONFIG_CACHE_COPY[configurationCache] : undefined
|
||||||
return projectCache ? PROJECT_CACHE_COPY[projectCache] : undefined
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderProviderNote(providerNote?: ProviderNote): string | undefined {
|
function renderProviderNote(providerNote?: ProviderNote): string | undefined {
|
||||||
@@ -108,10 +99,10 @@ function renderDetails(report: CacheReport): string {
|
|||||||
: `Entries: ${restored} restored, ${saved} saved - Expand for more details`
|
: `Entries: ${restored} restored, ${saved} saved - Expand for more details`
|
||||||
|
|
||||||
const cleanup = report.status === 'enabled' ? renderCleanupLine(report.cleanup) : undefined
|
const cleanup = report.status === 'enabled' ? renderCleanupLine(report.cleanup) : undefined
|
||||||
const projectCache = renderProjectCacheLine(report.projectCache)
|
const configCache = renderConfigCacheLine(report.configurationCache)
|
||||||
const table = renderEntryTable(report.entries)
|
const table = renderEntryTable(report.entries)
|
||||||
const pre = `<pre>\n${renderEntryDetails(report.entries)}</pre>`
|
const pre = `<pre>\n${renderEntryDetails(report.entries)}</pre>`
|
||||||
const body = [STATUS_COPY[report.status], cleanup, projectCache, table, pre].filter(Boolean).join('\n\n')
|
const body = [STATUS_COPY[report.status], cleanup, configCache, table, pre].filter(Boolean).join('\n\n')
|
||||||
|
|
||||||
return `<details>
|
return `<details>
|
||||||
<summary>${summary}</summary>
|
<summary>${summary}</summary>
|
||||||
|
|||||||
@@ -174,22 +174,3 @@ export class DevelocityAccessCredentials {
|
|||||||
return this.accessKeyRegexp.test(allKeys)
|
return this.accessKeyRegexp.test(allKeys)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolve the access key that matches a given Develocity server, for use as the
|
|
||||||
* `develocityAccessToken` cache option. Returns `undefined` (fail-closed) when the access key is
|
|
||||||
* empty/malformed, the server URL is empty/unparseable, or no key matches the server's host.
|
|
||||||
*/
|
|
||||||
export function resolveAccessKeyForServer(accessKey: string, serverUrl: string): string | undefined {
|
|
||||||
const creds = DevelocityAccessCredentials.parse(accessKey)
|
|
||||||
if (!creds || !serverUrl) {
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
let host: string
|
|
||||||
try {
|
|
||||||
host = new URL(serverUrl).hostname
|
|
||||||
} catch {
|
|
||||||
host = serverUrl // tolerate a bare hostname (no scheme)
|
|
||||||
}
|
|
||||||
return creds.keys.find(k => k.hostname === host)?.key
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import * as path from 'path'
|
|||||||
import * as os from 'os'
|
import * as os from 'os'
|
||||||
import * as jobSummary from './job-summary'
|
import * as jobSummary from './job-summary'
|
||||||
import * as buildScan from './develocity/build-scan'
|
import * as buildScan from './develocity/build-scan'
|
||||||
import {resolveAccessKeyForServer} from './develocity/short-lived-token'
|
|
||||||
|
|
||||||
import {loadBuildResults, markBuildResultsProcessed} from './build-results'
|
import {loadBuildResults, markBuildResultsProcessed} from './build-results'
|
||||||
import {getCacheService, getProviderNote} from './cache-service-loader'
|
import {getCacheService, getProviderNote} from './cache-service-loader'
|
||||||
@@ -55,11 +54,7 @@ export async function setup(
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function complete(
|
export async function complete(cacheConfig: CacheConfig, summaryConfig: SummaryConfig): Promise<boolean> {
|
||||||
cacheConfig: CacheConfig,
|
|
||||||
develocityConfig: DevelocityConfig,
|
|
||||||
summaryConfig: SummaryConfig
|
|
||||||
): Promise<boolean> {
|
|
||||||
if (!core.getState(GRADLE_SETUP_VAR)) {
|
if (!core.getState(GRADLE_SETUP_VAR)) {
|
||||||
core.info('Gradle setup post-action only performed for first gradle/actions step in workflow.')
|
core.info('Gradle setup post-action only performed for first gradle/actions step in workflow.')
|
||||||
return false
|
return false
|
||||||
@@ -70,11 +65,7 @@ export async function complete(
|
|||||||
|
|
||||||
const gradleUserHome = core.getState(GRADLE_USER_HOME)
|
const gradleUserHome = core.getState(GRADLE_USER_HOME)
|
||||||
const cacheService = await getCacheService(cacheConfig)
|
const cacheService = await getCacheService(cacheConfig)
|
||||||
const cacheReport = await cacheService.save(
|
const cacheReport = await cacheService.save(gradleUserHome, buildResults, cacheOptionsFrom(cacheConfig))
|
||||||
gradleUserHome,
|
|
||||||
buildResults,
|
|
||||||
cacheOptionsFrom(cacheConfig, develocityConfig)
|
|
||||||
)
|
|
||||||
await jobSummary.generateJobSummary(buildResults, cacheReport, getProviderNote(cacheConfig), summaryConfig)
|
await jobSummary.generateJobSummary(buildResults, cacheReport, getProviderNote(cacheConfig), summaryConfig)
|
||||||
|
|
||||||
markBuildResultsProcessed()
|
markBuildResultsProcessed()
|
||||||
@@ -84,14 +75,7 @@ export async function complete(
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
function cacheOptionsFrom(config: CacheConfig, develocityConfig?: DevelocityConfig): CacheOptions {
|
function cacheOptionsFrom(config: CacheConfig): CacheOptions {
|
||||||
// Trial credentials are threaded only on the save path (when develocityConfig is provided).
|
|
||||||
// On restore they stay undefined, which is fine: project-entry restore is ungated.
|
|
||||||
const develocityServerUrl = develocityConfig?.getDevelocityUrl() || undefined
|
|
||||||
const develocityAccessToken =
|
|
||||||
develocityConfig && develocityServerUrl
|
|
||||||
? resolveAccessKeyForServer(develocityConfig.getDevelocityAccessKey(), develocityServerUrl)
|
|
||||||
: undefined
|
|
||||||
return {
|
return {
|
||||||
disabled: config.isCacheDisabled(),
|
disabled: config.isCacheDisabled(),
|
||||||
readOnly: config.isCacheReadOnly(),
|
readOnly: config.isCacheReadOnly(),
|
||||||
@@ -100,8 +84,6 @@ function cacheOptionsFrom(config: CacheConfig, develocityConfig?: DevelocityConf
|
|||||||
strictMatch: config.isCacheStrictMatch(),
|
strictMatch: config.isCacheStrictMatch(),
|
||||||
cleanup: config.getCacheCleanupOption(),
|
cleanup: config.getCacheCleanupOption(),
|
||||||
encryptionKey: config.getCacheEncryptionKey() || undefined,
|
encryptionKey: config.getCacheEncryptionKey() || undefined,
|
||||||
develocityAccessToken,
|
|
||||||
develocityServerUrl,
|
|
||||||
includes: config.getCacheIncludes(),
|
includes: config.getCacheIncludes(),
|
||||||
excludes: config.getCacheExcludes()
|
excludes: config.getCacheExcludes()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,52 +79,37 @@ describe('renderCachingReport', () => {
|
|||||||
expect(md).toContain('<summary>Entries: 1 restored, 0 saved - Expand for more details</summary>')
|
expect(md).toContain('<summary>Entries: 1 restored, 0 saved - Expand for more details</summary>')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders the project-cache status line inside the details', () => {
|
it('renders the configuration-cache status line inside the details', () => {
|
||||||
const report: CacheReport = {
|
const report: CacheReport = {
|
||||||
status: 'enabled',
|
status: 'enabled',
|
||||||
cleanup: 'enabled',
|
cleanup: 'enabled',
|
||||||
projectCache: 'restored',
|
configurationCache: 'restored',
|
||||||
entries: [entry()]
|
entries: [entry()]
|
||||||
}
|
}
|
||||||
const md = renderCachingReport(report, ENHANCED)
|
const md = renderCachingReport(report, ENHANCED)
|
||||||
|
|
||||||
const detailsBody = md.slice(md.indexOf('</summary>'))
|
const detailsBody = md.slice(md.indexOf('</summary>'))
|
||||||
expect(detailsBody).toContain(
|
expect(detailsBody).toContain('Configuration cache state was restored from the cache.')
|
||||||
'Project state (build-logic and configuration cache) was restored from the cache.'
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('explains an omitted configuration cache with a link to the encryption key docs', () => {
|
it('explains an inactive configuration cache with a link to the encryption key docs', () => {
|
||||||
const report: CacheReport = {
|
const report: CacheReport = {
|
||||||
status: 'enabled',
|
status: 'enabled',
|
||||||
cleanup: 'enabled',
|
cleanup: 'enabled',
|
||||||
projectCache: 'stored-no-configuration-cache',
|
configurationCache: 'not-active',
|
||||||
entries: [entry()]
|
entries: [entry()]
|
||||||
}
|
}
|
||||||
const md = renderCachingReport(report, ENHANCED)
|
const md = renderCachingReport(report, ENHANCED)
|
||||||
|
|
||||||
expect(md).toContain('Build-logic state was cached.')
|
expect(md).toContain('Configuration cache state was not cached')
|
||||||
expect(md).toContain('#cache-encryption-key')
|
expect(md).toContain('#cache-encryption-key')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders nothing for the not-enabled project-cache status', () => {
|
it('omits the configuration-cache line when the status is absent', () => {
|
||||||
const report: CacheReport = {
|
|
||||||
status: 'enabled',
|
|
||||||
cleanup: 'enabled',
|
|
||||||
projectCache: 'not-enabled',
|
|
||||||
entries: [entry()]
|
|
||||||
}
|
|
||||||
const md = renderCachingReport(report, ENHANCED)
|
|
||||||
|
|
||||||
expect(md).not.toContain('Project state')
|
|
||||||
expect(md).not.toContain('Build-logic state')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('omits the project-cache line when the status is absent', () => {
|
|
||||||
const report: CacheReport = {status: 'enabled', cleanup: 'enabled', entries: [entry()]}
|
const report: CacheReport = {status: 'enabled', cleanup: 'enabled', entries: [entry()]}
|
||||||
const md = renderCachingReport(report, ENHANCED)
|
const md = renderCachingReport(report, ENHANCED)
|
||||||
|
|
||||||
expect(md).not.toContain('Project state')
|
expect(md).not.toContain('Configuration cache state')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders a compact disabled report with no note and no details', () => {
|
it('renders a compact disabled report with no note and no details', () => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import nock from "nock";
|
import nock from "nock";
|
||||||
import {describe, expect, it} from '@jest/globals'
|
import {describe, expect, it} from '@jest/globals'
|
||||||
|
|
||||||
import {DevelocityAccessCredentials, getToken, resolveAccessKeyForServer} from "../../src/develocity/short-lived-token";
|
import {DevelocityAccessCredentials, getToken} from "../../src/develocity/short-lived-token";
|
||||||
|
|
||||||
describe('short lived tokens', () => {
|
describe('short lived tokens', () => {
|
||||||
it('parse valid access key should return an object', async () => {
|
it('parse valid access key should return an object', async () => {
|
||||||
@@ -134,37 +134,3 @@ describe('short lived tokens with retry', () => {
|
|||||||
.toBeNull()
|
.toBeNull()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('resolveAccessKeyForServer', () => {
|
|
||||||
it('returns the key matching the server host from a full URL', () => {
|
|
||||||
expect(resolveAccessKeyForServer('ge.example.com=key1;other=key2', 'https://ge.example.com')).toBe('key1')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('matches on hostname, ignoring scheme, port and path', () => {
|
|
||||||
expect(resolveAccessKeyForServer('ge.example.com=key1', 'https://ge.example.com:8443/path')).toBe('key1')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('tolerates a bare hostname with no scheme', () => {
|
|
||||||
expect(resolveAccessKeyForServer('ge.example.com=key1', 'ge.example.com')).toBe('key1')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('selects the matching key when multiple are present', () => {
|
|
||||||
expect(resolveAccessKeyForServer('dev=key1;ge.example.com=key2', 'https://ge.example.com')).toBe('key2')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns undefined when no key matches the server host', () => {
|
|
||||||
expect(resolveAccessKeyForServer('ge.example.com=key1', 'https://other.example.com')).toBeUndefined()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns undefined for an empty server URL', () => {
|
|
||||||
expect(resolveAccessKeyForServer('ge.example.com=key1', '')).toBeUndefined()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns undefined for an empty access key', () => {
|
|
||||||
expect(resolveAccessKeyForServer('', 'https://ge.example.com')).toBeUndefined()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns undefined for a malformed access key', () => {
|
|
||||||
expect(resolveAccessKeyForServer('not-a-valid-access-key', 'https://ge.example.com')).toBeUndefined()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|||||||
@@ -37,8 +37,6 @@ export declare interface CacheOptions {
|
|||||||
strictMatch: boolean;
|
strictMatch: boolean;
|
||||||
cleanup: 'always' | 'on-success' | 'never';
|
cleanup: 'always' | 'on-success' | 'never';
|
||||||
encryptionKey?: string;
|
encryptionKey?: string;
|
||||||
develocityAccessToken?: string;
|
|
||||||
develocityServerUrl?: string;
|
|
||||||
includes: string[];
|
includes: string[];
|
||||||
excludes: string[];
|
excludes: string[];
|
||||||
}
|
}
|
||||||
@@ -47,22 +45,12 @@ export declare interface CacheOptions {
|
|||||||
export declare interface CacheReport {
|
export declare interface CacheReport {
|
||||||
status: CacheStatus;
|
status: CacheStatus;
|
||||||
cleanup?: CacheCleanupStatus;
|
cleanup?: CacheCleanupStatus;
|
||||||
projectCache?: ProjectCacheStatus;
|
|
||||||
entries: CacheEntryReport[];
|
entries: CacheEntryReport[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @public */
|
/** @public */
|
||||||
export declare type CacheStatus = 'enabled' | 'read-only' | 'write-only' | 'disabled' | 'disabled-existing-home' | 'not-available';
|
export declare type CacheStatus = 'enabled' | 'read-only' | 'write-only' | 'disabled' | 'disabled-existing-home' | 'not-available';
|
||||||
|
|
||||||
/**
|
|
||||||
* Status of project-entry caching (build-logic artifacts + configuration-cache data) for a run.
|
|
||||||
* The first three are set on restore (always ungated); the rest are set on save and reflect the
|
|
||||||
* two-tier gate (opt-in + Develocity trial, then encryption key + Gradle version). Still beta.
|
|
||||||
*
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
declare type ProjectCacheStatus = 'restore-incomplete' | 'restored' | 'not-restored' | 'not-enabled' | 'trial-expired' | 'trial-not-licensed' | 'not-stored-no-develocity-plugin' | 'stored' | 'stored-no-configuration-cache';
|
|
||||||
|
|
||||||
/** @public */
|
/** @public */
|
||||||
export declare function restore(gradleUserHome: string, cacheOptions: CacheOptions): Promise<void>;
|
export declare function restore(gradleUserHome: string, cacheOptions: CacheOptions): Promise<void>;
|
||||||
|
|
||||||
|
|||||||
+2
-2
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gradle-actions-caching",
|
"name": "gradle-actions-caching",
|
||||||
"version": "0.8.0-cc",
|
"version": "0.7.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./index.js",
|
"main": "./index.js",
|
||||||
"types": "./index.d.ts",
|
"types": "./index.d.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user