Bug 1277595 - Add a --triggered-by=nightly flag to taskgraph draft
authorAnthony Miyaguchi <amiyaguchi@mozilla.com>
Fri, 26 Aug 2016 10:58:18 -0700
changeset 406270 26cecd6e8b1a3ab43e1ba4f02798200ed8064acb
parent 405618 024e7dc7a219e3f276bc2245746bbad67a574ea9
child 406271 cf116682ee73f192a7856980b79379b798b869de
push id27674
push useramiyaguchi@mozilla.com
push dateFri, 26 Aug 2016 18:00:28 +0000
bugs1277595
milestone51.0a1
Bug 1277595 - Add a --triggered-by=nightly flag to taskgraph This adds a triggered-by option to the decision command which lets us specify where the decision task was triggered. We can also explicitly pass the target tasks method, which will overwrite any project or default methods. MozReview-Commit-ID: 7ivjAgatH96
taskcluster/mach_commands.py
taskcluster/taskgraph/decision.py
--- a/taskcluster/mach_commands.py
+++ b/taskcluster/mach_commands.py
@@ -139,16 +139,22 @@ class MachCommands(MachCommandBase):
                      type=int,
                      default=0)
     @CommandArgument('--owner',
                      required=True,
                      help='email address of who owns this graph')
     @CommandArgument('--level',
                      required=True,
                      help='SCM level of this repository')
+    @CommandArgument('--triggered-by',
+                     choices=['nightly', 'push'],
+                     default='push',
+                     help='Source of execution of the decision graph')
+    @CommandArgument('--target-tasks-method',
+                     help='method for selecting the target tasks to generate')
     def taskgraph_decision(self, **options):
         """Run the decision task: generate a task graph and submit to
         TaskCluster.  This is only meant to be called within decision tasks,
         and requires a great many arguments.  Commands like `mach taskgraph
         optimized` are better suited to use on the command line, and can take
         the parameters file generated by a decision task.  """
 
         import taskgraph.decision
--- a/taskcluster/taskgraph/decision.py
+++ b/taskcluster/taskgraph/decision.py
@@ -105,28 +105,33 @@ def get_decision_parameters(options):
         'head_rev',
         'head_ref',
         'message',
         'project',
         'pushlog_id',
         'pushdate',
         'owner',
         'level',
+        'triggered_by',
         'target_tasks_method',
     ] if n in options}
 
     project = parameters['project']
     try:
         parameters.update(PER_PROJECT_PARAMETERS[project])
     except KeyError:
         logger.warning("using default project parameters; add {} to "
                        "PER_PROJECT_PARAMETERS in {} to customize behavior "
                        "for this project".format(project, __file__))
         parameters.update(PER_PROJECT_PARAMETERS['default'])
 
+    # `target_tasks_method` has higher precedence than `project` parameters
+    if 'target_tasks_method' in options:
+        parameters['target_tasks_method'] = options['target_tasks_method']
+
     return Parameters(parameters)
 
 
 def write_artifact(filename, data):
     logger.info('writing artifact file `{}`'.format(filename))
     if not os.path.isdir(ARTIFACTS_DIR):
         os.mkdir(ARTIFACTS_DIR)
     path = os.path.join(ARTIFACTS_DIR, filename)