Skip to content

bot: Use public download url for artifacts #210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion bot/code_coverage_bot/taskcluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
from zipfile import is_zipfile

import requests
import structlog
import taskcluster

from code_coverage_bot.utils import retry
from code_coverage_tools.taskcluster import TaskclusterConfig

logger = structlog.getLogger(__name__)
taskcluster_config = TaskclusterConfig()


Expand Down Expand Up @@ -77,8 +79,11 @@ def download_artifact(artifact_path, task_id, artifact_name):
return artifact_path

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

def perform_download():
r = requests.get(url, stream=True)
Expand Down
6 changes: 3 additions & 3 deletions bot/tests/test_taskcluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,14 @@ def test_get_platform(task_name, expected):
def test_download_artifact_forbidden(mocked_sleep, mock_taskcluster, tmpdir):
responses.add(
responses.GET,
"http://taskcluster.test/api/queue/v1/task/FBdocjnAQOW_GJDOfmgjxw/artifacts/public%2Ftest_info%2Fcode-coverage-grcov.zip", # noqa
"https://queue.taskcluster.net/v1/task/FBdocjnAQOW_GJDOfmgjxw/artifacts/public%2Ftest_info%2Fcode-coverage-grcov.zip", # noqa
body="xml error...",
status=403,
)

with pytest.raises(
requests.exceptions.HTTPError,
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
match="403 Client Error: Forbidden for url: https://queue.taskcluster.net/v1/task/FBdocjnAQOW_GJDOfmgjxw/artifacts/public%2Ftest_info%2Fcode-coverage-grcov.zip", # noqa
):
taskcluster.download_artifact(
os.path.join(tmpdir.strpath, "windows_reftest-6_code-coverage-grcov.zip"),
Expand All @@ -282,7 +282,7 @@ def test_download_artifact_forbidden(mocked_sleep, mock_taskcluster, tmpdir):
def test_download_artifact_badzip(mocked_sleep, mock_taskcluster, tmpdir):
responses.add(
responses.GET,
"http://taskcluster.test/api/queue/v1/task/FBdocjnAQOW_GJDOfmgjxw/artifacts/public%2Ftest_info%2Fcode-coverage-grcov.zip", # noqa
"https://queue.taskcluster.net/v1/task/FBdocjnAQOW_GJDOfmgjxw/artifacts/public%2Ftest_info%2Fcode-coverage-grcov.zip", # noqa
body="NOT A ZIP FILE",
status=200,
stream=True,
Expand Down