mirror of
https://github.com/dorny/test-reporter.git
synced 2026-02-01 02:45:22 -08:00
artifact-provider: improve logging
This commit is contained in:
@@ -67,20 +67,35 @@ export class ArtifactProvider implements InputProvider {
|
||||
}
|
||||
|
||||
for (const art of artifacts) {
|
||||
await downloadArtifact(this.octokit, art.id, art.name, art.size_in_bytes, this.token)
|
||||
const reportName = this.getReportName(art.name)
|
||||
const files: FileContent[] = []
|
||||
const zip = new Zip(art.name)
|
||||
for (const entry of zip.getEntries()) {
|
||||
const file = entry.name
|
||||
if (entry.isDirectory || !this.fileNameMatch(file)) continue
|
||||
const content = zip.readAsText(entry)
|
||||
files.push({file, content})
|
||||
}
|
||||
if (result[reportName]) {
|
||||
result[reportName].push(...files)
|
||||
} else {
|
||||
result[reportName] = files
|
||||
const fileName = `${art.name}.zip`
|
||||
await downloadArtifact(this.octokit, art.id, fileName, art.size_in_bytes, 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.name
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ export async function downloadArtifact(
|
||||
|
||||
core.info(`Downloading ${url}`)
|
||||
downloadStream.on('downloadProgress', ({transferred}) => {
|
||||
const percentage = Math.round(transferred / size * 100)
|
||||
const percentage = Math.round((transferred / size) * 100)
|
||||
core.info(`Progress: ${transferred}/${size} (${percentage}%)`)
|
||||
})
|
||||
await asyncStream(downloadStream, fileWriterStream)
|
||||
|
||||
Reference in New Issue
Block a user