Skip to content

Commit f475ae6

Browse files
committed
Handle expired artifact error
1 parent 860f000 commit f475ae6

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

badges/coverage.svg

Lines changed: 1 addition & 1 deletion
Loading

dist/index.js

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/artifact.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as github from '@actions/github'
88
import type { ArtifactData, GitBranch } from '@code-pushup/ci'
99
import { DEFAULT_PERSIST_FILENAME } from '@code-pushup/models'
1010
import { projectToFilename } from '@code-pushup/utils'
11+
import type { RequestError } from '@octokit/request-error'
1112
import { readdir, rm } from 'node:fs/promises'
1213
import { join } from 'node:path'
1314
import type { ActionInputs } from './inputs'
@@ -124,7 +125,13 @@ export async function downloadReportArtifact(
124125
} catch (err) {
125126
if (err instanceof ArtifactNotFoundError) {
126127
core.info(
127-
`Artifact not found for ${branch.ref} branch's commit ${branch.sha}`
128+
`Artifact not found for ${branch.ref} branch's commit ${branch.sha} - ${err.message}`
129+
)
130+
return null
131+
}
132+
if (isRequestError(err)) {
133+
core.info(
134+
`Artifact download failed, received "${err.message}" error for ${err.request.method} ${err.request.url} request`
128135
)
129136
return null
130137
}
@@ -134,3 +141,13 @@ export async function downloadReportArtifact(
134141
throw err
135142
}
136143
}
144+
145+
// `err instanceof RequestError` is `false` for some reason
146+
function isRequestError(err: unknown): err is RequestError {
147+
return (
148+
typeof err === 'object' &&
149+
err !== null &&
150+
'status' in err &&
151+
typeof err.status === 'number'
152+
)
153+
}

0 commit comments

Comments
 (0)