|
26 | 26 | from github.Requester import Requester
|
27 | 27 | from github.PaginatedList import PaginatedList
|
28 | 28 | from github.WorkflowRun import WorkflowRun
|
29 |
| -from typing import List, Optional, TypedDict |
| 29 | +from github.Artifact import Artifact |
| 30 | +from typing import Any, List, Optional, TypedDict |
30 | 31 |
|
31 | 32 | DIFF_HEADER_LINE_LENGTH = 5
|
32 | 33 | FIXES_FILE = "clang_tidy_review.yaml"
|
@@ -353,6 +354,16 @@ def post_annotations(self, review):
|
353 | 354 | "POST", url, parameters=review, headers=headers
|
354 | 355 | )
|
355 | 356 |
|
| 357 | + def download_json_artifact(self, artifact: Artifact) -> Any: |
| 358 | + headers = { |
| 359 | + "Accept": "application/vnd.github+json", |
| 360 | + "Authorization": f"Bearer {self.token}", |
| 361 | + } |
| 362 | + _, data = self.repo._requester.requestJsonAndCheck( |
| 363 | + "GET", artifact.archive_download_url, headers=headers |
| 364 | + ) |
| 365 | + return data |
| 366 | + |
356 | 367 |
|
357 | 368 | @contextlib.contextmanager
|
358 | 369 | def message_group(title: str):
|
@@ -925,9 +936,7 @@ def download_artifacts(pull: PullRequest, workflow_id: int):
|
925 | 936 | return None, None
|
926 | 937 |
|
927 | 938 | try:
|
928 |
| - _, data = pull.repo._requester.requestJsonAndCheck( |
929 |
| - "GET", artifact.archive_download_url, headers=pull.headers("json") |
930 |
| - ) |
| 939 | + data = pull.download_json_artifact(artifact) |
931 | 940 | except GithubException as exc:
|
932 | 941 | print(
|
933 | 942 | f"WARNING: Couldn't automatically download artifacts for workflow '{workflow_id}', response was: {exc}"
|
|
0 commit comments