2019-09-12 16:45:26 +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/.
|
|
|
|
|
2022-06-15 15:12:47 +00:00
|
|
|
import os
|
|
|
|
from redo import retry
|
|
|
|
|
2020-12-16 14:37:22 +00:00
|
|
|
from taskgraph.target_tasks import _target_task
|
2022-06-15 15:12:47 +00:00
|
|
|
from taskgraph.util.taskcluster import find_task_id
|
|
|
|
|
|
|
|
|
|
|
|
def index_exists(index_path, reason=""):
|
|
|
|
print(f"Looking for existing index {index_path} {reason}...")
|
|
|
|
try:
|
|
|
|
task_id = find_task_id(index_path)
|
|
|
|
print(f"Index {index_path} exists: taskId {task_id}")
|
|
|
|
return True
|
|
|
|
except KeyError:
|
|
|
|
print(f"Index {index_path} doesn't exist.")
|
|
|
|
return False
|
2019-10-02 09:05:56 +00:00
|
|
|
|
|
|
|
|
2022-06-28 12:48:38 +00:00
|
|
|
@_target_task("promote")
|
|
|
|
def target_tasks_promote(full_task_graph, parameters, graph_config):
|
|
|
|
def filter(task, parameters):
|
|
|
|
if (
|
|
|
|
task.attributes.get("release-type") == parameters["release_type"]
|
|
|
|
and task.attributes.get("shipping_phase") == "promote"
|
|
|
|
):
|
|
|
|
return True
|
|
|
|
|
|
|
|
return [l for l, t in full_task_graph.tasks.items() if filter(t, parameters)]
|
|
|
|
|
|
|
|
|
2022-06-28 09:48:22 +00:00
|
|
|
@_target_task("ship")
|
2022-06-28 12:48:38 +00:00
|
|
|
def target_tasks_ship(full_task_graph, parameters, graph_config):
|
|
|
|
filtered_for_candidates = target_tasks_promote(
|
|
|
|
full_task_graph,
|
|
|
|
parameters,
|
|
|
|
graph_config,
|
|
|
|
)
|
2019-10-02 09:05:56 +00:00
|
|
|
|
|
|
|
def filter(task, parameters):
|
2022-06-28 12:48:38 +00:00
|
|
|
# Include promotion tasks; these will be optimized out
|
|
|
|
if task.label in filtered_for_candidates:
|
|
|
|
return True
|
|
|
|
|
|
|
|
if (
|
|
|
|
task.attributes.get("release-type") == parameters["release_type"]
|
|
|
|
and task.attributes.get("shipping_phase") == "ship"
|
|
|
|
):
|
|
|
|
return True
|
2019-09-18 09:40:14 +00:00
|
|
|
|
2021-06-09 19:52:28 +00:00
|
|
|
return [l for l, t in full_task_graph.tasks.items() if filter(t, parameters)]
|
2019-09-13 10:48:22 +00:00
|
|
|
|
|
|
|
|
2019-09-18 10:49:22 +00:00
|
|
|
@_target_task("nightly")
|
|
|
|
def target_tasks_nightly(full_task_graph, parameters, graph_config):
|
|
|
|
"""Select the set of tasks required for a nightly build."""
|
|
|
|
|
2020-04-14 12:04:26 +00:00
|
|
|
def filter(task, parameters):
|
2021-08-12 15:16:44 +00:00
|
|
|
return task.attributes.get("nightly", False)
|
2019-09-18 10:49:22 +00:00
|
|
|
|
2022-06-15 15:12:47 +00:00
|
|
|
index_path = (
|
|
|
|
f"{graph_config['trust-domain']}.v2.{parameters['project']}.branch."
|
|
|
|
f"{parameters['head_ref']}.revision.{parameters['head_rev']}.taskgraph.decision-nightly"
|
|
|
|
)
|
|
|
|
if os.environ.get("MOZ_AUTOMATION") and retry(
|
|
|
|
index_exists,
|
|
|
|
args=(index_path,),
|
|
|
|
kwargs={
|
|
|
|
"reason": "to avoid triggering multiple nightlies off the same revision",
|
|
|
|
},
|
|
|
|
):
|
|
|
|
return []
|
|
|
|
|
2021-06-09 19:52:28 +00:00
|
|
|
return [l for l, t in full_task_graph.tasks.items() if filter(t, parameters)]
|
2019-09-16 09:03:42 +00:00
|
|
|
|
2020-02-19 14:35:20 +00:00
|
|
|
|
|
|
|
def _filter_fennec(fennec_type, task, parameters):
|
|
|
|
return task.attributes.get("build-type", "") == "fennec-{}".format(fennec_type)
|
|
|
|
|
2020-01-15 10:10:49 +00:00
|
|
|
|
2020-06-04 12:54:11 +00:00
|
|
|
@_target_task("fennec-production")
|
2020-02-19 14:35:20 +00:00
|
|
|
def target_tasks_fennec_nightly(full_task_graph, parameters, graph_config):
|
2020-06-04 12:54:11 +00:00
|
|
|
"""Select the set of tasks required for a production build signed with the fennec key."""
|
2020-02-19 14:35:20 +00:00
|
|
|
|
2022-03-11 23:23:38 +00:00
|
|
|
return [
|
|
|
|
l
|
|
|
|
for l, t in full_task_graph.tasks.items()
|
|
|
|
if _filter_fennec("production", t, parameters)
|
|
|
|
]
|
2020-01-15 10:10:49 +00:00
|
|
|
|
2019-09-16 09:03:42 +00:00
|
|
|
|
2020-03-20 09:26:44 +00:00
|
|
|
@_target_task("bump_android_components")
|
|
|
|
def target_tasks_bump_android_components(full_task_graph, parameters, graph_config):
|
|
|
|
"""Select the set of tasks required to update android components."""
|
|
|
|
|
|
|
|
def filter(task, parameters):
|
|
|
|
return task.attributes.get("bump-type", "") == "android-components"
|
|
|
|
|
2021-06-09 19:52:28 +00:00
|
|
|
return [l for l, t in full_task_graph.tasks.items() if filter(t, parameters)]
|
2020-07-16 14:08:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
@_target_task("screenshots")
|
|
|
|
def target_tasks_screnshots(full_task_graph, parameters, graph_config):
|
|
|
|
"""Select the set of tasks required to generate screenshots on a real device."""
|
|
|
|
|
|
|
|
def filter(task, parameters):
|
|
|
|
return task.attributes.get("screenshots", False)
|
|
|
|
|
2021-06-09 19:52:28 +00:00
|
|
|
return [l for l, t in full_task_graph.tasks.items() if filter(t, parameters)]
|