Skip to content

Commit

Permalink
fix: Fetch artifacts in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
Kesin11 committed Sep 4, 2020
1 parent 95311bc commit 0214b48
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
14 changes: 9 additions & 5 deletions src/client/github_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,18 @@ export class GithubClient {
run_id: runId
})

// Unarchive zip artifacts
const zipExtractor = new ZipExtractor()
for (const artifact of res.data.artifacts) {
const res = await this.axios.get(
const nameResponse = res.data.artifacts.map((artifact) => {
const response = this.axios.get(
artifact.archive_download_url,
{ responseType: 'arraybuffer'}
)
await zipExtractor.put(artifact.name, res.data)
return { name: artifact.name, response }
})

// Unarchive zip artifacts
const zipExtractor = new ZipExtractor()
for (const { name, response } of nameResponse) {
await zipExtractor.put(name, (await response).data)
}
const zipEntries = await zipExtractor.extract(globs)
await zipExtractor.rmTmpZip()
Expand Down
12 changes: 8 additions & 4 deletions src/client/jenkins_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,19 @@ export class JenkinsClient {
}

async fetchArtifacts(jobName: string, runId: number, paths: string[]): Promise<Artifact[]> {
const artifacts = []
for (const path of paths) {
const res = await this.axios.get(
const pathResponses = paths.map((path) => {
const response = this.axios.get(
`job/${jobName}/${runId}/artifact/${path}`,
{ responseType: 'arraybuffer'}
)
return { path, response }
})

const artifacts = []
for (const { path, response } of pathResponses) {
artifacts.push({
path,
data: res.data as ArrayBuffer
data: (await response).data as ArrayBuffer
})
}
return artifacts
Expand Down

0 comments on commit 0214b48

Please sign in to comment.