Bug 1404067 - [tryselect] Improve error message on parameter mismatch, r=dustin

MozReview-Commit-ID: GMiGuNApoUF

--HG--
extra : rebase_source : 326df920793b54806cd4423ec0bf0e20df6cd42d
This commit is contained in:
Andrew Halberstadt 2017-09-28 15:25:34 -04:00
parent 5f1c377014
commit 776ed09b77
3 changed files with 43 additions and 11 deletions

View File

@ -24,19 +24,26 @@ graph-generation process and output the results.
``mach taskgraph morphed``
Get the morhped task graph
Each of these commands takes an optional ``--parameters`` option giving a file
See :doc:`how-tos` for further practical tips on debugging task-graph mechanics
locally.
Parameters
----------
Each of these commands takes an optional ``--parameters`` argument giving a file
with parameters to guide the graph generation. The decision task helpfully
produces such a file on every run, and that is generally the easiest way to get
a parameter file. The parameter keys and values are described in
:doc:`parameters`; using that information, you may modify an existing
``parameters.yml`` or create your own. The ``--parameters`` option can also
take an argument of the form ``project=<project>`` which will fetch the
parameters from the latest push on that project; or ``task-id=<task-id>`` which
will fetch the parameters from the given decision task. It defaults to
``project=mozilla-central``.
take the following forms:
See :doc:`how-tos` for further practical tips on debugging task-graph mechanics
locally.
``project=<project>``
Fetch the parameters from the latest push on that project
``task-id=<task-id>``
Fetch the parameters from the given decision task id
If not specified, parameters will default to ``project=mozilla-central``.
Taskgraph JSON Format
---------------------

View File

@ -10,6 +10,11 @@ import json
import yaml
from mozbuild.util import ReadOnlyDict
class ParameterMismatch(Exception):
"""Raised when a parameters.yml has extra or missing parameters."""
# Please keep this list sorted and in sync with taskcluster/docs/parameters.rst
PARAMETER_NAMES = set([
'base_repository',
@ -50,7 +55,7 @@ class Parameters(ReadOnlyDict):
msg.append("extra parameters: " + ", ".join(extra))
if msg:
raise Exception("; ".join(msg))
raise ParameterMismatch("; ".join(msg))
def __getitem__(self, k):
if k not in PARAMETER_NAMES:

View File

@ -5,18 +5,34 @@
from __future__ import absolute_import, print_function, unicode_literals
import os
import sys
from mozboot.util import get_state_dir
from mozbuild.base import MozbuildObject
from mozpack.files import FileFinder
from taskgraph.generator import TaskGraphGenerator
from taskgraph.parameters import load_parameters_file
from taskgraph.parameters import (
ParameterMismatch,
load_parameters_file,
)
here = os.path.abspath(os.path.dirname(__file__))
build = MozbuildObject.from_environment(cwd=here)
PARAMETER_MISMATCH = """
ERROR - The parameters being used to generate tasks differ from those defined
in your working copy:
{}
To fix this, either rebase onto the latest mozilla-central or pass in
-p/--parameters. For more information on how to define parameters, see:
https://firefox-source-docs.mozilla.org/taskcluster/taskcluster/mach.html#parameters
"""
def invalidate(cache):
if not os.path.isfile(cache):
return
@ -45,8 +61,12 @@ def generate_tasks(params=None, full=False):
os.makedirs(cache_dir)
print("Task configuration changed, generating {}".format(attr.replace('_', ' ')))
params = load_parameters_file(params)
params.check()
try:
params = load_parameters_file(params)
params.check()
except ParameterMismatch as e:
print(PARAMETER_MISMATCH.format(e.args[0]))
sys.exit(1)
cwd = os.getcwd()
os.chdir(build.topsrcdir)