servo/decision-task.py
2018-08-29 18:15:13 +02:00

50 lines
1.7 KiB
Python

# coding: utf8
import os
import datetime
import taskcluster
task_id = taskcluster.slugId()
payload = {
"taskGroupId": os.environ["DECISION_TASK_ID"],
"dependencies": [os.environ["DECISION_TASK_ID"]],
"schedulerId": "taskcluster-github", # FIXME: can we avoid hard-coding this?
"provisionerId": "aws-provisioner-v1",
"workerType": "github-worker",
"created": taskcluster.fromNowJSON(""),
"deadline": taskcluster.fromNowJSON("1 hour"),
"metadata": {
"name": "Taskcluster experiments for Servo: Child task",
"description": "",
"owner": os.environ["DECISION_TASK_OWNER"],
"source": os.environ["DECISION_TASK_SOURCE"],
},
# https://docs.taskcluster.net/docs/reference/workers/docker-worker/docs/caches
"scopes": [
"docker-worker:cache:cargo-registry-cache",
"docker-worker:cache:cargo-git-cache",
],
"payload": {
"maxRunTime": 600,
"image": "buildpack-deps:bionic-scm",
"cache": {
"cargo-registry-cache": "/root/.cargo/registry",
"cargo-git-cache": "/root/.cargo/git",
},
"command": [
"/bin/bash",
"--login",
"-c",
"""
git clone %(DECISION_TASK_CLONE_URL)s repo &&
cd repo &&
git checkout %(DECISION_TASK_COMMIT_SHA)s &&
./child-task.sh
""" % os.environ,
],
},
}
# https://docs.taskcluster.net/docs/reference/workers/docker-worker/docs/features#feature-taskclusterproxy
queue = taskcluster.Queue(options={"baseUrl": "http://taskcluster/queue/v1/"})
result = queue.createTask(task_id, payload)
print("task %s created…? %r" % (task_id, result))