Bug 1383880: Annotate builds and tests with SCHEDULES-related optimizations; r=ahal
☠☠ backed out by 6f5dc86effe0 ☠ ☠
authorDustin J. Mitchell <dustin@mozilla.com>
Fri, 25 Aug 2017 19:15:12 +0000
changeset 428824 b41cd667697e13c989659b16bf649090a3908ecd
parent 428823 046d705929f7a41e977eec19c8503afccdec7592
child 428825 8586bf76d73db40ef52142fff8f21cdb0b31cf31
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1383880
milestone57.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 1383880: Annotate builds and tests with SCHEDULES-related optimizations; r=ahal This means that a push to try affecting only Android will only run android builds and tests, for example. MozReview-Commit-ID: HVUvIg0EUZn
taskcluster/taskgraph/transforms/build_attrs.py
taskcluster/taskgraph/transforms/tests.py
taskcluster/taskgraph/util/platforms.py
--- a/taskcluster/taskgraph/transforms/build_attrs.py
+++ b/taskcluster/taskgraph/transforms/build_attrs.py
@@ -1,14 +1,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 from __future__ import absolute_import, print_function, unicode_literals
 
 from taskgraph.transforms.base import TransformSequence
+from taskgraph.util.platforms import platform_family
 
 transforms = TransformSequence()
 
 
 @transforms.add
 def set_build_attributes(config, jobs):
     """
     Set the build_platform and build_type attributes based on the job name.
@@ -26,8 +27,23 @@ def set_build_attributes(config, jobs):
 
         attributes = job.setdefault('attributes', {})
         attributes.update({
             'build_platform': build_platform,
             'build_type': build_type,
         })
 
         yield job
+
+
+@transforms.add
+def set_schedules_optimization(config, jobs):
+    """Set the `skip-unless-affected` optimization based on the build platform."""
+    for job in jobs:
+        # don't add skip-unless-schedules if there's already a when defined
+        if 'when' in job:
+            yield job
+            continue
+
+        build_platform = job['attributes']['build_platform']
+        job.setdefault('optimization',
+                       {'skip-unless-schedules': [platform_family(build_platform)]})
+        yield job
--- a/taskcluster/taskgraph/transforms/tests.py
+++ b/taskcluster/taskgraph/transforms/tests.py
@@ -17,16 +17,17 @@ what should run where. this is the wrong
 for example - use `all_tests.py` instead.
 """
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 from taskgraph.transforms.base import TransformSequence
 from taskgraph.util.schema import resolve_keyed_by
 from taskgraph.util.treeherder import split_symbol, join_symbol
+from taskgraph.util.platforms import platform_family
 from taskgraph.util.schema import (
     validate_schema,
     optionally_keyed_by,
     Schema,
 )
 from voluptuous import (
     Any,
     Optional,
@@ -925,22 +926,26 @@ def make_job_description(config, tests):
         }
         jobdesc['treeherder'] = {
             'symbol': test['treeherder-symbol'],
             'kind': 'test',
             'tier': test['tier'],
             'platform': test.get('treeherder-machine-platform', test['build-platform']),
         }
 
-        # run SETA unless this is a try push
-        if config.params['project'] == 'try':
-            jobdesc['when'] = test.get('when', {})
+        if test.get('when'):
+            jobdesc['when'] = test['when']
         else:
-            # when SETA is enabled, the 'when' does not apply (optimizations don't mix)
-            jobdesc['optimization'] = {'seta': None}
+            schedules = [platform_family(test['build-platform'])]
+            if config.params['project'] != 'try':
+                # for non-try branches, include SETA
+                jobdesc['optimization'] = {'skip-unless-schedules-or-seta': schedules}
+            else:
+                # otherwise just use skip-unless-schedules
+                jobdesc['optimization'] = {'skip-unless-schedules': schedules}
 
         run = jobdesc['run'] = {}
         run['using'] = 'mozharness-test'
         run['test'] = test
 
         jobdesc['worker-type'] = test.pop('worker-type')
 
         yield jobdesc
new file mode 100644
--- /dev/null
+++ b/taskcluster/taskgraph/util/platforms.py
@@ -0,0 +1,20 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+import re
+
+# platform family is extracted from build platform by taking the alphabetic prefix
+# and then translating win -> windows
+_platform_re = re.compile(r'^[a-z]*')
+_renames = {
+    'win': 'windows'
+}
+
+
+def platform_family(build_platform):
+    """Given a build platform, return the platform family (linux, macosx, etc.)"""
+    family = _platform_re.match(build_platform).group(0)
+    return _renames.get(family, family)