зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1414919 - [taskgraph] Create a 'rebuild' morph template, r=dustin
This template takes a single integer as input, and sets the 'task_duplicates' attribute on any tasks that were explicitly specified by try_task_config.json. This means dependent tasks or 'always_target' tasks will not be rebuilt. To support this template, the apply_jsone_templates morph now requires the entire try_task_config object instead of just the templates. MozReview-Commit-ID: DwxUtlC5VD5 --HG-- extra : rebase_source : c57a80ada2fc4591a5ce4c94965b8c9f02bb53b1
This commit is contained in:
Родитель
1ec6a60b5b
Коммит
1fdddacae3
|
@ -114,6 +114,8 @@ The context available to the JSON-e render contains attributes from the
|
||||||
{
|
{
|
||||||
"attributes": task.attributes,
|
"attributes": task.attributes,
|
||||||
"kind": task.kind,
|
"kind": task.kind,
|
||||||
|
"label": task.label,
|
||||||
|
"target_tasks": [<tasks from try_task_config.json>],
|
||||||
"task": task.task,
|
"task": task.task,
|
||||||
"taskId": task.task_id,
|
"taskId": task.task_id,
|
||||||
"input": ...
|
"input": ...
|
||||||
|
|
|
@ -253,8 +253,9 @@ class apply_jsone_templates(object):
|
||||||
"""
|
"""
|
||||||
template_dir = os.path.join(here, 'templates')
|
template_dir = os.path.join(here, 'templates')
|
||||||
|
|
||||||
def __init__(self, templates):
|
def __init__(self, try_task_config):
|
||||||
self.templates = templates
|
self.templates = try_task_config.get('templates')
|
||||||
|
self.target_tasks = try_task_config.get('tasks')
|
||||||
|
|
||||||
def __call__(self, taskgraph, label_to_taskid):
|
def __call__(self, taskgraph, label_to_taskid):
|
||||||
if not self.templates:
|
if not self.templates:
|
||||||
|
@ -270,6 +271,8 @@ class apply_jsone_templates(object):
|
||||||
'input': self.templates[template],
|
'input': self.templates[template],
|
||||||
# The following context differs from action tasks
|
# The following context differs from action tasks
|
||||||
'attributes': task.attributes,
|
'attributes': task.attributes,
|
||||||
|
'label': task.label,
|
||||||
|
'target_tasks': self.target_tasks,
|
||||||
}
|
}
|
||||||
|
|
||||||
template_path = os.path.join(self.template_dir, template + '.yml')
|
template_path = os.path.join(self.template_dir, template + '.yml')
|
||||||
|
@ -290,7 +293,7 @@ def morph(taskgraph, label_to_taskid, parameters):
|
||||||
add_s3_uploader_task,
|
add_s3_uploader_task,
|
||||||
]
|
]
|
||||||
if parameters['try_mode'] == 'try_task_config':
|
if parameters['try_mode'] == 'try_task_config':
|
||||||
morphs.append(apply_jsone_templates(parameters['try_task_config'].get('templates')))
|
morphs.append(apply_jsone_templates(parameters['try_task_config']))
|
||||||
|
|
||||||
for m in morphs:
|
for m in morphs:
|
||||||
taskgraph, label_to_taskid = m(taskgraph, label_to_taskid)
|
taskgraph, label_to_taskid = m(taskgraph, label_to_taskid)
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
$if: label in target_tasks
|
||||||
|
then:
|
||||||
|
attributes:
|
||||||
|
$merge:
|
||||||
|
- $eval: attributes
|
||||||
|
- task_duplicates:
|
||||||
|
$eval: input
|
|
@ -138,7 +138,12 @@ class TestApplyJSONeTemplates(MorphTestCase):
|
||||||
t['label']: Task(**t) for t in self.tasks[:]
|
t['label']: Task(**t) for t in self.tasks[:]
|
||||||
})
|
})
|
||||||
|
|
||||||
fn = morph.apply_jsone_templates({'artifact': {'enabled': 1}})
|
try_task_config = {
|
||||||
|
'templates': {
|
||||||
|
'artifact': {'enabled': 1}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
fn = morph.apply_jsone_templates(try_task_config)
|
||||||
morphed = fn(tg, label_to_taskid)[0]
|
morphed = fn(tg, label_to_taskid)[0]
|
||||||
|
|
||||||
self.assertEqual(len(morphed.tasks), 2)
|
self.assertEqual(len(morphed.tasks), 2)
|
||||||
|
@ -158,7 +163,15 @@ class TestApplyJSONeTemplates(MorphTestCase):
|
||||||
t['label']: Task(**t) for t in self.tasks[:]
|
t['label']: Task(**t) for t in self.tasks[:]
|
||||||
})
|
})
|
||||||
|
|
||||||
fn = morph.apply_jsone_templates({'env': {'ENABLED': 1, 'FOO': 'BAZ'}})
|
try_task_config = {
|
||||||
|
'templates': {
|
||||||
|
'env': {
|
||||||
|
'ENABLED': 1,
|
||||||
|
'FOO': 'BAZ',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
fn = morph.apply_jsone_templates(try_task_config)
|
||||||
morphed = fn(tg, label_to_taskid)[0]
|
morphed = fn(tg, label_to_taskid)[0]
|
||||||
|
|
||||||
self.assertEqual(len(morphed.tasks), 2)
|
self.assertEqual(len(morphed.tasks), 2)
|
||||||
|
@ -167,7 +180,10 @@ class TestApplyJSONeTemplates(MorphTestCase):
|
||||||
self.assertEqual(t.task['payload']['env']['ENABLED'], 1)
|
self.assertEqual(t.task['payload']['env']['ENABLED'], 1)
|
||||||
self.assertEqual(t.task['payload']['env']['FOO'], 'BAZ')
|
self.assertEqual(t.task['payload']['env']['FOO'], 'BAZ')
|
||||||
|
|
||||||
fn = morph.apply_jsone_templates({'env': {'ENABLED': 0}})
|
try_task_config['templates']['env'] = {
|
||||||
|
'ENABLED': 0,
|
||||||
|
}
|
||||||
|
fn = morph.apply_jsone_templates(try_task_config)
|
||||||
morphed = fn(tg, label_to_taskid)[0]
|
morphed = fn(tg, label_to_taskid)[0]
|
||||||
|
|
||||||
self.assertEqual(len(morphed.tasks), 2)
|
self.assertEqual(len(morphed.tasks), 2)
|
||||||
|
@ -176,6 +192,28 @@ class TestApplyJSONeTemplates(MorphTestCase):
|
||||||
self.assertEqual(t.task['payload']['env']['ENABLED'], 0)
|
self.assertEqual(t.task['payload']['env']['ENABLED'], 0)
|
||||||
self.assertEqual(t.task['payload']['env']['FOO'], 'BAZ')
|
self.assertEqual(t.task['payload']['env']['FOO'], 'BAZ')
|
||||||
|
|
||||||
|
def test_template_rebuild(self):
|
||||||
|
tg, label_to_taskid = self.make_taskgraph({
|
||||||
|
t['label']: Task(**t) for t in self.tasks[:]
|
||||||
|
})
|
||||||
|
|
||||||
|
try_task_config = {
|
||||||
|
'tasks': ['b'],
|
||||||
|
'templates': {
|
||||||
|
'rebuild': 4,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
fn = morph.apply_jsone_templates(try_task_config)
|
||||||
|
tasks = fn(tg, label_to_taskid)[0].tasks.values()
|
||||||
|
self.assertEqual(len(tasks), 2)
|
||||||
|
|
||||||
|
for t in tasks:
|
||||||
|
if t.label == 'a':
|
||||||
|
self.assertNotIn('task_duplicates', t.attributes)
|
||||||
|
elif t.label == 'b':
|
||||||
|
self.assertIn('task_duplicates', t.attributes)
|
||||||
|
self.assertEqual(t.attributes['task_duplicates'], 4)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Загрузка…
Ссылка в новой задаче