Skip to content

Commit

Permalink
artifact-provider: improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Dorner committed Feb 15, 2021
1 parent da9cc2c commit 1ae86a1
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 35 deletions.
53 changes: 34 additions & 19 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

43 changes: 29 additions & 14 deletions src/input-providers/artifact-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/github-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1ae86a1

Please sign in to comment.