Bug 1530908 - Use a transform for try --artifact instead of a morph. r=tomprince
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 05 Mar 2019 08:52:19 +0000
changeset 520602 6b25ace491c34353e04b75ae443bf8c640f00699
parent 520601 ede80ab4fa72c062232a0299959466da2cb9626a
child 520603 ecc39e015e7a877c37212def591574a4531d11f1
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstomprince
bugs1530908
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1530908 - Use a transform for try --artifact instead of a morph. r=tomprince While the morph was changing the treeherder symbol to `Ba` for all jobs, doing so with a transform fails because of the conflicting symbol check (as multiple jobs in the same category would end up with `Ba`). So instead, we append `a` to the existing symbol. We also change the documentation wrt templates for try pushes, as the artifact template is now essentially gone (although technically, mach try will still set params['templates']['artifacts']['enabled'] for now, and the template still exists, albeit empty). Differential Revision: https://phabricator.services.mozilla.com/D22054
taskcluster/docs/try.rst
taskcluster/taskgraph/templates/artifact.yml
taskcluster/taskgraph/test/test_morph.py
taskcluster/taskgraph/transforms/build.py
--- a/taskcluster/docs/try.rst
+++ b/taskcluster/docs/try.rst
@@ -93,17 +93,17 @@ It's possible to alter the definition of
 from the ``try_task_config.json`` like this:
 
 .. parsed-literal::
 
     {
       "version": 1,
       "tasks": [...],
       "templates": {
-        artifact: {"enabled": 1}
+        env: {"FOO": "bar"}
       }
     }
 
 Each key in the templates object denotes a new template to apply, and the value
 denotes extra context to use while rendering. When specified, a template will
 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`_.
--- a/taskcluster/taskgraph/templates/artifact.yml
+++ b/taskcluster/taskgraph/templates/artifact.yml
@@ -1,15 +1,3 @@
+# This file is empty to keep mach try fuzzy happy until it doesn't use
+# {"templates": {"artifact": {"enabled": "1"}}} to enable artifact builds.
 ---
-$if: task["tags"]
-then:
-    $if: task.tags["kind"] == "build"
-    then:
-        task:
-            $mergeDeep:
-                - $eval: task
-                - extra:
-                      treeherder:
-                          symbol: Ba
-                - payload:
-                      env:
-                          USE_ARTIFACT:
-                              $eval: input.enabled
--- a/taskcluster/taskgraph/test/test_morph.py
+++ b/taskcluster/taskgraph/test/test_morph.py
@@ -144,36 +144,16 @@ def get_morphed(make_taskgraph):
             t['label']: Task(**t) for t in tasks[:]
         })
 
         fn = morph.apply_jsone_templates(try_task_config)
         return fn(*taskgraph)[0]
     return inner
 
 
-def test_template_artifact(get_morphed):
-    morphed = get_morphed({
-        'templates': {
-            'artifact': {'enabled': 1}
-        },
-    })
-
-    assert len(morphed.tasks) == 2
-
-    for t in morphed.tasks.values():
-        if t.kind == 'build':
-            assert t.task['extra']['treeherder']['group'] == 'tc'
-            assert t.task['extra']['treeherder']['symbol'] == 'Ba'
-            assert t.task['payload']['env']['USE_ARTIFACT'] == 1
-        else:
-            assert t.task['extra']['treeherder']['group'] == 'tc'
-            assert t.task['extra']['treeherder']['symbol'] == 't'
-            assert 'USE_ARTIFACT' not in t.task['payload']['env']
-
-
 def test_template_env(get_morphed):
     morphed = get_morphed({
         'templates': {
             'env': {
                 'ENABLED': 1,
                 'FOO': 'BAZ',
             }
         },
--- a/taskcluster/taskgraph/transforms/build.py
+++ b/taskcluster/taskgraph/transforms/build.py
@@ -129,8 +129,22 @@ def enable_full_crashsymbols(config, job
     for job in jobs:
         enable_full_crashsymbols = job['attributes'].get('enable-full-crashsymbols')
         if enable_full_crashsymbols and config.params['project'] in branches:
             logger.debug("Enabling full symbol generation for %s", job['name'])
         else:
             logger.debug("Disabling full symbol generation for %s", job['name'])
             job['worker']['env']['MOZ_DISABLE_FULL_SYMBOLS'] = '1'
         yield job
+
+
+@transforms.add
+def use_artifact(config, jobs):
+    if config.params['try_mode'] == 'try_task_config':
+        use_artifact = config.params['try_task_config'] \
+            .get('templates', {}).get('artifact', {}).get('enabled')
+    else:
+        use_artifact = False
+    for job in jobs:
+        if config.kind == 'build' and use_artifact:
+            job['treeherder']['symbol'] += 'a'
+            job['worker']['env']['USE_ARTIFACT'] = '1'
+        yield job