2021-04-22 19:34:51 +00: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/.
|
|
|
|
"""
|
|
|
|
Transform the beetmover task into an actual task description.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import logging
|
|
|
|
|
2021-12-15 23:14:23 +00:00
|
|
|
from taskgraph.util.schema import optionally_keyed_by, resolve_keyed_by
|
2021-04-22 19:34:51 +00:00
|
|
|
from taskgraph.transforms.base import TransformSequence
|
|
|
|
from taskgraph.transforms.task import task_description_schema
|
2022-03-11 23:23:38 +00:00
|
|
|
from voluptuous import Optional, Required, Schema
|
2021-04-22 19:34:51 +00:00
|
|
|
|
|
|
|
from fenix_taskgraph.util.scriptworker import generate_beetmover_artifact_map
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
beetmover_description_schema = Schema(
|
|
|
|
{
|
|
|
|
# unique name to describe this beetmover task, defaults to {dep.label}-beetmover
|
2022-03-11 23:23:38 +00:00
|
|
|
Required("name"): str,
|
2021-04-22 19:34:51 +00:00
|
|
|
Required("worker"): {"upstream-artifacts": [dict]},
|
|
|
|
# treeherder is allowed here to override any defaults we use for beetmover.
|
|
|
|
Optional("treeherder"): task_description_schema["treeherder"],
|
|
|
|
Optional("attributes"): task_description_schema["attributes"],
|
|
|
|
Optional("dependencies"): task_description_schema["dependencies"],
|
2022-03-11 23:23:38 +00:00
|
|
|
Optional("run-on-tasks-for"): [str],
|
2021-12-15 23:14:23 +00:00
|
|
|
Optional("bucket-scope"): optionally_keyed_by("level", "build-type", str),
|
2021-04-22 19:34:51 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
transforms = TransformSequence()
|
|
|
|
transforms.add_validate(beetmover_description_schema)
|
|
|
|
|
|
|
|
|
|
|
|
@transforms.add
|
|
|
|
def make_task_description(config, tasks):
|
|
|
|
for task in tasks:
|
|
|
|
attributes = task["attributes"]
|
|
|
|
|
|
|
|
label = "beetmover-{}".format(task["name"])
|
2022-03-11 23:23:38 +00:00
|
|
|
description = "Beetmover submission for build type '{build_type}'".format(
|
|
|
|
build_type=attributes.get("build-type"),
|
2021-04-22 19:34:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
if task.get("locale"):
|
|
|
|
attributes["locale"] = task["locale"]
|
|
|
|
|
2021-12-15 23:14:23 +00:00
|
|
|
resolve_keyed_by(
|
2022-03-11 23:23:38 +00:00
|
|
|
task,
|
2021-12-15 23:14:23 +00:00
|
|
|
"bucket-scope",
|
2022-03-11 23:23:38 +00:00
|
|
|
item_name=task["name"],
|
2021-12-15 23:14:23 +00:00
|
|
|
**{
|
2022-03-11 23:23:38 +00:00
|
|
|
"build-type": task["attributes"]["build-type"],
|
|
|
|
"level": config.params["level"],
|
2021-12-15 23:14:23 +00:00
|
|
|
}
|
|
|
|
)
|
2022-03-11 23:23:38 +00:00
|
|
|
bucket_scope = task.pop("bucket-scope")
|
2021-12-15 22:09:45 +00:00
|
|
|
|
2021-04-22 19:34:51 +00:00
|
|
|
task = {
|
|
|
|
"label": label,
|
|
|
|
"description": description,
|
|
|
|
"worker-type": "beetmover",
|
|
|
|
"worker": task["worker"],
|
|
|
|
"scopes": [
|
2021-12-15 21:06:34 +00:00
|
|
|
bucket_scope,
|
2021-04-22 19:34:51 +00:00
|
|
|
"project:mobile:fenix:releng:beetmover:action:direct-push-to-bucket",
|
|
|
|
],
|
|
|
|
"dependencies": task["dependencies"],
|
|
|
|
"attributes": attributes,
|
|
|
|
"run-on-projects": attributes.get("run_on_projects"),
|
|
|
|
"run-on-tasks-for": attributes.get("run_on_tasks_for"),
|
|
|
|
"treeherder": task["treeherder"],
|
|
|
|
}
|
|
|
|
|
|
|
|
yield task
|
|
|
|
|
|
|
|
|
|
|
|
def craft_release_properties(config, task):
|
|
|
|
params = config.params
|
|
|
|
return {
|
2022-03-11 23:23:38 +00:00
|
|
|
"app-name": str(params["project"]),
|
|
|
|
"app-version": str(params["version"]),
|
|
|
|
"branch": str(params["project"]),
|
|
|
|
"build-id": str(params["moz_build_date"]),
|
2021-04-22 19:34:51 +00:00
|
|
|
"hash-type": "sha512",
|
|
|
|
"platform": "android",
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@transforms.add
|
|
|
|
def make_task_worker(config, tasks):
|
|
|
|
for task in tasks:
|
|
|
|
locale = task["attributes"].get("locale")
|
|
|
|
build_type = task["attributes"]["build-type"]
|
|
|
|
|
|
|
|
task["worker"].update(
|
|
|
|
{
|
|
|
|
"implementation": "beetmover",
|
|
|
|
"release-properties": craft_release_properties(config, task),
|
|
|
|
"artifact-map": generate_beetmover_artifact_map(
|
|
|
|
config, task, platform=build_type, locale=locale
|
|
|
|
),
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
if locale:
|
|
|
|
task["worker"]["locale"] = locale
|
|
|
|
|
|
|
|
yield task
|