mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 1414919 - [taskgraph] Allow morph templates to also modify task attributes, r=dustin
The motivation for this change is to create a 'rebuild' template that sets 'attributes.task_duplicates'. A nice side effect is that if any of 'task' or 'attributes' aren't explicitly set, we can ignore the result which means we don't need to have a whole bunch of 'else' clauses in the templates. MozReview-Commit-ID: DX3UyFGb4ff --HG-- extra : rebase_source : b768cb9f9df3cb22827209519f1cd2a4944af74f
This commit is contained in:
parent
33c2d96bbf
commit
1ec6a60b5b
@ -106,32 +106,23 @@ be applied to every task no matter what. If the template should only be applied
|
||||
to certain kinds of tasks, this needs to be specified in the template itself
|
||||
using JSON-e `condition statements`_.
|
||||
|
||||
The context available to the JSON-e render aims to match that of ``actions``.
|
||||
It looks like this:
|
||||
The context available to the JSON-e render contains attributes from the
|
||||
:py:class:`taskgraph.task.Task` class. It looks like this:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
{
|
||||
"task": {
|
||||
"payload": {
|
||||
"env": { ... },
|
||||
...
|
||||
}
|
||||
"extra": {
|
||||
"treeherder": { ... },
|
||||
...
|
||||
},
|
||||
"tags": { "kind": "<kind>", ... },
|
||||
...
|
||||
},
|
||||
"input": {
|
||||
"enabled": 1,
|
||||
...
|
||||
},
|
||||
"taskId": "<task id>"
|
||||
"attributes": task.attributes,
|
||||
"kind": task.kind,
|
||||
"task": task.task,
|
||||
"taskId": task.task_id,
|
||||
"input": ...
|
||||
}
|
||||
|
||||
See the `existing templates`_ for examples.
|
||||
The ``input`` context can be any arbitrary value or object. What it contains
|
||||
depends on each specific template. Templates must return objects that have have
|
||||
either ``attributes`` or ``task`` as a top level key. All other top level keys
|
||||
will be ignored. See the `existing templates`_ for examples.
|
||||
|
||||
Empty Try
|
||||
:::::::::
|
||||
|
@ -27,3 +27,4 @@ PYTHON_UNITTEST_MANIFESTS += [
|
||||
'taskgraph/test/python.ini',
|
||||
]
|
||||
SPHINX_TREES['taskcluster'] = 'docs'
|
||||
SPHINX_PYTHON_PACKAGE_DIRS += ['taskgraph']
|
||||
|
@ -268,12 +268,17 @@ class apply_jsone_templates(object):
|
||||
'taskId': task.task_id,
|
||||
'kind': task.kind,
|
||||
'input': self.templates[template],
|
||||
# The following context differs from action tasks
|
||||
'attributes': task.attributes,
|
||||
}
|
||||
|
||||
template_path = os.path.join(self.template_dir, template + '.yml')
|
||||
with open(template_path) as f:
|
||||
template = yaml.load(f)
|
||||
task.task = jsone.render(template, context)
|
||||
result = jsone.render(template, context) or {}
|
||||
for attr in ('task', 'attributes'):
|
||||
if attr in result:
|
||||
setattr(task, attr, result[attr])
|
||||
|
||||
return taskgraph, label_to_taskid
|
||||
|
||||
|
@ -3,16 +3,13 @@ $if: task["tags"]
|
||||
then:
|
||||
$if: task.tags["kind"] == "build"
|
||||
then:
|
||||
$mergeDeep:
|
||||
- $eval: task
|
||||
- extra:
|
||||
treeherder:
|
||||
symbol: Ba
|
||||
- payload:
|
||||
env:
|
||||
USE_ARTIFACT:
|
||||
$eval: input.enabled
|
||||
else:
|
||||
$eval: task
|
||||
else:
|
||||
$eval: task
|
||||
task:
|
||||
$mergeDeep:
|
||||
- $eval: task
|
||||
- extra:
|
||||
treeherder:
|
||||
symbol: Ba
|
||||
- payload:
|
||||
env:
|
||||
USE_ARTIFACT:
|
||||
$eval: input.enabled
|
||||
|
@ -1,5 +1,6 @@
|
||||
$mergeDeep:
|
||||
- $eval: task
|
||||
- payload:
|
||||
env:
|
||||
$eval: input
|
||||
task:
|
||||
$mergeDeep:
|
||||
- $eval: task
|
||||
- payload:
|
||||
env:
|
||||
$eval: input
|
||||
|
Loading…
Reference in New Issue
Block a user