Skip to content

Commit

Permalink
Handle separate downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
bigdaz committed Dec 24, 2023
1 parent 2f8a784 commit be32345
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/dependency-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ async function uploadDependencyGraphs(dependencyGraphFiles: string[]): Promise<v
for (const dependencyGraphFile of dependencyGraphFiles) {
const relativePath = getRelativePathFromWorkspace(dependencyGraphFile)
core.info(`Uploading dependency graph file: ${relativePath}`)
await artifactClient.uploadArtifact(path.basename(dependencyGraphFile), [dependencyGraphFile], workspaceDirectory, {
const artifactName = `dependency-graph_${path.basename(dependencyGraphFile)}`
await artifactClient.uploadArtifact(artifactName, [dependencyGraphFile], workspaceDirectory, {
retentionDays: getArtifactRetentionDays()
})
}
Expand Down Expand Up @@ -172,16 +173,21 @@ async function retrieveDependencyGraphsForWorkflowRun(runId: number, workspaceDi
async function retrieveDependencyGraphsForCurrentWorkflow(workspaceDirectory: string): Promise<string[]> {
const artifactClient = new DefaultArtifactClient()
const downloadPath = path.resolve(workspaceDirectory, 'dependency-graph')
const artifact = await artifactClient.getArtifact(DEPENDENCY_GRAPH_ARTIFACT)
core.info(`Downloading dependency-graph artifact to ${downloadPath}`)
const downloadedArtifact = await artifactClient.downloadArtifact(artifact.artifact.id, {
path: downloadPath

const dependencyGraphArtifacts = (await artifactClient.listArtifacts({
latest: true
})).artifacts.filter(candidate => {
return candidate.name.startsWith('dependency-graph_')
})
if (!downloadedArtifact.downloadPath) {
throw new Error(`Dependency graph artifact not found.`)

const downloadedPaths: string[] = []
for (const artifact of dependencyGraphArtifacts) {
const downloadedArtifact = await artifactClient.downloadArtifact(artifact.id)
core.info(`Downloading dependency-graph artifact ${artifact.name} to ${downloadedArtifact.downloadPath}`)
downloadedPaths.push(downloadedArtifact.downloadPath!)
}
core.info(`Downloaded dependency-graph artifact to ${downloadedArtifact.downloadPath}`)
return await findDependencyGraphFiles(downloadedArtifact.downloadPath)

return downloadedPaths
}

async function findDependencyGraphFiles(dir: string): Promise<string[]> {
Expand Down

0 comments on commit be32345

Please sign in to comment.