Skip to content

Commit

Permalink
Merge pull request #115 from Nerixyz/fix/pr-stuff
Browse files Browse the repository at this point in the history
fix: artifact download
  • Loading branch information
ZedThree committed Feb 12, 2024
2 parents 4923dc7 + 0b130f2 commit 9a32adc
Showing 1 changed file with 13 additions and 4 deletions.
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

0 comments on commit 9a32adc

Please sign in to comment.