Taskcluster: add initial Windows task

This commit is contained in:
Simon Sapin 2018-09-30 22:32:47 +02:00
parent 1bab9fb64f
commit f9038a78df
2 changed files with 96 additions and 52 deletions

View file

@ -16,6 +16,7 @@ def main():
linux_tidy_unit() linux_tidy_unit()
#linux_wpt() #linux_wpt()
android_arm32() android_arm32()
windows_dev()
# https://tools.taskcluster.net/hooks/project-servo/daily # https://tools.taskcluster.net/hooks/project-servo/daily
elif task_for == "daily": elif task_for == "daily":
@ -56,7 +57,7 @@ def linux_tidy_unit():
./etc/ci/lockfile_changed.sh ./etc/ci/lockfile_changed.sh
./etc/ci/check_no_panic.sh ./etc/ci/check_no_panic.sh
""", """,
**build_kwargs **linux_build_kwargs
) )
@ -68,7 +69,7 @@ def with_rust_nightly():
./mach build --dev ./mach build --dev
./mach test-unit ./mach test-unit
""", """,
**build_kwargs **linux_build_kwargs
) )
@ -90,6 +91,31 @@ def android_arm32():
"/repo/target/armv7-linux-androideabi/release/servoapp.apk", "/repo/target/armv7-linux-androideabi/release/servoapp.apk",
"/repo/target/armv7-linux-androideabi/release/servoview.aar", "/repo/target/armv7-linux-androideabi/release/servoview.aar",
], ],
**linux_build_kwargs
)
def windows_dev():
return decision.create_task(
task_name="Windows x86_64: clone only",
worker_type="servo-win2016",
script="""
dir
""",
mounts=[
{
"directory": "git",
"format": "zip",
"content": {
"url": "https://github.com/git-for-windows/git/releases/download/" +
"v2.19.0.windows.1/MinGit-2.19.0-64-bit.zip",
"sha256": "424d24b5fc185a9c5488d7872262464f2facab4f1d4693ea8008196f14a3c19b",
}
},
],
homedir_path=[
"git\\cmd",
],
**build_kwargs **build_kwargs
) )
@ -120,7 +146,7 @@ def linux_release_build():
artifacts=[ artifacts=[
"/target.tar.gz", "/target.tar.gz",
], ],
**build_kwargs **linux_build_kwargs
) )
@ -219,7 +245,7 @@ def dockerfile_path(name):
decision = DecisionTask( decision = DecisionTask(
task_name_template="Servo: %s", task_name_template="Servo: %s",
index_prefix="project.servo.servo", index_prefix="project.servo.servo",
worker_type="servo-docker-worker", default_worker_type="servo-docker-worker",
) )
# https://docs.taskcluster.net/docs/reference/workers/docker-worker/docs/caches # https://docs.taskcluster.net/docs/reference/workers/docker-worker/docs/caches
@ -234,11 +260,14 @@ build_caches = {
} }
build_kwargs = { build_kwargs = {
"max_run_time_minutes": 60, "max_run_time_minutes": 60,
"dockerfile": dockerfile_path("build"),
"env": build_env, "env": build_env,
}
linux_build_kwargs = dict(**build_kwargs, **{
"worker_type": "servo-docker-worker",
"dockerfile": dockerfile_path("build"),
"scopes": cache_scopes, "scopes": cache_scopes,
"cache": build_caches, "cache": build_caches,
} })
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -35,11 +35,11 @@ class DecisionTask:
"0a7d012ce444d62ffb9e7f06f0c52fedc24b68c2060711b313263367f7272d9d" "0a7d012ce444d62ffb9e7f06f0c52fedc24b68c2060711b313263367f7272d9d"
def __init__(self, *, index_prefix="garbage.servo-decisionlib", task_name_template="%s", def __init__(self, *, index_prefix="garbage.servo-decisionlib", task_name_template="%s",
worker_type="github-worker", docker_image_cache_expiry="1 month", default_worker_type="github-worker", docker_image_cache_expiry="1 month",
routes_for_all_subtasks=None, scopes_for_all_subtasks=None): routes_for_all_subtasks=None, scopes_for_all_subtasks=None):
self.task_name_template = task_name_template self.task_name_template = task_name_template
self.index_prefix = index_prefix self.index_prefix = index_prefix
self.worker_type = worker_type self.default_worker_type = default_worker_type
self.docker_image_cache_expiry = docker_image_cache_expiry self.docker_image_cache_expiry = docker_image_cache_expiry
self.routes_for_all_subtasks = routes_for_all_subtasks or [] self.routes_for_all_subtasks = routes_for_all_subtasks or []
self.scopes_for_all_subtasks = scopes_for_all_subtasks or [] self.scopes_for_all_subtasks = scopes_for_all_subtasks or []
@ -133,37 +133,21 @@ class DecisionTask:
def create_task(self, *, task_name, script, max_run_time_minutes, def create_task(self, *, task_name, script, max_run_time_minutes,
docker_image=None, dockerfile=None, # One of these is required docker_image=None, dockerfile=None, # One of these is required
artifacts=None, dependencies=None, env=None, cache=None, scopes=None, artifacts=None, dependencies=None, env=None, cache=None, scopes=None,
routes=None, extra=None, features=None, routes=None, extra=None, features=None, mounts=None, homedir_path=None,
with_repo=True): worker_type=None, with_repo=True):
""" """
Schedule a new task. Only supports `docker-worker` for now. Schedule a new task. Returns the new task ID.
Returns the new task ID.
One of `docker_image` or `dockerfile` (but not both) must be given. One of `docker_image` or `dockerfile` (but not both) must be given.
If `dockerfile` is given, the corresponding Docker image is built as needed and cached. If `dockerfile` is given, the corresponding Docker image is built as needed and cached.
`with_repo` indicates whether `script` should start in a clone of the git repository. `with_repo` indicates whether `script` should start in a clone of the git repository.
""" """
if docker_image and dockerfile:
raise TypeError("cannot use both `docker_image` or `dockerfile`")
if not docker_image and not dockerfile:
raise TypeError("need one of `docker_image` or `dockerfile`")
# https://docs.taskcluster.net/docs/reference/workers/docker-worker/docs/environment # https://docs.taskcluster.net/docs/reference/workers/docker-worker/docs/environment
decision_task_id = os.environ["TASK_ID"] decision_task_id = os.environ["TASK_ID"]
dependencies = [decision_task_id] + (dependencies or []) dependencies = [decision_task_id] + (dependencies or [])
if dockerfile:
image_build_task = self.find_or_build_docker_image(dockerfile)
dependencies.append(image_build_task)
docker_image = {
"type": "task-image",
"taskId": image_build_task,
"path": "public/" + self.DOCKER_IMAGE_ARTIFACT_FILENAME,
}
# Set in .taskcluster.yml # Set in .taskcluster.yml
task_owner = os.environ["TASK_OWNER"] task_owner = os.environ["TASK_OWNER"]
task_source = os.environ["TASK_SOURCE"] task_source = os.environ["TASK_SOURCE"]
@ -175,19 +159,72 @@ class DecisionTask:
for k in ["GIT_URL", "GIT_REF", "GIT_SHA"]: for k in ["GIT_URL", "GIT_REF", "GIT_SHA"]:
env[k] = os.environ[k] env[k] = os.environ[k]
script = """ worker_type = worker_type or self.default_worker_type
if "docker" in worker_type:
if docker_image and dockerfile:
raise TypeError("cannot use both `docker_image` or `dockerfile`")
if not docker_image and not dockerfile:
raise TypeError("need one of `docker_image` or `dockerfile`")
if dockerfile:
image_build_task = self.find_or_build_docker_image(dockerfile)
dependencies.append(image_build_task)
docker_image = {
"type": "task-image",
"taskId": image_build_task,
"path": "public/" + self.DOCKER_IMAGE_ARTIFACT_FILENAME,
}
if with_repo:
script = """
git init repo git init repo
cd repo cd repo
git fetch --depth 1 "$GIT_URL" "$GIT_REF" git fetch --depth 1 "$GIT_URL" "$GIT_REF"
git reset --hard "$GIT_SHA" git reset --hard "$GIT_SHA"
""" + script """ + script
command = ["/bin/bash", "--login", "-x", "-e", "-c", deindent(script)]
else:
command = [
"set PATH=%CD%\\{};%PATH%".format(p)
for p in reversed(homedir_path or [])
]
if with_repo:
command.append(deindent("""
git init repo
cd repo
git fetch --depth 1 %GIT_URL% %GIT_REF%
git reset --hard %GIT_SHA%
"""))
command.append(deindent(script))
worker_payload = {
"maxRunTime": max_run_time_minutes * 60,
"command": command,
"env": env,
}
if docker_image:
worker_payload["image"] = docker_image
if cache:
worker_payload["cache"] = cache
if features:
worker_payload["features"] = features
if mounts:
worker_payload["mounts"] = mounts
if artifacts:
worker_payload["artifacts"] = {
"public/" + os.path.basename(path): {
"type": "file",
"path": path,
"expires": self.from_now_json(expires),
}
for path, expires in artifacts
}
payload = { payload = {
"taskGroupId": decision_task_id, "taskGroupId": decision_task_id,
"dependencies": dependencies or [], "dependencies": dependencies or [],
"schedulerId": "taskcluster-github", "schedulerId": "taskcluster-github",
"provisionerId": "aws-provisioner-v1", "provisionerId": "aws-provisioner-v1",
"workerType": self.worker_type, "workerType": worker_type,
"created": self.from_now_json(""), "created": self.from_now_json(""),
"deadline": self.from_now_json("1 day"), "deadline": self.from_now_json("1 day"),
@ -200,29 +237,7 @@ class DecisionTask:
"scopes": (scopes or []) + self.scopes_for_all_subtasks, "scopes": (scopes or []) + self.scopes_for_all_subtasks,
"routes": (routes or []) + self.routes_for_all_subtasks, "routes": (routes or []) + self.routes_for_all_subtasks,
"extra": extra or {}, "extra": extra or {},
"payload": { "payload": worker_payload,
"cache": cache or {},
"maxRunTime": max_run_time_minutes * 60,
"image": docker_image,
"command": [
"/bin/bash",
"--login",
"-x",
"-e",
"-c",
deindent(script)
],
"env": env,
"artifacts": {
"public/" + os.path.basename(path): {
"type": "file",
"path": path,
"expires": self.from_now_json(expires),
}
for path, expires in artifacts or []
},
"features": features or {},
},
} }
task_id = taskcluster.slugId().decode("utf8") task_id = taskcluster.slugId().decode("utf8")