Bug 1525421 - parse out just the try syntax from the commit message r=tomprince
authorDustin J. Mitchell <dustin@mozilla.com>
Thu, 07 Feb 2019 02:10:42 +0000
changeset 516381 1936822aea92
parent 516380 d5aae246f088
child 516382 2f877e90ff57
push id1973
push userdmitchell@mozilla.com
push dateFri, 15 Mar 2019 14:41:25 +0000
treeherdermozilla-release@980321059007 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstomprince
bugs1525421
milestone66.0
Bug 1525421 - parse out just the try syntax from the commit message r=tomprince This mirrors what mozilla-taskcluster does in https://github.com/taskcluster/mozilla-taskcluster/blob/cb3de4c31e418f7dc1d89cffeeb28ad6a9dae610/src/jobs/taskcluster_graph.js#L46-L58 Differential Revision: https://phabricator.services.mozilla.com/D18748
taskcluster/taskgraph/decision.py
taskcluster/taskgraph/test/test_decision.py
taskcluster/taskgraph/try_option_syntax.py
--- a/taskcluster/taskgraph/decision.py
+++ b/taskcluster/taskgraph/decision.py
@@ -128,16 +128,27 @@ def full_task_graph_to_runnable_jobs(ful
         for i in ('groupName', 'groupSymbol', 'collection'):
             if i in th:
                 runnable_jobs[label][i] = th[i]
         if th.get('machine', {}).get('platform'):
             runnable_jobs[label]['platform'] = th['machine']['platform']
     return runnable_jobs
 
 
+def try_syntax_from_message(message):
+    """
+    Parse the try syntax out of a commit message, returning '' if none is
+    found.
+    """
+    try_idx = message.find('try:')
+    if try_idx == -1:
+        return ''
+    return message[try_idx:].split('\n', 1)[0]
+
+
 def taskgraph_decision(options, parameters=None):
     """
     Run the decision task.  This function implements `mach taskgraph decision`,
     and is responsible for
 
      * processing decision task command-line options into parameters
      * running task-graph generation exactly the same way the other `mach
        taskgraph` commands do
@@ -217,17 +228,18 @@ def get_decision_parameters(config, opti
         'target_tasks_method',
     ]
     parameters['optimize_target_tasks'] = True
     parameters['existing_tasks'] = {}
     parameters['do_not_optimize'] = []
     parameters['build_number'] = 1
     parameters['version'] = get_version(product_dir)
     parameters['app_version'] = get_app_version(product_dir)
-    parameters['message'] = get_hg_commit_message(GECKO)
+    parameters['message'] = try_syntax_from_message(
+            get_hg_commit_message(os.path.join(GECKO, product_dir)))
     parameters['hg_branch'] = get_hg_revision_branch(GECKO, revision=parameters['head_rev'])
     parameters['next_version'] = None
     parameters['release_type'] = ''
     parameters['release_eta'] = ''
     parameters['release_enable_partners'] = False
     parameters['release_partners'] = []
     parameters['release_partner_config'] = {}
     parameters['release_partner_build_number'] = 1
--- a/taskcluster/taskgraph/test/test_decision.py
+++ b/taskcluster/taskgraph/test/test_decision.py
@@ -104,11 +104,30 @@ class TestGetDecisionParameters(unittest
         ttc = {'tasks': ['a', 'b'], 'templates': {}}
         self.options['project'] = 'try'
         with MockedOpen({self.ttc_file: json.dumps(ttc)}):
             params = decision.get_decision_parameters(FAKE_GRAPH_CONFIG, self.options)
             self.assertEqual(params['try_mode'], 'try_task_config')
             self.assertEqual(params['try_options'], None)
             self.assertEqual(params['try_task_config'], ttc)
 
+    def test_try_syntax_from_message_empty(self):
+        self.assertEqual(decision.try_syntax_from_message(''), '')
+
+    def test_try_syntax_from_message_no_try_syntax(self):
+        self.assertEqual(decision.try_syntax_from_message('abc | def'), '')
+
+    def test_try_syntax_from_message_initial_try_syntax(self):
+        self.assertEqual(decision.try_syntax_from_message('try: -f -o -o'), 'try: -f -o -o')
+
+    def test_try_syntax_from_message_initial_try_syntax_multiline(self):
+        self.assertEqual(
+            decision.try_syntax_from_message('try: -f -o -o\nabc\ndef'),
+            'try: -f -o -o')
+
+    def test_try_syntax_from_message_embedded_try_syntax_multiline(self):
+        self.assertEqual(
+            decision.try_syntax_from_message('some stuff\ntry: -f -o -o\nabc\ndef'),
+            'try: -f -o -o')
+
 
 if __name__ == '__main__':
     main()
--- a/taskcluster/taskgraph/try_option_syntax.py
+++ b/taskcluster/taskgraph/try_option_syntax.py
@@ -7,18 +7,16 @@ from __future__ import absolute_import, 
 import argparse
 import copy
 import logging
 import re
 import shlex
 
 logger = logging.getLogger(__name__)
 
-TRY_DELIMITER = 'try:'
-
 # The build type aliases are very cryptic and only used in try flags these are
 # mappings from the single char alias to a longer more recognizable form.
 BUILD_TYPE_ALIASES = {
     'o': 'opt',
     'd': 'debug'
 }
 
 # consider anything in this whitelist of kinds to be governed by -b/-p