2016-05-17 01:53:22 +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-11-22 02:50:04 +03:00
|
|
|
import attr
|
2016-06-21 04:06:55 +03:00
|
|
|
|
2018-11-22 02:50:04 +03:00
|
|
|
|
|
|
|
@attr.s
|
2016-06-28 01:57:44 +03:00
|
|
|
class Task(object):
|
2016-05-17 01:53:22 +03:00
|
|
|
"""
|
2016-06-28 01:57:44 +03:00
|
|
|
Representation of a task in a TaskGraph. Each Task has, at creation:
|
|
|
|
|
|
|
|
- kind: the name of the task kind
|
|
|
|
- label; the label for this task
|
|
|
|
- attributes: a dictionary of attributes for this task (used for filtering)
|
|
|
|
- task: the task definition (JSON-able dictionary)
|
2017-08-01 23:02:59 +03:00
|
|
|
- optimization: optimization to apply to the task (see taskgraph.optimize)
|
2017-03-09 00:22:31 +03:00
|
|
|
- dependencies: tasks this one depends on, in the form {name: label}, for example
|
2020-10-09 03:07:56 +03:00
|
|
|
{'build': 'build-linux64/opt', 'docker-image': 'docker-image-desktop-test'}
|
2019-03-04 20:07:34 +03:00
|
|
|
- soft_dependencies: tasks this one may depend on if they are available post
|
|
|
|
optimisation. They are set as a list of tasks label.
|
2020-08-27 23:45:33 +03:00
|
|
|
- if_dependencies: only run this task if at least one of these dependencies
|
|
|
|
are present.
|
2016-06-28 01:57:44 +03:00
|
|
|
|
|
|
|
And later, as the task-graph processing proceeds:
|
|
|
|
|
|
|
|
- task_id -- TaskCluster taskId under which this task will be created
|
|
|
|
|
2018-06-08 22:08:34 +03:00
|
|
|
This class is just a convenience wrapper for the data type and managing
|
2017-03-10 07:14:30 +03:00
|
|
|
display, comparison, serialization, etc. It has no functionality of its own.
|
2016-05-17 01:53:22 +03:00
|
|
|
"""
|
2017-01-31 10:33:27 +03:00
|
|
|
|
2018-11-22 02:50:04 +03:00
|
|
|
kind = attr.ib()
|
|
|
|
label = attr.ib()
|
|
|
|
attributes = attr.ib()
|
|
|
|
task = attr.ib()
|
2020-07-18 18:59:27 +03:00
|
|
|
description = attr.ib(default="")
|
2018-11-22 02:50:04 +03:00
|
|
|
task_id = attr.ib(default=None, init=False)
|
|
|
|
optimization = attr.ib(default=None)
|
|
|
|
dependencies = attr.ib(factory=dict)
|
2019-03-04 20:07:34 +03:00
|
|
|
soft_dependencies = attr.ib(factory=list)
|
2020-08-27 23:45:33 +03:00
|
|
|
if_dependencies = attr.ib(factory=list)
|
2018-11-22 02:50:04 +03:00
|
|
|
release_artifacts = attr.ib(
|
|
|
|
converter=attr.converters.optional(frozenset),
|
|
|
|
default=None,
|
|
|
|
)
|
2016-05-17 01:53:22 +03:00
|
|
|
|
2018-11-22 02:50:04 +03:00
|
|
|
def __attrs_post_init__(self):
|
2020-10-24 03:36:18 +03:00
|
|
|
self.attributes["kind"] = self.kind
|
2017-03-10 07:14:30 +03:00
|
|
|
|
2019-05-15 21:04:47 +03:00
|
|
|
@property
|
|
|
|
def name(self):
|
|
|
|
if self.label.startswith(self.kind + "-"):
|
2020-10-24 03:36:18 +03:00
|
|
|
return self.label[len(self.kind) + 1 :]
|
2019-05-15 21:04:47 +03:00
|
|
|
else:
|
|
|
|
raise AttributeError("Task {} does not have a name.".format(self.label))
|
|
|
|
|
2017-03-10 07:14:30 +03:00
|
|
|
def to_json(self):
|
|
|
|
rv = {
|
2020-10-24 03:36:18 +03:00
|
|
|
"kind": self.kind,
|
|
|
|
"label": self.label,
|
|
|
|
"description": self.description,
|
|
|
|
"attributes": self.attributes,
|
|
|
|
"dependencies": self.dependencies,
|
|
|
|
"soft_dependencies": sorted(self.soft_dependencies),
|
|
|
|
"if_dependencies": self.if_dependencies,
|
|
|
|
"optimization": self.optimization,
|
|
|
|
"task": self.task,
|
2017-03-10 07:14:30 +03:00
|
|
|
}
|
|
|
|
if self.task_id:
|
2020-10-24 03:36:18 +03:00
|
|
|
rv["task_id"] = self.task_id
|
2018-08-20 21:29:15 +03:00
|
|
|
if self.release_artifacts:
|
2020-10-24 03:36:18 +03:00
|
|
|
rv["release_artifacts"] = sorted(self.release_artifacts)
|
2017-03-10 07:14:30 +03:00
|
|
|
return rv
|
|
|
|
|
Bug 1281004: Specify test tasks more flexibly; r=gps; r=gbrown
This introduces a completely new way of specifying test task in-tree,
completely replacing the old spider-web of YAML files.
The high-level view is this:
- some configuration files are used to determine which test suites to run
for each test platform, and against which build platforms
- each test suite is then represented by a dictionary, and modified by a
sequence of transforms, duplicating as necessary (e.g., chunks), until
it becomes a task definition
The transforms allow sufficient generality to support just about any desired
configuration, with the advantage that common configurations are "easy" while
unusual configurations are supported but notable for their oddness (they
require a custom transform).
As of this commit, this system produces the same set of test graphs as the
existing YAML, modulo:
- extra.treeherder.groupName -- this was not consistent in the YAML
- extra.treeherder.build -- this is ignored by taskcluster-treeherder anyway
- mozharness command argument order
- boolean True values for environment variables are now the string "true"
- metadata -- this is now much more consistent, with task name being the label
Testing of this commit demonstrates that it produces the same set of test tasks for
the following projects (those which had special cases defined in the YAML):
- autoland
- ash (*)
- willow
- mozilla-inbound
- mozilla-central
- try:
-b do -p all -t all -u all
-b d -p linux64,linux64-asan -u reftest -t none
-b d -p linux64,linux64-asan -u reftest[x64] -t none[x64]
(*) this patch omits the linux64/debug tc-M-e10s(dt) test, which is enabled on
ash; ash will require a small changeset to re-enable this test.
IGNORE BAD COMMIT MESSAGES (because the hook flags try syntax!)
MozReview-Commit-ID: G34dg9f17Hq
--HG--
rename : taskcluster/taskgraph/kind/base.py => taskcluster/taskgraph/task/base.py
rename : taskcluster/taskgraph/kind/docker_image.py => taskcluster/taskgraph/task/docker_image.py
rename : taskcluster/taskgraph/kind/legacy.py => taskcluster/taskgraph/task/legacy.py
extra : rebase_source : 03e70902c2d3a297eb9e3ce852f8737c2550d5a6
extra : histedit_source : d4d9f4b192605af21f41d83495fc3c923759c3cb
2016-07-12 02:27:14 +03:00
|
|
|
@classmethod
|
|
|
|
def from_json(cls, task_dict):
|
|
|
|
"""
|
|
|
|
Given a data structure as produced by taskgraph.to_json, re-construct
|
|
|
|
the original Task object. This is used to "resume" the task-graph
|
|
|
|
generation process, for example in Action tasks.
|
|
|
|
"""
|
2017-03-10 07:14:30 +03:00
|
|
|
rv = cls(
|
2020-10-24 03:36:18 +03:00
|
|
|
kind=task_dict["kind"],
|
|
|
|
label=task_dict["label"],
|
|
|
|
description=task_dict.get("description", ""),
|
|
|
|
attributes=task_dict["attributes"],
|
|
|
|
task=task_dict["task"],
|
|
|
|
optimization=task_dict["optimization"],
|
|
|
|
dependencies=task_dict.get("dependencies"),
|
|
|
|
soft_dependencies=task_dict.get("soft_dependencies"),
|
|
|
|
if_dependencies=task_dict.get("if_dependencies"),
|
|
|
|
release_artifacts=task_dict.get("release-artifacts"),
|
2018-08-20 21:29:15 +03:00
|
|
|
)
|
2020-10-24 03:36:18 +03:00
|
|
|
if "task_id" in task_dict:
|
|
|
|
rv.task_id = task_dict["task_id"]
|
2017-03-10 07:14:30 +03:00
|
|
|
return rv
|