diff options
Diffstat (limited to 'buildscripts/ciconfig/evergreen.py')
-rw-r--r-- | buildscripts/ciconfig/evergreen.py | 65 |
1 files changed, 34 insertions, 31 deletions
diff --git a/buildscripts/ciconfig/evergreen.py b/buildscripts/ciconfig/evergreen.py index 3c41d6e2012..16af4226078 100644 --- a/buildscripts/ciconfig/evergreen.py +++ b/buildscripts/ciconfig/evergreen.py @@ -1,4 +1,5 @@ """API to parse and access the configuration present in a evergreen.yml file. + The API also provides methods to access specific fields present in the mongodb/mongo configuration file. """ @@ -31,7 +32,7 @@ class EvergreenProjectConfig(object): @property def task_names(self): - """The list of task names.""" + """Get the list of task names.""" return self._tasks_by_name.keys() def get_task(self, task_name): @@ -40,7 +41,7 @@ class EvergreenProjectConfig(object): @property def lifecycle_task_names(self): - """The list of names of the tasks that have not been excluded from test lifecycle.""" + """Get the list of names of the tasks that have not been excluded from test lifecycle.""" excluded = self._get_test_lifecycle_excluded_task_names() return [name for name in self.task_names if name not in excluded] @@ -53,7 +54,7 @@ class EvergreenProjectConfig(object): @property def variant_names(self): - """The list of build variant names.""" + """Get the list of build variant names.""" return self._variants_by_name.keys() def get_variant(self, variant_name): @@ -70,19 +71,17 @@ class Task(object): @property def name(self): - """The task name.""" + """Get the task name.""" return self.raw["name"] @property def depends_on(self): - """The list of task names this task depends on.""" + """Get the list of task names this task depends on.""" return self.raw.get("depends_on", []) @property def resmoke_args(self): - """The value of the resmoke_args argument of the 'run tests' function if it is - defined, or None. - """ + """Get the resmoke_args from 'run tests' function if defined, or None.""" for command in self.raw.get("commands", []): if command.get("func") == "run tests": return command.get("vars", {}).get("resmoke_args") @@ -90,22 +89,21 @@ class Task(object): @property def resmoke_suite(self): - """The value of the --suites option in the resmoke_args argument of the 'run tests' - function if it is defined, or None. """ + """Get the --suites option in the resmoke_args of 'run tests' if defined, or None.""" args = self.resmoke_args if args: return ResmokeArgs.get_arg(args, "suites") + return None def __str__(self): return self.name class Variant(object): - """Represent a build variant configuration as found in an Evergreen project - configuration file. - """ + """Build variant configuration as found in an Evergreen project configuration file.""" def __init__(self, conf_dict, task_map): + """Initialize Variant.""" self.raw = conf_dict run_on = self.run_on self.tasks = [ @@ -118,40 +116,44 @@ class Variant(object): @property def name(self): - """The build variant name.""" + """Get the build variant name.""" return self.raw["name"] @property def display_name(self): - """The build variant display name, or None if not found.""" + """Get the build variant display name, or None if not found.""" return self.raw.get("display_name") @property def batchtime(self): - """The build variant batchtime parameter as a datetime.timedelta, or None if not found.""" + """Get the build variant batchtime parameter as datetime.timedelta. + + Return None if the batchtime parameter is not found. + """ batchtime = self.raw.get("batchtime") return datetime.timedelta(minutes=batchtime) if batchtime is not None else None @property def modules(self): - """The build variant modules parameter as a list of module names.""" + """Get build variant modules parameter as a list of module names.""" modules = self.raw.get("modules") return modules if modules is not None else [] @property def run_on(self): - """The build variant run_on parameter as a list of distro names.""" + """Get build variant run_on parameter as a list of distro names.""" run_on = self.raw.get("run_on") return run_on if run_on is not None else [] @property def task_names(self): - """The list of task names.""" + """Get list of task names.""" return [t.name for t in self.tasks] def get_task(self, task_name): - """Return the task with the given name as an instance of VariantTask or None if this - variant does not run the task. + """Return the task with the given name as an instance of VariantTask. + + Return None if this variant does not run the task. """ for task in self.tasks: if task.name == task_name: @@ -169,12 +171,12 @@ class Variant(object): @property def test_flags(self): - """Return the value of the test_flags expansion or None if not found.""" + """Get the value of the test_flags expansion or None if not found.""" return self.expansion("test_flags") @property def num_jobs_available(self): - """Return the value of the num_jobs_available expansion or None if not found.""" + """Get the value of the num_jobs_available expansion or None if not found.""" return self.expansion("num_jobs_available") @@ -182,16 +184,17 @@ class VariantTask(Task): """Represent a task definition in the context of a build variant.""" def __init__(self, task, run_on, variant): + """Initialize VariantTask.""" Task.__init__(self, task.raw) self.run_on = run_on self.variant = variant @property def combined_resmoke_args(self): - """Return the combined resmoke arguments resulting from the concatenation of the task's - resmoke_args parameter and the variant's test_flags parameter. + """Get the combined resmoke arguments. - If the task does not have a 'resmoke_args' parameter, then None is returned. + This results from the concatenation of the task's resmoke_args parameter and the + variant's test_flags parameter. """ resmoke_args = self.resmoke_args test_flags = self.variant.test_flags @@ -199,16 +202,16 @@ class VariantTask(Task): return None elif test_flags is None: return self.resmoke_args - else: - return "{} {}".format(resmoke_args, test_flags) + return "{} {}".format(resmoke_args, test_flags) class ResmokeArgs(object): + """ResmokeArgs class.""" + @staticmethod def get_arg(resmoke_args, name): - """Return the value of the option --'name' in the 'resmoke_args' string or - None if not found. - """ + """Return the value from --'name' in the 'resmoke_args' string or None if not found.""" match = re.search(r"--{}[=\s](?P<value>\w+)".format(name), resmoke_args) if match: return match.group("value") + return None |