[fenix] stop triggering multiple nightlies off the same revision
[gecko.git] / mobile / android / fenix / taskcluster / fenix_taskgraph / target_tasks.py
blob7c31524182718636ee53517c330d78cac6b76764
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 import os
6 from redo import retry
8 from taskgraph.target_tasks import _target_task
9 from taskgraph.util.taskcluster import find_task_id
12 def index_exists(index_path, reason=""):
13 print(f"Looking for existing index {index_path} {reason}...")
14 try:
15 task_id = find_task_id(index_path)
16 print(f"Index {index_path} exists: taskId {task_id}")
17 return True
18 except KeyError:
19 print(f"Index {index_path} doesn't exist.")
20 return False
23 @_target_task("release")
24 def target_tasks_default(full_task_graph, parameters, graph_config):
26 # TODO Use shipping-phase
27 def filter(task, parameters):
28 return task.attributes.get("release-type", "") == parameters["release_type"]
30 return [l for l, t in full_task_graph.tasks.items() if filter(t, parameters)]
33 @_target_task("nightly")
34 def target_tasks_nightly(full_task_graph, parameters, graph_config):
35 """Select the set of tasks required for a nightly build."""
37 def filter(task, parameters):
38 return task.attributes.get("nightly", False)
40 index_path = (
41 f"{graph_config['trust-domain']}.v2.{parameters['project']}.branch."
42 f"{parameters['head_ref']}.revision.{parameters['head_rev']}.taskgraph.decision-nightly"
44 if os.environ.get("MOZ_AUTOMATION") and retry(
45 index_exists,
46 args=(index_path,),
47 kwargs={
48 "reason": "to avoid triggering multiple nightlies off the same revision",
51 return []
53 return [l for l, t in full_task_graph.tasks.items() if filter(t, parameters)]
56 def _filter_fennec(fennec_type, task, parameters):
57 return task.attributes.get("build-type", "") == "fennec-{}".format(fennec_type)
60 @_target_task("fennec-production")
61 def target_tasks_fennec_nightly(full_task_graph, parameters, graph_config):
62 """Select the set of tasks required for a production build signed with the fennec key."""
64 return [
66 for l, t in full_task_graph.tasks.items()
67 if _filter_fennec("production", t, parameters)
71 @_target_task("bump_android_components")
72 def target_tasks_bump_android_components(full_task_graph, parameters, graph_config):
73 """Select the set of tasks required to update android components."""
75 def filter(task, parameters):
76 return task.attributes.get("bump-type", "") == "android-components"
78 return [l for l, t in full_task_graph.tasks.items() if filter(t, parameters)]
81 @_target_task("screenshots")
82 def target_tasks_screnshots(full_task_graph, parameters, graph_config):
83 """Select the set of tasks required to generate screenshots on a real device."""
85 def filter(task, parameters):
86 return task.attributes.get("screenshots", False)
88 return [l for l, t in full_task_graph.tasks.items() if filter(t, parameters)]