From 3fb42e9e885549bfa69acb9b53775dd0cd09ab32 Mon Sep 17 00:00:00 2001 From: Nerixyz Date: Mon, 25 Mar 2024 18:35:58 +0100 Subject: [PATCH 1/2] deps: update to `actions/upload-action@v4` --- upload/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upload/action.yml b/upload/action.yml index d3744d3..a4395d2 100644 --- a/upload/action.yml +++ b/upload/action.yml @@ -7,7 +7,7 @@ branding: runs: using: 'composite' steps: - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: clang-tidy-review path: | From 1d30432c20c44eaecaa73a751591416d4dc9fe4b Mon Sep 17 00:00:00 2001 From: Nerixyz Date: Mon, 25 Mar 2024 19:11:12 +0100 Subject: [PATCH 2/2] fix: download artifact as blob and follow redirects --- .../clang_tidy_review/__init__.py | 27 +++++++------------ post/clang_tidy_review/pyproject.toml | 1 + 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/post/clang_tidy_review/clang_tidy_review/__init__.py b/post/clang_tidy_review/clang_tidy_review/__init__.py index 4444fdb..69fc788 100644 --- a/post/clang_tidy_review/clang_tidy_review/__init__.py +++ b/post/clang_tidy_review/clang_tidy_review/__init__.py @@ -15,6 +15,7 @@ import subprocess import textwrap import unidiff +import urllib3 import yaml import contextlib import datetime @@ -26,7 +27,6 @@ from github.Requester import Requester from github.PaginatedList import PaginatedList from github.WorkflowRun import WorkflowRun -from github.Artifact import Artifact from typing import Any, List, Optional, TypedDict DIFF_HEADER_LINE_LENGTH = 5 @@ -354,16 +354,6 @@ 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): @@ -935,17 +925,18 @@ def download_artifacts(pull: PullRequest, workflow_id: int): ) return None, None - try: - data = pull.download_json_artifact(artifact) - except GithubException as exc: + headers = { + "Accept": "application/vnd.github+json", + "Authorization": f"Bearer {pull.token}", + } + r = urllib3.request("GET", artifact.archive_download_url, headers=headers) + if r.status is not 200: print( - f"WARNING: Couldn't automatically download artifacts for workflow '{workflow_id}', response was: {exc}" + f"WARNING: Couldn't automatically download artifacts for workflow '{workflow_id}', response was: {r}: {r.reason}" ) return None, None - contents = b"".join(data["data"].iter_content()) - - data = zipfile.ZipFile(io.BytesIO(contents)) + data = zipfile.ZipFile(io.BytesIO(r.data)) filenames = data.namelist() metadata = ( diff --git a/post/clang_tidy_review/pyproject.toml b/post/clang_tidy_review/pyproject.toml index 01ba865..c7ab2a9 100644 --- a/post/clang_tidy_review/pyproject.toml +++ b/post/clang_tidy_review/pyproject.toml @@ -16,6 +16,7 @@ dependencies = [ "PyGithub ~= 2.1", "unidiff ~= 0.6.0", "pyyaml ~= 6.0.1", + "urllib3 ~= 2.2.1", ] keywords = ["C++", "static-analysis"] dynamic = ["version"]