Skip to content

Fix duplicate artifact downloads (again) #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 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.

16 changes: 10 additions & 6 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

private readonly octokit

private readonly artifactCache = new Map<string, DownloadedArtifact | null>()
private readonly artifactCache = new Map<
string,
Promise<DownloadedArtifact | null>
>()

constructor(
private readonly token: string,
Expand Down Expand Up @@ -82,17 +85,18 @@
private async getReportsArtifact(
base: GitBranch
): Promise<DownloadedArtifact | null> {
if (this.artifactCache.has(base.sha)) {
return this.artifactCache.get(base.sha) ?? null
const cached = this.artifactCache.get(base.sha)
if (cached) {

Check failure on line 89 in src/api.ts

View workflow job for this annotation

GitHub Actions / GitHub Actions Test

<βœ“> Code coverage | Branch coverage

1st branch is not taken in any test case.
return cached
}
const result = await downloadReportsArtifact(
const promise = downloadReportsArtifact(
this.artifact,
this.octokit,
base,
this.token
)
this.artifactCache.set(base.sha, result)
return result
this.artifactCache.set(base.sha, promise)
return promise
}

private convertComment(
Expand Down
Loading