Skip to content
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

fix: artifact download #115

Merged
merged 1 commit into from Feb 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 13 additions & 4 deletions post/clang_tidy_review/clang_tidy_review/__init__.py
Expand Up @@ -26,7 +26,8 @@
from github.Requester import Requester
from github.PaginatedList import PaginatedList
from github.WorkflowRun import WorkflowRun
from typing import List, Optional, TypedDict
from github.Artifact import Artifact
from typing import Any, List, Optional, TypedDict

DIFF_HEADER_LINE_LENGTH = 5
FIXES_FILE = "clang_tidy_review.yaml"
Expand Down Expand Up @@ -353,6 +354,16 @@ def post_annotations(self, review):
"POST", url, parameters=review, headers=headers
)

def download_json_artifact(self, artifact: Artifact) -> Any:
headers = {
"Accept": "application/vnd.github+json",
"Authorization": f"Bearer {self.token}",
}
_, data = self.repo._requester.requestJsonAndCheck(
"GET", artifact.archive_download_url, headers=headers
)
return data


@contextlib.contextmanager
def message_group(title: str):
Expand Down Expand Up @@ -925,9 +936,7 @@ def download_artifacts(pull: PullRequest, workflow_id: int):
return None, None

try:
_, data = pull.repo._requester.requestJsonAndCheck(
"GET", artifact.archive_download_url, headers=pull.headers("json")
)
data = pull.download_json_artifact(artifact)
except GithubException as exc:
print(
f"WARNING: Couldn't automatically download artifacts for workflow '{workflow_id}', response was: {exc}"
Expand Down