Skip to content

Commit 6b82061

Browse files
authored
Use curl to download github artifacts during bloat report (#32666)
* Use CURL to download artifact data. ghapi does not seem to work, however the documented curl way does * Switch back to github_token * Restyle * Remove unused item
1 parent 84913af commit 6b82061

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

.github/workflows/bloat_check.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ jobs:
5050
--github-limit-artifacts 500 \
5151
--github-limit-comments 20 \
5252
--github-repository project-chip/connectedhomeip \
53-
--github-api-token "${{ secrets.BLOAT_REPORT }}"
53+
--github-api-token "${{ secrets.GITHUB_TOKEN }}"

scripts/tools/memory/memdf/util/github.py

+26-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import itertools
1919
import logging
2020
import os
21+
import subprocess
2122
from typing import Iterable, Mapping, Optional
2223

2324
import dateutil # type: ignore
@@ -173,7 +174,31 @@ def download_artifact(self, artifact_id: int):
173174
logging.debug('Downloading artifact %d', artifact_id)
174175
try:
175176
assert self.ghapi
176-
return self.ghapi.actions.download_artifact(artifact_id, 'zip')
177+
178+
# It seems like github artifact download is at least partially broken
179+
# (see https://github.com/project-chip/connectedhomeip/issues/32656)
180+
#
181+
# This makes `self.ghapi.actions.download_artifact` not work
182+
#
183+
# Oddly enough downloading via CURL seems ok
184+
owner = self.config['github.owner']
185+
repo = self.config['github.repo']
186+
token = self.config['github.token']
187+
188+
download_url = f"https://api.github.com/repos/{owner}/{repo}/actions/artifacts/{artifact_id}/zip"
189+
190+
# Follow https://docs.github.com/en/rest/actions/artifacts?apiVersion=2022-11-28#download-an-artifact
191+
return subprocess.check_output(
192+
[
193+
'curl',
194+
'-L',
195+
'-H', 'Accept: application/vnd.github+json',
196+
'-H', f'Authorization: Bearer {token}',
197+
'-H', 'X-GitHub-Api-Version: 2022-11-28',
198+
'--output', '-',
199+
download_url
200+
]
201+
)
177202
except Exception as e:
178203
logging.error('Failed to download artifact %d: %s', artifact_id, e)
179204
return None

0 commit comments

Comments
 (0)