forked from mirrors/gecko-dev
The `taskgraph` package generates TaskCluster task graphs based on collections of task "kinds". Initially, there is only one kind, the "legacy" kind, which reads the YAML files from `testing/taskcluster/tasks` to generate the task graph. Try syntax is implemented by filtering the tasks in the taskgraph after it has been created, then extending the result to include any prerequisite tasks. A collection of `mach taskgraph` subcommands are provided for developers to extend or debug the task-graph generation process. MozReview-Commit-ID: 1TJCns4XxZ8 --HG-- rename : testing/taskcluster/docs/index.rst => taskcluster/docs/index.rst extra : rebase_source : 7b9125281d66044db9bd8e4a1fade16136f384b9 extra : histedit_source : 47640d27080acda0279270babbcf33f5badb0d1c
55 lines
1.6 KiB
Python
55 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
# 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 json
|
|
import sys
|
|
import yaml
|
|
from mozbuild.util import ReadOnlyDict
|
|
|
|
class Parameters(ReadOnlyDict):
|
|
"""An immutable dictionary with nicer KeyError messages on failure"""
|
|
def __getitem__(self, k):
|
|
try:
|
|
return super(Parameters, self).__getitem__(k)
|
|
except KeyError:
|
|
raise KeyError("taskgraph parameter {!r} not found".format(k))
|
|
|
|
|
|
def load_parameters_file(options):
|
|
"""
|
|
Load parameters from the --parameters option
|
|
"""
|
|
filename = options['parameters']
|
|
if not filename:
|
|
return Parameters()
|
|
with open(filename) as f:
|
|
if filename.endswith('.yml'):
|
|
return Parameters(**yaml.safe_load(f))
|
|
elif filename.endswith('.json'):
|
|
return Parameters(**json.load(f))
|
|
else:
|
|
print("Parameters file `{}` is not JSON or YAML".format(filename))
|
|
sys.exit(1)
|
|
|
|
def get_decision_parameters(options):
|
|
"""
|
|
Load parameters from the command-line options for 'taskgraph decision'.
|
|
"""
|
|
return Parameters({n: options[n] for n in [
|
|
'base_repository',
|
|
'head_repository',
|
|
'head_rev',
|
|
'head_ref',
|
|
'revision_hash',
|
|
'message',
|
|
'project',
|
|
'pushlog_id',
|
|
'owner',
|
|
'level',
|
|
'target_tasks_method',
|
|
] if n in options})
|