From af478ed758bc958ae0a21aa7b5db1108fa383234 Mon Sep 17 00:00:00 2001 From: "Dustin J. Mitchell" Date: Mon, 25 Jun 2018 18:21:03 +0000 Subject: [PATCH] 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 --HG-- extra : rebase_source : 7434f2047c48ff0d1fa6de9e3419fb4e0bf0bb72 --- .taskcluster.yml | 4 ++++ taskcluster/taskgraph/actions/registry.py | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.taskcluster.yml b/.taskcluster.yml index f96ac16326f3..901d02823d8a 100644 --- a/.taskcluster.yml +++ b/.taskcluster.yml @@ -4,6 +4,8 @@ # - 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'} @@ -197,3 +199,5 @@ tasks: then: cron: {$json: {$eval: 'cron'}} - tasks_for: '${tasks_for}' + # no tasks for unrecognized tasks_for + else: [] diff --git a/taskcluster/taskgraph/actions/registry.py b/taskcluster/taskgraph/actions/registry.py index b96b4c2e20ae..900c68b2c95a 100644 --- a/taskcluster/taskgraph/actions/registry.py +++ b/taskcluster/taskgraph/actions/registry.py @@ -193,7 +193,13 @@ def register_callback_action(name, title, symbol, description, order=10000, 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') @@ -206,7 +212,7 @@ def register_callback_action(name, title, symbol, description, order=10000, 'push': push, 'action': action, }, - 'in': taskcluster_yml['tasks'][0], + 'in': tasks[0], }, })