Skip to content

Commit

Permalink
Show artifact download progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Dorner committed Feb 15, 2021
1 parent 8819b4b commit da9cc2c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/input-providers/artifact-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class ArtifactProvider implements InputProvider {
}

for (const art of artifacts) {
await downloadArtifact(this.octokit, art.id, art.name, this.token)
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)
Expand Down
7 changes: 4 additions & 3 deletions src/utils/github-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export async function downloadArtifact(
octokit: InstanceType<typeof GitHub>,
artifactId: number,
fileName: string,
size: number,
token: string
): Promise<void> {
core.startGroup(`Downloading artifact ${fileName}`)
Expand Down Expand Up @@ -72,9 +73,9 @@ export async function downloadArtifact(
const fileWriterStream = createWriteStream(fileName)

core.info(`Downloading ${url}`)
downloadStream.on('downloadProgress', ({transferred, total, percent}) => {
const percentage = Math.round(percent * 100)
core.info(`Progress: ${transferred}/${total} (${percentage}%)`)
downloadStream.on('downloadProgress', ({transferred}) => {
const percentage = Math.round(transferred / size * 100)
core.info(`Progress: ${transferred}/${size} (${percentage}%)`)
})
await asyncStream(downloadStream, fileWriterStream)
} finally {
Expand Down

0 comments on commit da9cc2c

Please sign in to comment.