Decision task!

This commit is contained in:
Simon Sapin 2018-08-17 20:21:29 +02:00
parent f559fcb5dc
commit 3d12b33e2d
4 changed files with 47 additions and 6 deletions

View file

@ -5,13 +5,15 @@ policy:
tasks: tasks:
- $if: 'tasks_for == "github-push"' - $if: 'tasks_for == "github-push"'
then: then:
taskGroupId: {$eval: as_slugid("decision_task")}
taskId: {$eval: as_slugid("decision_task")}
provisionerId: aws-provisioner-v1 provisionerId: aws-provisioner-v1
workerType: github-worker workerType: github-worker
created: {$fromNow: ''} created: {$fromNow: ''}
deadline: {$fromNow: '1 hour'} deadline: {$fromNow: '1 hour'}
metadata: metadata:
name: "Taskcluster experiments for Servo" name: "Taskcluster experiments for Servo: Decision task"
description: "Initial task" description: ""
owner: ${event.pusher.name}@users.noreply.github.com owner: ${event.pusher.name}@users.noreply.github.com
source: ${event.compare} source: ${event.compare}
@ -20,12 +22,19 @@ tasks:
image: "buildpack-deps:bionic-scm" image: "buildpack-deps:bionic-scm"
features: features:
taskclusterProxy: true 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: command:
- /bin/bash - /bin/bash
- '--login' - '--login'
- '-c' - '-c'
- >- - >-
git clone ${event.repository.clone_url} repo && git clone $DECISION_TASK_CLONE_URL repo &&
cd repo && cd repo &&
git checkout ${event.after} && git checkout $DECISION_TASK_COMMIT_SHA &&
python2.7 task.py pip install taskcluster &&
python2.7 decision-task.py

1
child-task.py Normal file
View file

@ -0,0 +1 @@
print("hello from a child task!")

32
decision-task.py Normal file
View file

@ -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)

View file

@ -1 +0,0 @@
print("Hello, World!")