Skip to content

Commit e9eaaaf

Browse files
authored
bot: Use public download url for artifacts, refs taskcluster/taskcluster-proxy#44 (#210)
1 parent b99a669 commit e9eaaaf

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

bot/code_coverage_bot/taskcluster.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
from zipfile import is_zipfile
66

77
import requests
8+
import structlog
89
import taskcluster
910

1011
from code_coverage_bot.utils import retry
1112
from code_coverage_tools.taskcluster import TaskclusterConfig
1213

14+
logger = structlog.getLogger(__name__)
1315
taskcluster_config = TaskclusterConfig()
1416

1517

@@ -77,8 +79,11 @@ def download_artifact(artifact_path, task_id, artifact_name):
7779
return artifact_path
7880

7981
# Build artifact public url
80-
queue = taskcluster_config.get_service("queue")
82+
# Use un-authenticated Taskcluster client to avoid taskcluster-proxy rewrite issue
83+
# https://github.com/taskcluster/taskcluster-proxy/issues/44
84+
queue = taskcluster.Queue({"rootUrl": "https://taskcluster.net"})
8185
url = queue.buildUrl("getLatestArtifact", task_id, artifact_name)
86+
logger.debug("Downloading artifact", url=url)
8287

8388
def perform_download():
8489
r = requests.get(url, stream=True)

bot/tests/test_taskcluster.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,14 @@ def test_get_platform(task_name, expected):
260260
def test_download_artifact_forbidden(mocked_sleep, mock_taskcluster, tmpdir):
261261
responses.add(
262262
responses.GET,
263-
"http://taskcluster.test/api/queue/v1/task/FBdocjnAQOW_GJDOfmgjxw/artifacts/public%2Ftest_info%2Fcode-coverage-grcov.zip", # noqa
263+
"https://queue.taskcluster.net/v1/task/FBdocjnAQOW_GJDOfmgjxw/artifacts/public%2Ftest_info%2Fcode-coverage-grcov.zip", # noqa
264264
body="xml error...",
265265
status=403,
266266
)
267267

268268
with pytest.raises(
269269
requests.exceptions.HTTPError,
270-
match="403 Client Error: Forbidden for url: http://taskcluster.test/api/queue/v1/task/FBdocjnAQOW_GJDOfmgjxw/artifacts/public%2Ftest_info%2Fcode-coverage-grcov.zip", # noqa
270+
match="403 Client Error: Forbidden for url: https://queue.taskcluster.net/v1/task/FBdocjnAQOW_GJDOfmgjxw/artifacts/public%2Ftest_info%2Fcode-coverage-grcov.zip", # noqa
271271
):
272272
taskcluster.download_artifact(
273273
os.path.join(tmpdir.strpath, "windows_reftest-6_code-coverage-grcov.zip"),
@@ -282,7 +282,7 @@ def test_download_artifact_forbidden(mocked_sleep, mock_taskcluster, tmpdir):
282282
def test_download_artifact_badzip(mocked_sleep, mock_taskcluster, tmpdir):
283283
responses.add(
284284
responses.GET,
285-
"http://taskcluster.test/api/queue/v1/task/FBdocjnAQOW_GJDOfmgjxw/artifacts/public%2Ftest_info%2Fcode-coverage-grcov.zip", # noqa
285+
"https://queue.taskcluster.net/v1/task/FBdocjnAQOW_GJDOfmgjxw/artifacts/public%2Ftest_info%2Fcode-coverage-grcov.zip", # noqa
286286
body="NOT A ZIP FILE",
287287
status=200,
288288
stream=True,

0 commit comments

Comments
 (0)