mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-25 15:43:10 -10:00
This introduces a completely new way of specifying test task in-tree,
completely replacing the old spider-web of YAML files.
The high-level view is this:
- some configuration files are used to determine which test suites to run
for each test platform, and against which build platforms
- each test suite is then represented by a dictionary, and modified by a
sequence of transforms, duplicating as necessary (e.g., chunks), until
it becomes a task definition
The transforms allow sufficient generality to support just about any desired
configuration, with the advantage that common configurations are "easy" while
unusual configurations are supported but notable for their oddness (they
require a custom transform).
As of this commit, this system produces the same set of test graphs as the
existing YAML, modulo:
- extra.treeherder.groupName -- this was not consistent in the YAML
- extra.treeherder.build -- this is ignored by taskcluster-treeherder anyway
- mozharness command argument order
- boolean True values for environment variables are now the string "true"
- metadata -- this is now much more consistent, with task name being the label
Testing of this commit demonstrates that it produces the same set of test tasks for
the following projects (those which had special cases defined in the YAML):
- autoland
- ash (*)
- willow
- mozilla-inbound
- mozilla-central
- try:
-b do -p all -t all -u all
-b d -p linux64,linux64-asan -u reftest -t none
-b d -p linux64,linux64-asan -u reftest[x64] -t none[x64]
(*) this patch omits the linux64/debug tc-M-e10s(dt) test, which is enabled on
ash; ash will require a small changeset to re-enable this test.
IGNORE BAD COMMIT MESSAGES (because the hook flags try syntax!)
MozReview-Commit-ID: G34dg9f17Hq
106 lines
3.4 KiB
Python
106 lines
3.4 KiB
Python
# 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 voluptuous
|
|
|
|
|
|
class TransformConfig(object):
|
|
"""A container for configuration affecting transforms. The `config`
|
|
argument to transforms is an instance of this class, possibly with
|
|
additional kind-specific attributes beyond those set here."""
|
|
def __init__(self, kind, path, config, params):
|
|
# the name of the current kind
|
|
self.kind = kind
|
|
|
|
# the path to the kind configuration directory
|
|
self.path = path
|
|
|
|
# the parsed contents of kind.yml
|
|
self.config = config
|
|
|
|
# the parameters for this task-graph generation run
|
|
self.params = params
|
|
|
|
|
|
class TransformSequence(object):
|
|
"""
|
|
Container for a sequence of transforms. Each transform is represented as a
|
|
callable taking (config, items) and returning a generator which will yield
|
|
transformed items. The resulting sequence has the same interface.
|
|
|
|
This is convenient to use in a file full of transforms, as it provides a
|
|
decorator, @transforms.add, that will add the decorated function to the
|
|
sequence.
|
|
"""
|
|
|
|
def __init__(self, transforms=None):
|
|
self.transforms = transforms or []
|
|
|
|
def __call__(self, config, items):
|
|
for xform in self.transforms:
|
|
items = xform(config, items)
|
|
if items is None:
|
|
raise Exception("Transform {} is not a generator".format(xform))
|
|
return items
|
|
|
|
def __repr__(self):
|
|
return '\n'.join(
|
|
['TransformSequence(['] +
|
|
[repr(x) for x in self.transforms] +
|
|
['])'])
|
|
|
|
def add(self, func):
|
|
self.transforms.append(func)
|
|
return func
|
|
|
|
|
|
def validate_schema(schema, obj, msg_prefix):
|
|
"""
|
|
Validate that object satisfies schema. If not, generate a useful exception
|
|
beginning with msg_prefix.
|
|
"""
|
|
try:
|
|
return schema(obj)
|
|
except voluptuous.MultipleInvalid as exc:
|
|
msg = [msg_prefix]
|
|
for error in exc.errors:
|
|
msg.append(str(error))
|
|
raise Exception('\n'.join(msg))
|
|
|
|
|
|
def get_keyed_by(item, field, item_name):
|
|
"""
|
|
For values which can either accept a literal value, or be keyed by some
|
|
other attribute of the item, perform that lookup. For example, this supports
|
|
|
|
chunks:
|
|
by-item-platform:
|
|
macosx-10.11/debug: 13
|
|
default: 12
|
|
|
|
The `item_name` parameter is used to generate useful error messages.
|
|
"""
|
|
value = item[field]
|
|
if not isinstance(value, dict):
|
|
return value
|
|
|
|
assert len(value) == 1, "Invalid attribute {} in {}".format(field, item_name)
|
|
keyed_by = value.keys()[0]
|
|
values = value[keyed_by]
|
|
if keyed_by.startswith('by-'):
|
|
keyed_by = keyed_by[3:] # extract just the keyed-by field name
|
|
for k in item[keyed_by], 'default':
|
|
if k in values:
|
|
return values[k]
|
|
else:
|
|
raise Exception(
|
|
"Neither {} {} nor 'default' found while determining item {} in {}".format(
|
|
keyed_by, item[keyed_by], field, item_name))
|
|
else:
|
|
raise Exception(
|
|
"Invalid attribute {} keyed-by value {} in {}".format(
|
|
field, keyed_by, item_name))
|