2019-09-24 10:52:05 +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/.
|
|
|
|
"""
|
|
|
|
Apply some defaults and minor modifications to the jobs defined in the build
|
|
|
|
kind.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from taskgraph.transforms.base import TransformSequence
|
|
|
|
from taskgraph.util.schema import resolve_keyed_by
|
|
|
|
|
|
|
|
|
|
|
|
transforms = TransformSequence()
|
|
|
|
|
|
|
|
|
|
|
|
@transforms.add
|
|
|
|
def resolve_keys(config, tasks):
|
|
|
|
for task in tasks:
|
2021-06-14 18:07:02 +00:00
|
|
|
for key in ("run-on-tasks-for", "signing-format", "notify"):
|
2019-09-24 10:52:05 +00:00
|
|
|
resolve_keyed_by(
|
|
|
|
task,
|
|
|
|
key,
|
|
|
|
item_name=task["name"],
|
|
|
|
**{
|
2022-03-11 23:23:38 +00:00
|
|
|
"build-type": task["attributes"]["build-type"],
|
|
|
|
"level": config.params["level"],
|
|
|
|
"tasks-for": config.params["tasks_for"],
|
2019-09-24 10:52:05 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
yield task
|
|
|
|
|
2022-03-11 23:23:38 +00:00
|
|
|
|
2021-03-10 10:31:55 +00:00
|
|
|
@transforms.add
|
|
|
|
def set_worker_type(config, tasks):
|
|
|
|
for task in tasks:
|
|
|
|
worker_type = "dep-signing"
|
|
|
|
if (
|
|
|
|
str(config.params["level"]) == "3"
|
|
|
|
and task["attributes"]["build-type"]
|
2022-03-11 23:23:38 +00:00
|
|
|
in (
|
|
|
|
"nightly",
|
|
|
|
"beta",
|
|
|
|
"release",
|
|
|
|
"android-test-nightly",
|
|
|
|
"beta-mozillaonline",
|
|
|
|
"release-mozillaonline",
|
|
|
|
)
|
2022-01-14 12:04:02 +00:00
|
|
|
and config.params["tasks_for"] in ("cron", "action")
|
2021-03-10 10:31:55 +00:00
|
|
|
):
|
|
|
|
worker_type = "signing"
|
|
|
|
task["worker-type"] = worker_type
|
|
|
|
yield task
|
|
|
|
|
|
|
|
|
|
|
|
@transforms.add
|
|
|
|
def set_signing_type(config, tasks):
|
|
|
|
for task in tasks:
|
|
|
|
signing_type = "dep-signing"
|
2022-03-11 23:23:38 +00:00
|
|
|
if str(config.params["level"]) == "3" and config.params["tasks_for"] in (
|
|
|
|
"cron",
|
|
|
|
"action",
|
2021-03-10 10:31:55 +00:00
|
|
|
):
|
|
|
|
if task["attributes"]["build-type"] in ("beta", "release"):
|
|
|
|
signing_type = "fennec-production-signing"
|
2022-03-11 23:23:38 +00:00
|
|
|
elif task["attributes"]["build-type"] in (
|
|
|
|
"nightly",
|
|
|
|
"android-test-nightly",
|
|
|
|
"beta-mozillaonline",
|
|
|
|
"release-mozillaonline",
|
|
|
|
):
|
2021-03-10 10:31:55 +00:00
|
|
|
signing_type = "production-signing"
|
|
|
|
task.setdefault("worker", {})["signing-type"] = signing_type
|
|
|
|
yield task
|
|
|
|
|
|
|
|
|
|
|
|
@transforms.add
|
|
|
|
def set_index(config, tasks):
|
|
|
|
for task in tasks:
|
|
|
|
index = {}
|
2022-03-11 23:23:38 +00:00
|
|
|
if config.params["tasks_for"] in ("cron", "action") and task["attributes"][
|
|
|
|
"build-type"
|
|
|
|
] in ("nightly", "debut", "nightly-simulation", "beta", "release"):
|
2021-03-10 10:31:55 +00:00
|
|
|
index["type"] = "signing"
|
|
|
|
task["index"] = index
|
|
|
|
yield task
|
|
|
|
|
2019-09-24 10:52:05 +00:00
|
|
|
|
|
|
|
@transforms.add
|
|
|
|
def set_signing_attributes(config, tasks):
|
|
|
|
for task in tasks:
|
|
|
|
task["attributes"]["signed"] = True
|
|
|
|
yield task
|
|
|
|
|
|
|
|
|
|
|
|
@transforms.add
|
|
|
|
def set_signing_format(config, tasks):
|
|
|
|
for task in tasks:
|
2019-12-09 08:40:11 +00:00
|
|
|
signing_format = task.pop("signing-format")
|
2019-09-24 10:52:05 +00:00
|
|
|
for upstream_artifact in task["worker"]["upstream-artifacts"]:
|
2019-12-09 08:40:11 +00:00
|
|
|
upstream_artifact["formats"] = [signing_format]
|
2019-09-24 10:52:05 +00:00
|
|
|
yield task
|
2021-06-14 18:07:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
@transforms.add
|
|
|
|
def format_email(config, tasks):
|
|
|
|
version = config.params["version"]
|
|
|
|
|
|
|
|
for task in tasks:
|
|
|
|
if "notify" in task:
|
|
|
|
email = task["notify"].get("email")
|
|
|
|
if email:
|
|
|
|
email["subject"] = email["subject"].format(version=version)
|
|
|
|
email["content"] = email["content"].format(version=version)
|
|
|
|
|
|
|
|
yield task
|