artifact-provider: improve logging

This commit is contained in:
Michal Dorner 2021-02-15 20:46:28 +01:00
parent da9cc2c0d9
commit 1ae86a176d
No known key found for this signature in database
GPG key ID: 9EEE04B48DA36786
4 changed files with 65 additions and 35 deletions

View file

@ -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()
}
}

View file

@ -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)