Unverified Commit bd08e7b7 authored by Daz DeBoer's avatar Daz DeBoer
Browse files

Do not fail build on error restoring artifact for marker

Instead, catch and report these errors before continuing.
parent cca55d08
Loading
Loading
Loading
Loading
+11 −6
Changes for src/cache-gradle-user-home.ts: 11 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -72,17 +72,23 @@ export class GradleUserHomeCache extends AbstractCache {
            const key = path.relative(this.getGradleUserHome(), artifactFile)
            const cacheKey = `gradle-artifact-${key}`

            try {
                const restoreKey = await cache.restoreCache(
                    [artifactFile],
                    cacheKey
                )
                if (restoreKey) {
                this.debug(`Restored ${cacheKey} from cache to ${artifactFile}`)
                    this.debug(
                        `Restored ${cacheKey} from cache to ${artifactFile}`
                    )
                } else {
                    core.warning(
                        `Failed to restore from ${cacheKey} to ${artifactFile}`
                    )
                }
            } catch (error) {
                core.warning(`Error restoring ${cacheKey}: ${error}`)
            }
        } else {
            this.debug(
                `Artifact file already exists, not restoring: ${artifactFile}`
@@ -162,16 +168,15 @@ export class GradleUserHomeCache extends AbstractCache {
                await cache.saveCache([artifactFile], cacheKey)
            } catch (error) {
                // Fail on validation errors or non-errors (the latter to keep Typescript happy)
                if (
                    error instanceof cache.ValidationError ||
                    !(error instanceof Error)
                ) {
                if (error instanceof cache.ValidationError) {
                    throw error
                } else if (error instanceof cache.ReserveCacheError) {
                    // These are expected if the artifact is already cached
                    this.debug(error.message)
                } else {
                } else if (error instanceof Error) {
                    core.warning(error.message)
                } else {
                    core.warning(`${error}`)
                }
            }