Skip to content
Permalink
Browse files

Add Windows support to `with_curl_artifact_script`

  • Loading branch information
SimonSapin committed Nov 21, 2019
1 parent b96a36c commit a11dc7006f495050b56e1ec402d5a5522b32d9e1
Showing with 28 additions and 25 deletions.
  1. +28 −25 etc/taskcluster/decisionlib.py
@@ -304,6 +304,21 @@ def find_or_create(self, index_path=None):
SHARED.found_or_created_indexed_tasks[index_path] = task_id
return task_id

def with_curl_script(self, url, file_path):
return self \
.with_script("""
curl --retry 5 --connect-timeout 10 -Lf "%s" -o "%s"
""" % (url, file_path))

def with_curl_artifact_script(self, task_id, artifact_name, out_directory=""):
queue_service = CONFIG.tc_root_url + "/api/queue"
return self \
.with_dependencies(task_id) \
.with_curl_script(
queue_service + "/v1/task/%s/artifacts/public/%s" % (task_id, artifact_name),
os.path.join(out_directory, url_basename(artifact_name)),
)


class GenericWorkerTask(Task):
"""
@@ -506,6 +521,19 @@ def with_git(self):
path="git",
)

def with_curl_script(self, url, file_path):
self.with_curl()
return super().with_curl_script(url, file_path)

def with_curl(self):
return self \
.with_path_from_homedir("curl\\curl-7.67.0-win64-mingw\\bin") \
.with_directory_mount(
"https://curl.haxx.se/windows/dl-7.67.0_4/curl-7.67.0_4-win64-mingw.zip",
sha256="1d50deeac7f945ed75149e6300f6d21f007a6b942ab851a119ed76cdef27d714",
path="curl",
)

def with_rustup(self):
"""
Download rustup.rs and make it available to task commands,
@@ -583,10 +611,6 @@ def with_python2(self):


class UnixTaskMixin(Task):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.curl_scripts_count = 0

def with_repo(self, shallow=True, alternate_object_dir=None):
"""
Make a shallow clone the git repository at the start of the task.
@@ -620,27 +644,6 @@ def with_repo(self, shallow=True, alternate_object_dir=None):
)
))

def with_curl_script(self, url, file_path):
self.curl_scripts_count += 1
n = self.curl_scripts_count
return self \
.with_env(**{
"CURL_%s_URL" % n: url,
"CURL_%s_PATH" % n: file_path,
}) \
.with_script("""
curl --retry 5 --connect-timeout 10 -Lf "$CURL_{n}_URL" -o "$CURL_{n}_PATH"
""".format(n=n))

def with_curl_artifact_script(self, task_id, artifact_name, out_directory=""):
queue_service = CONFIG.tc_root_url + "/api/queue"
return self \
.with_dependencies(task_id) \
.with_curl_script(
queue_service + "/v1/task/%s/artifacts/public/%s" % (task_id, artifact_name),
os.path.join(out_directory, url_basename(artifact_name)),
)


class MacOsGenericWorkerTask(UnixTaskMixin, GenericWorkerTask):
"""

0 comments on commit a11dc70

Please sign in to comment.
You can’t perform that action at this time.