diff --git a/.taskcluster.yml b/.taskcluster.yml index 755ab8b7454..d4033f3b616 100644 --- a/.taskcluster.yml +++ b/.taskcluster.yml @@ -5,13 +5,15 @@ policy: tasks: - $if: 'tasks_for == "github-push"' then: + taskGroupId: {$eval: as_slugid("decision_task")} + taskId: {$eval: as_slugid("decision_task")} provisionerId: aws-provisioner-v1 workerType: github-worker created: {$fromNow: ''} deadline: {$fromNow: '1 hour'} metadata: - name: "Taskcluster experiments for Servo" - description: "Initial task" + name: "Taskcluster experiments for Servo: Decision task" + description: "" owner: ${event.pusher.name}@users.noreply.github.com source: ${event.compare} @@ -20,12 +22,19 @@ tasks: image: "buildpack-deps:bionic-scm" features: taskclusterProxy: true + env: + DECISION_TASK_ID: {$eval: as_slugid("decision_task")} + DECISION_TASK_OWNER: ${event.pusher.name}@users.noreply.github.com + DECISION_TASK_SOURCE: ${event.compare} + DECISION_TASK_CLONE_URL: ${event.repository.clone_url} + DECISION_TASK_COMMIT_SHA: ${event.after} command: - /bin/bash - '--login' - '-c' - >- - git clone ${event.repository.clone_url} repo && + git clone $DECISION_TASK_CLONE_URL repo && cd repo && - git checkout ${event.after} && - python2.7 task.py + git checkout $DECISION_TASK_COMMIT_SHA && + pip install taskcluster && + python2.7 decision-task.py diff --git a/child-task.py b/child-task.py new file mode 100644 index 00000000000..7387848f77e --- /dev/null +++ b/child-task.py @@ -0,0 +1 @@ +print("hello from a child task!") diff --git a/decision-task.py b/decision-task.py new file mode 100644 index 00000000000..f6ab76d8c9c --- /dev/null +++ b/decision-task.py @@ -0,0 +1,32 @@ +import os +import datetime +import taskcluster + +task_id = os.environ["DECISION_TASK_ID"] + "-child-task" +payload = { + "taskGroupId": os.environ["DECISION_TASK_ID"], + "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"], + } + "payload": { + "maxRunTime": 600, + "image": "buildpack-deps:bionic-scm", + "command": [ + "/bin/bash", "--login", "-c", """ + git clone %(DECISION_TASK_CLONE_URL)s repo && + cd repo && + git checkout %(DECISION_TASK_COMMIT_SHA)s && + python2.7 child-task.py + """ % os.environ + ] + } +} +result = taskcluster.Queue().createTask(task_id, payload) +print("task created…? %r" % result) diff --git a/task.py b/task.py deleted file mode 100644 index 7df869a15e7..00000000000 --- a/task.py +++ /dev/null @@ -1 +0,0 @@ -print("Hello, World!")