From d8b630779d0a265127919902b4387f399e561814 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Sun, 3 Nov 2019 15:08:44 +0100 Subject: [PATCH] Support both Taskcluster deployments Part of https://bugzilla.mozilla.org/show_bug.cgi?id=1574648 --- .taskcluster.yml | 15 ++++++++++++--- etc/taskcluster/decision_task.py | 17 ++++++++++++----- etc/taskcluster/decisionlib.py | 11 ++++++++++- etc/taskcluster/mock.py | 1 + 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/.taskcluster.yml b/.taskcluster.yml index 360af84ad3a4..649cec45f554 100644 --- a/.taskcluster.yml +++ b/.taskcluster.yml @@ -8,7 +8,10 @@ policy: tasks: $let: task_common: - provisionerId: aws-provisioner-v1 + provisionerId: + $if: "taskcluster_root_url == 'https://taskcluster.net'" + then: aws-provisioner-v1 + else: proj-servo created: {$fromNow: ''} deadline: {$fromNow: '1 day'} extra: @@ -53,7 +56,10 @@ tasks: description: "" owner: ${event.pusher.name}@users.noreply.github.com source: ${event.compare} - workerType: servo-docker-worker + workerType: + $if: "taskcluster_root_url == 'https://taskcluster.net'" + then: servo-docker-worker + else: docker scopes: - "assume:repo:github.com/servo/servo:branch:${branch}" routes: @@ -82,7 +88,10 @@ tasks: description: "" owner: ${event.sender.login}@users.noreply.github.com source: ${event.pull_request.url} - workerType: servo-docker-untrusted + workerType: + $if: "taskcluster_root_url == 'https://taskcluster.net'" + then: servo-docker-untrusted + else: docker-untrusted scopes: - "assume:repo:github.com/servo/servo:pull-request" routes: diff --git a/etc/taskcluster/decision_task.py b/etc/taskcluster/decision_task.py index b166c6d8fe9e..050c74fc55d2 100644 --- a/etc/taskcluster/decision_task.py +++ b/etc/taskcluster/decision_task.py @@ -157,7 +157,9 @@ def mocked_only(): def linux_tidy_unit_untrusted(): return ( decisionlib.DockerWorkerTask("Tidy + dev build + unit tests") - .with_worker_type("servo-docker-untrusted") + .with_worker_type( + "servo-docker-untrusted" if CONFIG.legacy_tc_deployment else "docker-untrusted" + ) .with_treeherder("Linux x64", "Tidy+Unit") .with_max_run_time_minutes(60) .with_dockerfile(dockerfile_path("build")) @@ -731,7 +733,7 @@ def dockerfile_path(name): def linux_task(name): return ( decisionlib.DockerWorkerTask(name) - .with_worker_type("servo-docker-worker") + .with_worker_type("servo-docker-worker" if CONFIG.legacy_tc_deployment else "docker") .with_treeherder_required() ) @@ -739,7 +741,7 @@ def linux_task(name): def windows_task(name): return ( decisionlib.WindowsGenericWorkerTask(name) - .with_worker_type("servo-win2016") + .with_worker_type("servo-win2016" if CONFIG.legacy_tc_deployment else "win2016") .with_treeherder_required() ) @@ -968,10 +970,15 @@ def magicleap_nightly(): CONFIG.task_name_template = "Servo: %s" -CONFIG.index_prefix = "project.servo.servo" -CONFIG.docker_image_build_worker_type = "servo-docker-worker" CONFIG.docker_images_expire_in = build_dependencies_artifacts_expire_in CONFIG.repacked_msi_files_expire_in = build_dependencies_artifacts_expire_in +if CONFIG.legacy_tc_deployment: + CONFIG.index_prefix = "project.servo.servo" + CONFIG.docker_image_build_worker_type = "servo-docker-worker" +else: # pragma: no cover + CONFIG.index_prefix = "project.servo" + CONFIG.default_provisioner_id = "proj-servo" + CONFIG.docker_image_build_worker_type = "docker" if __name__ == "__main__": # pragma: no cover diff --git a/etc/taskcluster/decisionlib.py b/etc/taskcluster/decisionlib.py index c518ed216e03..0436612dafab 100644 --- a/etc/taskcluster/decisionlib.py +++ b/etc/taskcluster/decisionlib.py @@ -57,6 +57,15 @@ def __init__(self): self.git_ref = os.environ.get("GIT_REF") self.git_sha = os.environ.get("GIT_SHA") + root_url = os.environ.get("TASKCLUSTER_ROOT_URL") + self.legacy_tc_deployment = root_url == "https://taskcluster.net" + + if self.legacy_tc_deployment: + self.default_provisioner_id = "aws-provisioner-v1" + else: # pragma: no cover + self.default_provisioner_id = "proj-example" + + def task_id(self): if hasattr(self, "_task_id"): return self._task_id @@ -131,7 +140,7 @@ def __init__(self, name): self.name = name self.description = "" self.scheduler_id = "taskcluster-github" - self.provisioner_id = "aws-provisioner-v1" + self.provisioner_id = CONFIG.default_provisioner_id self.worker_type = "github-worker" self.deadline_in = "1 day" self.expires_in = "1 year" diff --git a/etc/taskcluster/mock.py b/etc/taskcluster/mock.py index 559c837ef82f..10fe23b22a16 100755 --- a/etc/taskcluster/mock.py +++ b/etc/taskcluster/mock.py @@ -44,6 +44,7 @@ def findTask(self, path): sys.dont_write_bytecode = True os.environ.update(**{k: k for k in "TASK_ID TASK_OWNER TASK_SOURCE GIT_URL GIT_SHA".split()}) os.environ["GIT_REF"] = "refs/heads/auto" +os.environ["TASKCLUSTER_ROOT_URL"] = "https://taskcluster.net" import decision_task print("\n# Push:")