2017-11-02 20:37:20 +03:00
|
|
|
# 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
|
|
|
|
|
2018-05-03 04:28:43 +03:00
|
|
|
import os
|
|
|
|
import logging
|
2018-05-03 05:28:11 +03:00
|
|
|
import attr
|
2018-05-03 04:28:43 +03:00
|
|
|
import yaml
|
|
|
|
|
2017-11-02 20:37:20 +03:00
|
|
|
from .util.schema import validate_schema, Schema
|
2018-01-09 02:27:32 +03:00
|
|
|
from voluptuous import Required
|
2017-11-02 20:37:20 +03:00
|
|
|
|
2018-05-03 04:28:43 +03:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2017-11-02 20:37:20 +03:00
|
|
|
graph_config_schema = Schema({
|
2017-11-10 03:15:29 +03:00
|
|
|
# The trust-domain for this graph.
|
|
|
|
# (See https://firefox-source-docs.mozilla.org/taskcluster/taskcluster/taskgraph.html#taskgraph-trust-domain) # noqa
|
|
|
|
Required('trust-domain'): basestring,
|
2018-04-11 20:08:48 +03:00
|
|
|
# This specifes the prefix for repo parameters that refer to the project being built.
|
|
|
|
# This selects between `head_rev` and `comm_head_rev` and related paramters.
|
|
|
|
# (See http://firefox-source-docs.mozilla.org/taskcluster/taskcluster/parameters.html#push-information # noqa
|
|
|
|
# and http://firefox-source-docs.mozilla.org/taskcluster/taskcluster/parameters.html#comm-push-information) # noqa
|
|
|
|
Required('project-repo-param-prefix'): basestring,
|
2017-11-02 20:37:20 +03:00
|
|
|
Required('treeherder'): {
|
|
|
|
# Mapping of treeherder group symbols to descriptive names
|
|
|
|
Required('group-names'): {basestring: basestring}
|
2017-11-02 23:34:47 +03:00
|
|
|
},
|
2017-12-14 02:00:14 +03:00
|
|
|
Required('index'): {
|
2017-12-14 02:00:57 +03:00
|
|
|
Required('products'): [basestring],
|
2017-12-14 02:00:14 +03:00
|
|
|
},
|
2017-11-02 23:34:47 +03:00
|
|
|
Required('try'): {
|
|
|
|
# We have a few platforms for which we want to do some "extra" builds, or at
|
|
|
|
# least build-ish things. Sort of. Anyway, these other things are implemented
|
|
|
|
# as different "platforms". These do *not* automatically ride along with "-p
|
|
|
|
# all"
|
|
|
|
Required('ridealong-builds', default={}): {basestring: [basestring]},
|
|
|
|
},
|
2018-04-19 18:21:30 +03:00
|
|
|
Required('release-promotion'): {
|
|
|
|
Required('products'): [basestring],
|
|
|
|
},
|
2018-01-09 20:44:04 +03:00
|
|
|
Required('scriptworker'): {
|
2018-01-12 11:08:54 +03:00
|
|
|
# Prefix to add to scopes controlling scriptworkers
|
|
|
|
Required('scope-prefix'): basestring,
|
2018-01-09 20:44:04 +03:00
|
|
|
# Mapping of scriptworker types to scopes they accept
|
|
|
|
Required('worker-types'): {basestring: [basestring]}
|
|
|
|
},
|
2018-04-26 01:16:49 +03:00
|
|
|
Required('partner'): {
|
|
|
|
# Release config for partner repacks
|
|
|
|
Required('release'): {basestring: basestring},
|
|
|
|
# Staging config for partner repacks
|
|
|
|
Required('staging'): {basestring: basestring},
|
|
|
|
},
|
2017-11-02 20:37:20 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
|
2018-05-03 05:28:11 +03:00
|
|
|
@attr.s(frozen=True)
|
|
|
|
class GraphConfig(object):
|
|
|
|
_config = attr.ib()
|
|
|
|
root_dir = attr.ib()
|
|
|
|
|
|
|
|
def __getitem__(self, name):
|
|
|
|
return self._config[name]
|
|
|
|
|
|
|
|
|
2017-11-02 20:37:20 +03:00
|
|
|
def validate_graph_config(config):
|
|
|
|
return validate_schema(graph_config_schema, config, "Invalid graph configuration:")
|
2018-05-03 04:28:43 +03:00
|
|
|
|
|
|
|
|
|
|
|
def load_graph_config(root_dir):
|
|
|
|
config_yml = os.path.join(root_dir, "config.yml")
|
|
|
|
if not os.path.exists(config_yml):
|
|
|
|
raise Exception("Couldn't find taskgraph configuration: {}".format(config_yml))
|
|
|
|
|
|
|
|
logger.debug("loading config from `{}`".format(config_yml))
|
|
|
|
with open(config_yml) as f:
|
|
|
|
config = yaml.load(f)
|
|
|
|
|
|
|
|
validate_graph_config(config)
|
2018-05-03 05:28:11 +03:00
|
|
|
return GraphConfig(config=config, root_dir=root_dir)
|