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
|
2020-01-23 20:09:41 +03:00
|
|
|
import sys
|
2018-05-03 05:28:11 +03:00
|
|
|
import attr
|
2019-03-19 22:13:56 +03:00
|
|
|
from six import text_type
|
2018-05-03 05:30:15 +03:00
|
|
|
from mozpack import path
|
2018-05-03 04:28:43 +03:00
|
|
|
|
2020-01-23 20:09:41 +03:00
|
|
|
from .util.python_path import find_object
|
2018-12-27 12:30:52 +03:00
|
|
|
from .util.schema import validate_schema, Schema, optionally_keyed_by
|
|
|
|
from voluptuous import Required, Optional, Any
|
2019-02-04 19:55:54 +03:00
|
|
|
from .util.yaml import load_yaml
|
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
|
2020-01-21 20:12:08 +03:00
|
|
|
Required('trust-domain'): text_type,
|
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
|
2020-01-21 20:12:08 +03:00
|
|
|
Required('project-repo-param-prefix'): text_type,
|
2018-09-29 23:53:10 +03:00
|
|
|
# This specifies the top level directory of the application being built.
|
|
|
|
# ie. "browser/" for Firefox, "comm/mail/" for Thunderbird.
|
2020-01-21 20:12:08 +03:00
|
|
|
Required('product-dir'): text_type,
|
2017-11-02 20:37:20 +03:00
|
|
|
Required('treeherder'): {
|
|
|
|
# Mapping of treeherder group symbols to descriptive names
|
2020-01-21 20:12:08 +03:00
|
|
|
Required('group-names'): {text_type: text_type}
|
2017-11-02 23:34:47 +03:00
|
|
|
},
|
2017-12-14 02:00:14 +03:00
|
|
|
Required('index'): {
|
2020-01-21 20:12:08 +03:00
|
|
|
Required('products'): [text_type]
|
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"
|
2020-01-21 20:12:08 +03:00
|
|
|
Required('ridealong-builds'): {text_type: [text_type]},
|
2017-11-02 23:34:47 +03:00
|
|
|
},
|
2018-04-19 18:21:30 +03:00
|
|
|
Required('release-promotion'): {
|
2020-01-21 20:12:08 +03:00
|
|
|
Required('products'): [text_type],
|
|
|
|
Required('flavors'): {text_type: {
|
|
|
|
Required('product'): text_type,
|
|
|
|
Required('target-tasks-method'): text_type,
|
2018-09-17 21:09:16 +03:00
|
|
|
Optional('is-rc'): bool,
|
2020-01-21 20:12:08 +03:00
|
|
|
Optional('rebuild-kinds'): [text_type],
|
2018-05-30 10:16:41 +03:00
|
|
|
Optional('version-bump'): bool,
|
|
|
|
Optional('partial-updates'): bool,
|
2018-04-23 09:17:30 +03:00
|
|
|
}},
|
2018-04-19 18:21:30 +03:00
|
|
|
},
|
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
|
2020-01-21 20:12:08 +03:00
|
|
|
Required('scope-prefix'): text_type,
|
2018-01-09 20:44:04 +03:00
|
|
|
},
|
2019-03-07 07:20:36 +03:00
|
|
|
Required('task-priority'): optionally_keyed_by('project', Any(
|
|
|
|
'highest',
|
|
|
|
'very-high',
|
|
|
|
'high',
|
|
|
|
'medium',
|
|
|
|
'low',
|
|
|
|
'very-low',
|
|
|
|
'lowest',
|
|
|
|
)),
|
2018-12-27 12:30:52 +03:00
|
|
|
Required('partner-urls'): {
|
|
|
|
Required('release-partner-repack'):
|
|
|
|
optionally_keyed_by('release-product', 'release-level', 'release-type',
|
2020-01-21 20:12:08 +03:00
|
|
|
Any(text_type, None)),
|
2018-12-27 12:30:52 +03:00
|
|
|
Required('release-eme-free-repack'):
|
|
|
|
optionally_keyed_by('release-product', 'release-level', 'release-type',
|
2020-01-21 20:12:08 +03:00
|
|
|
Any(text_type, None)),
|
2018-04-26 01:16:49 +03:00
|
|
|
},
|
2019-03-19 22:13:56 +03:00
|
|
|
Required('workers'): {
|
|
|
|
Required('aliases'): {
|
|
|
|
text_type: {
|
2019-10-18 19:04:30 +03:00
|
|
|
Required('provisioner'): optionally_keyed_by('level', text_type),
|
2019-03-19 22:13:56 +03:00
|
|
|
Required('implementation'): text_type,
|
|
|
|
Required('os'): text_type,
|
2019-12-28 02:44:06 +03:00
|
|
|
Required('worker-type'): optionally_keyed_by('level', 'release-level', text_type),
|
2019-03-19 22:13:56 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
2019-06-06 01:02:25 +03:00
|
|
|
Required('mac-notarization'): {
|
|
|
|
Required('mac-behavior'):
|
2020-02-25 18:38:27 +03:00
|
|
|
optionally_keyed_by('project',
|
2019-07-15 19:38:43 +03:00
|
|
|
Any('mac_notarize', 'mac_geckodriver', 'mac_sign',
|
|
|
|
'mac_sign_and_pkg')),
|
2019-06-06 01:03:36 +03:00
|
|
|
Required('mac-entitlements'):
|
2019-07-16 20:22:40 +03:00
|
|
|
optionally_keyed_by('platform', 'release-level', text_type),
|
2019-06-06 01:02:25 +03:00
|
|
|
},
|
2020-01-23 20:09:41 +03:00
|
|
|
Required("taskgraph"): {
|
|
|
|
Optional(
|
|
|
|
"register",
|
|
|
|
description="Python function to call to register extensions.",
|
|
|
|
): text_type,
|
2020-02-05 01:32:12 +03:00
|
|
|
Optional('decision-parameters'): text_type,
|
2020-01-23 20:09:41 +03:00
|
|
|
},
|
2017-11-02 20:37:20 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
|
2019-03-07 07:20:36 +03:00
|
|
|
@attr.s(frozen=True, cmp=False)
|
2018-05-03 05:28:11 +03:00
|
|
|
class GraphConfig(object):
|
|
|
|
_config = attr.ib()
|
|
|
|
root_dir = attr.ib()
|
|
|
|
|
2020-01-23 20:09:41 +03:00
|
|
|
_PATH_MODIFIED = False
|
|
|
|
|
2018-05-03 05:28:11 +03:00
|
|
|
def __getitem__(self, name):
|
|
|
|
return self._config[name]
|
|
|
|
|
2020-01-23 20:09:41 +03:00
|
|
|
def register(self):
|
|
|
|
"""
|
|
|
|
Add the project's taskgraph directory to the python path, and register
|
|
|
|
any extensions present.
|
|
|
|
"""
|
|
|
|
if GraphConfig._PATH_MODIFIED:
|
|
|
|
raise Exception("Can't register multiple directories on python path.")
|
|
|
|
GraphConfig._PATH_MODIFIED = True
|
|
|
|
sys.path.insert(0, os.path.dirname(self.root_dir))
|
|
|
|
register_path = self['taskgraph'].get('register')
|
|
|
|
if register_path:
|
|
|
|
find_object(register_path)(self)
|
|
|
|
|
2018-05-03 05:30:15 +03:00
|
|
|
@property
|
|
|
|
def taskcluster_yml(self):
|
|
|
|
if path.split(self.root_dir)[-2:] != ['taskcluster', 'ci']:
|
|
|
|
raise Exception(
|
|
|
|
"Not guessing path to `.taskcluster.yml`. "
|
|
|
|
"Graph config in non-standard location."
|
|
|
|
)
|
|
|
|
return os.path.join(
|
|
|
|
os.path.dirname(os.path.dirname(self.root_dir)),
|
|
|
|
".taskcluster.yml",
|
|
|
|
)
|
|
|
|
|
2018-05-03 05:28:11 +03:00
|
|
|
|
2017-11-02 20:37:20 +03:00
|
|
|
def validate_graph_config(config):
|
2018-10-03 00:17:07 +03:00
|
|
|
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))
|
2019-02-04 19:55:54 +03:00
|
|
|
config = load_yaml(config_yml)
|
2018-05-03 04:28:43 +03:00
|
|
|
|
|
|
|
validate_graph_config(config)
|
2018-05-03 05:28:11 +03:00
|
|
|
return GraphConfig(config=config, root_dir=root_dir)
|