Bug 1470886 - only produce tasks for recognized tasks_for r=tomprince
☠☠ backed out by 176a499c5b80 ☠ ☠
authorDustin J. Mitchell <dustin@mozilla.com>
Mon, 25 Jun 2018 18:21:03 +0000
changeset 424887 66956b121b939bf9a56bc33d6f3b8ffa58df4131
parent 424886 260d05b38752cc901f956b5a303da994e29f9556
child 424888 058b07756df6e4e2530aa1847936dae16dddd58c
push id34226
push userrgurzau@mozilla.com
push dateWed, 04 Jul 2018 09:57:31 +0000
treeherdermozilla-central@3d7f2fdc5bf7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstomprince
bugs1470886
milestone63.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 1470886 - only produce tasks for recognized tasks_for r=tomprince This also updates actions to "see through" the conditional. Soon we won't be using kind=task, so this hack will be less important. MozReview-Commit-ID: Aa6g9ZqoPMa
.taskcluster.yml
taskcluster/taskgraph/actions/registry.py
--- a/.taskcluster.yml
+++ b/.taskcluster.yml
@@ -1,14 +1,16 @@
 # This file is rendered via JSON-e by
 # - mozilla-taskcluster - https://docs.taskcluster.net/reference/integrations/mozilla-taskcluster/docs/taskcluster-yml
 # - cron tasks - taskcluster/taskgraph/cron/decision.py
 # - action tasks - taskcluster/taskgraph/actions/registry.py
 version: 1
 tasks:
+  $if: 'tasks_for in ["hg-push", "action", "cron"]'
+  then:
   - $let:
       # sometimes the push user is just `ffxbld` or the like, but we want an email-like field..
       ownerEmail: {$if: '"@" in push.owner', then: '${push.owner}', else: '${push.owner}@noreply.mozilla.org'}
       # ensure there's no trailing `/` on the repo URL
       repoUrl: {$if: 'repository.url[-1] == "/"', then: {$eval: 'repository.url[:-1]'}, else: {$eval: 'repository.url'}}
     in:
       taskId: {$if: 'tasks_for != "action"', then: '${as_slugid("decision")}'}
       taskGroupId:
@@ -192,8 +194,10 @@ tasks:
                   taskGroupId: '${action.taskGroupId}'
                   taskId: {$eval: 'taskId'}
                   input: {$eval: 'input'}
                   parameters: {$eval: 'parameters'}
           - $if: 'tasks_for == "cron"'
             then:
               cron: {$json: {$eval: 'cron'}}
           - tasks_for: '${tasks_for}'
+  # no tasks for unrecognized tasks_for
+  else: []
--- a/taskcluster/taskgraph/actions/registry.py
+++ b/taskcluster/taskgraph/actions/registry.py
@@ -188,30 +188,36 @@ def register_callback_action(name, title
                 repo_scope = 'assume:repo:{}/{}:branch:default'.format(
                     match.group(1), match.group(2))
                 action['repo_scope'] = repo_scope
 
                 taskcluster_yml = read_taskcluster_yml(graph_config.taskcluster_yml)
                 if taskcluster_yml['version'] != 1:
                     raise Exception(
                         'actions.json must be updated to work with .taskcluster.yml')
-                if not isinstance(taskcluster_yml['tasks'], list):
+
+                # allow a top-level conditional (bug 1470886)
+                tasks = taskcluster_yml['tasks']
+                if isinstance(tasks, dict) and '$if' in tasks:
+                    tasks = tasks['then']
+
+                if not isinstance(tasks, list):
                     raise Exception(
                         '.taskcluster.yml "tasks" must be a list for action tasks')
 
                 rv.update({
                     'kind': 'task',
                     'task': {
                         '$let': {
                             'tasks_for': 'action',
                             'repository': repository,
                             'push': push,
                             'action': action,
                         },
-                        'in': taskcluster_yml['tasks'][0],
+                        'in': tasks[0],
                     },
                 })
 
             # for kind=hook
             elif kind == 'hook':
                 trustDomain = graph_config['trust-domain']
                 level = parameters['level']
                 tcyml_hash = hash_taskcluster_yml(graph_config.taskcluster_yml)