mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-22 17:12:51 +00:00
Do not fail build on error restoring artifact for marker
Instead, catch and report these errors before continuing.
This commit is contained in:
parent
cca55d0890
commit
bd08e7b7cd
1 changed files with 19 additions and 14 deletions
|
@ -72,17 +72,23 @@ export class GradleUserHomeCache extends AbstractCache {
|
||||||
const key = path.relative(this.getGradleUserHome(), artifactFile)
|
const key = path.relative(this.getGradleUserHome(), artifactFile)
|
||||||
const cacheKey = `gradle-artifact-${key}`
|
const cacheKey = `gradle-artifact-${key}`
|
||||||
|
|
||||||
|
try {
|
||||||
const restoreKey = await cache.restoreCache(
|
const restoreKey = await cache.restoreCache(
|
||||||
[artifactFile],
|
[artifactFile],
|
||||||
cacheKey
|
cacheKey
|
||||||
)
|
)
|
||||||
if (restoreKey) {
|
if (restoreKey) {
|
||||||
this.debug(`Restored ${cacheKey} from cache to ${artifactFile}`)
|
this.debug(
|
||||||
|
`Restored ${cacheKey} from cache to ${artifactFile}`
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
core.warning(
|
core.warning(
|
||||||
`Failed to restore from ${cacheKey} to ${artifactFile}`
|
`Failed to restore from ${cacheKey} to ${artifactFile}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
core.warning(`Error restoring ${cacheKey}: ${error}`)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.debug(
|
this.debug(
|
||||||
`Artifact file already exists, not restoring: ${artifactFile}`
|
`Artifact file already exists, not restoring: ${artifactFile}`
|
||||||
|
@ -162,16 +168,15 @@ export class GradleUserHomeCache extends AbstractCache {
|
||||||
await cache.saveCache([artifactFile], cacheKey)
|
await cache.saveCache([artifactFile], cacheKey)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Fail on validation errors or non-errors (the latter to keep Typescript happy)
|
// Fail on validation errors or non-errors (the latter to keep Typescript happy)
|
||||||
if (
|
if (error instanceof cache.ValidationError) {
|
||||||
error instanceof cache.ValidationError ||
|
|
||||||
!(error instanceof Error)
|
|
||||||
) {
|
|
||||||
throw error
|
throw error
|
||||||
} else if (error instanceof cache.ReserveCacheError) {
|
} else if (error instanceof cache.ReserveCacheError) {
|
||||||
// These are expected if the artifact is already cached
|
// These are expected if the artifact is already cached
|
||||||
this.debug(error.message)
|
this.debug(error.message)
|
||||||
} else {
|
} else if (error instanceof Error) {
|
||||||
core.warning(error.message)
|
core.warning(error.message)
|
||||||
|
} else {
|
||||||
|
core.warning(`${error}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue