Bug 1275774 - Add try-syntax parsing of email notifications to taskcluster draft
authorBrian Stack <bstack@mozilla.com>
Wed, 21 Sep 2016 18:02:43 -0700
changeset 417704 2f10b3e70eb28167ed9ead624a1194f7989c4a16
parent 417703 dd7e7996abffa50239b866f096ac4e2fc2fa5801
child 417705 880bee6e391c81bc70ba23f75f1bf998b7380ae8
child 417724 ef402bcc0de44fd47e659449c8b96870081205a9
child 418516 1add188f671b252a731d13114f93d2910130f4f4
push id30460
push userbstack@mozilla.com
push dateMon, 26 Sep 2016 16:52:15 +0000
bugs1275774
milestone52.0a1
Bug 1275774 - Add try-syntax parsing of email notifications to taskcluster MozReview-Commit-ID: 8ZXCNEvMDCg
taskcluster/taskgraph/try_option_syntax.py
--- a/taskcluster/taskgraph/try_option_syntax.py
+++ b/taskcluster/taskgraph/try_option_syntax.py
@@ -166,33 +166,33 @@ RIDEALONG_BUILDS = {
         'sm-tsan',
         'sm-asan',
         'sm-msan',
     ],
 }
 
 TEST_CHUNK_SUFFIX = re.compile('(.*)-([0-9]+)$')
 
-
 class TryOptionSyntax(object):
 
     def __init__(self, message, full_task_graph):
         """
         Parse a "try syntax" formatted commit message.  This is the old "-b do -p
         win32 -u all" format.  Aliases are applied to map short names to full
         names.
 
         The resulting object has attributes:
 
         - build_types: a list containing zero or more of 'opt' and 'debug'
         - platforms: a list of selected platform names, or None for all
         - unittests: a list of tests, of the form given below, or None for all
         - jobs: a list of requested job names, or None for all
         - trigger_tests: the number of times tests should be triggered (--rebuild)
-        - interactive; true if --interactive
+        - interactive: true if --interactive
+        - notifications: one of 'none', 'all', 'failure'
 
         Note that -t is currently completely ignored.
 
         The unittests and talos lists contain dictionaries of the form:
 
         {
             'test': '<suite name>',
             'platforms': [..platform names..], # to limit to only certain platforms
@@ -201,16 +201,17 @@ class TryOptionSyntax(object):
         """
         self.jobs = []
         self.build_types = []
         self.platforms = []
         self.unittests = []
         self.talos = []
         self.trigger_tests = 0
         self.interactive = False
+        self.notifications = 'none'
 
         # shlex used to ensure we split correctly when giving values to argparse.
         parts = shlex.split(self.escape_whitespace_in_brackets(message))
         try_idx = None
         for idx, part in enumerate(parts):
             if part == TRY_DELIMITER:
                 try_idx = idx
                 break
@@ -223,29 +224,32 @@ class TryOptionSyntax(object):
         parser.add_argument('-b', '--build', dest='build_types')
         parser.add_argument('-p', '--platform', nargs='?',
                             dest='platforms', const='all', default='all')
         parser.add_argument('-u', '--unittests', nargs='?',
                             dest='unittests', const='all', default='all')
         parser.add_argument('-t', '--talos', nargs='?', dest='talos', const='all', default='all')
         parser.add_argument('-i', '--interactive',
                             dest='interactive', action='store_true', default=False)
+        parser.add_argument('-e', '--all-emails', dest='notifications', action='store_const', const='all')
+        parser.add_argument('-f', '--failure-emails', dest='notifications', action='store_const', const='failure')
         parser.add_argument('-j', '--job', dest='jobs', action='append')
         # In order to run test jobs multiple times
         parser.add_argument('--rebuild', dest='trigger_tests', type=int, default=1)
         args, _ = parser.parse_known_args(parts[try_idx:])
 
         self.jobs = self.parse_jobs(args.jobs)
         self.build_types = self.parse_build_types(args.build_types)
         self.platforms = self.parse_platforms(args.platforms)
         self.unittests = self.parse_test_option(
             "unittest_try_name", args.unittests, full_task_graph)
         self.talos = self.parse_test_option("talos_try_name", args.talos, full_task_graph)
         self.trigger_tests = args.trigger_tests
         self.interactive = args.interactive
+        self.notifications = args.notifications or self.notifications
 
     def parse_jobs(self, jobs_arg):
         if not jobs_arg or jobs_arg == ['all']:
             return None
         expanded = []
         for job in jobs_arg:
             expanded.extend(j.strip() for j in job.split(','))
         return expanded
@@ -538,9 +542,10 @@ class TryOptionSyntax(object):
 
         return "\n".join([
             "build_types: " + ", ".join(self.build_types),
             "platforms: " + none_for_all(self.platforms),
             "unittests: " + none_for_all(self.unittests),
             "jobs: " + none_for_all(self.jobs),
             "trigger_tests: " + str(self.trigger_tests),
             "interactive: " + str(self.interactive),
+            "notifications: " + self.notifications,
         ])