|
15 | 15 | import subprocess
|
16 | 16 | import textwrap
|
17 | 17 | import unidiff
|
| 18 | +import urllib3 |
18 | 19 | import yaml
|
19 | 20 | import contextlib
|
20 | 21 | import datetime
|
|
26 | 27 | from github.Requester import Requester
|
27 | 28 | from github.PaginatedList import PaginatedList
|
28 | 29 | from github.WorkflowRun import WorkflowRun
|
29 |
| -from github.Artifact import Artifact |
30 | 30 | from typing import Any, List, Optional, TypedDict
|
31 | 31 |
|
32 | 32 | DIFF_HEADER_LINE_LENGTH = 5
|
@@ -354,16 +354,6 @@ def post_annotations(self, review):
|
354 | 354 | "POST", url, parameters=review, headers=headers
|
355 | 355 | )
|
356 | 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 |
| - |
367 | 357 |
|
368 | 358 | @contextlib.contextmanager
|
369 | 359 | def message_group(title: str):
|
@@ -935,17 +925,18 @@ def download_artifacts(pull: PullRequest, workflow_id: int):
|
935 | 925 | )
|
936 | 926 | return None, None
|
937 | 927 |
|
938 |
| - try: |
939 |
| - data = pull.download_json_artifact(artifact) |
940 |
| - except GithubException as exc: |
| 928 | + headers = { |
| 929 | + "Accept": "application/vnd.github+json", |
| 930 | + "Authorization": f"Bearer {pull.token}", |
| 931 | + } |
| 932 | + r = urllib3.request("GET", artifact.archive_download_url, headers=headers) |
| 933 | + if r.status is not 200: |
941 | 934 | print(
|
942 |
| - f"WARNING: Couldn't automatically download artifacts for workflow '{workflow_id}', response was: {exc}" |
| 935 | + f"WARNING: Couldn't automatically download artifacts for workflow '{workflow_id}', response was: {r}: {r.reason}" |
943 | 936 | )
|
944 | 937 | return None, None
|
945 | 938 |
|
946 |
| - contents = b"".join(data["data"].iter_content()) |
947 |
| - |
948 |
| - data = zipfile.ZipFile(io.BytesIO(contents)) |
| 939 | + data = zipfile.ZipFile(io.BytesIO(r.data)) |
949 | 940 | filenames = data.namelist()
|
950 | 941 |
|
951 | 942 | metadata = (
|
|
0 commit comments