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

--HG--
extra : rebase_source : 67b38061d9c7e533b2347eaacf6b186d9b86b984
extra : histedit_source : 7b01445b822e8fc7f04d74cd37006240da33ecc6
This commit is contained in:
Dustin J. Mitchell 2017-08-25 19:15:12 +00:00
Родитель 9bfdfd7670
Коммит 50de0c93d3
3 изменённых файлов: 46 добавлений и 5 удалений

Просмотреть файл

@ -4,6 +4,7 @@
from __future__ import absolute_import, print_function, unicode_literals
from taskgraph.transforms.base import TransformSequence
from taskgraph.util.platforms import platform_family
transforms = TransformSequence()
@ -31,3 +32,18 @@ def set_build_attributes(config, jobs):
})
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

Просмотреть файл

@ -22,6 +22,7 @@ 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,
@ -930,12 +931,16 @@ def make_job_description(config, tests):
'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'

Просмотреть файл

@ -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)