in test-reporter/src/input-providers/artifact-provider.ts [50:104]
async load(): Promise<ReportInput> {
const result: ReportInput = {}
const resp = await this.octokit.actions.listWorkflowRunArtifacts({
...github.context.repo,
run_id: this.runId,
per_page: 100
})
if (resp.data.artifacts.length === 0) {
core.warning(`No artifacts found in run ${this.runId}`)
return {}
}
const artifacts = resp.data.artifacts.filter(a => this.artifactNameMatch(a.name))
if (artifacts.length === 0) {
core.warning(`No artifact matches ${this.artifact}`)
return {}
}
for (const art of artifacts) {
const fileName = `${art.name}.zip`
await downloadArtifact(this.octokit, art.id, fileName, this.token)
core.startGroup(`Reading archive ${fileName}`)
try {
const reportName = this.getReportName(art.name)
core.info(`Report name: ${reportName}`)
const files: FileContent[] = []
const zip = new Zip(fileName)
for (const entry of zip.getEntries()) {
const file = entry.entryName
if (entry.isDirectory) {
core.info(`Skipping ${file}: entry is a directory`)
continue
}
if (!this.fileNameMatch(file)) {
core.info(`Skipping ${file}: filename does not match pattern`)
continue
}
const content = zip.readAsText(entry)
files.push({file, content})
core.info(`Read ${file}: ${content.length} chars`)
}
if (result[reportName]) {
result[reportName].push(...files)
} else {
result[reportName] = files
}
} finally {
core.endGroup()
}
}
return result
}