target_tasks.py (3132B)
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/. 4 5 from taskgraph.target_tasks import register_target_task 6 7 from android_taskgraph.release_type import does_task_match_release_type 8 9 10 @register_target_task("promote_android") 11 def target_tasks_promote(full_task_graph, parameters, graph_config): 12 return _filter_release_promotion( 13 full_task_graph, 14 parameters, 15 filtered_for_candidates=[], 16 shipping_phase="promote", 17 ) 18 19 20 @register_target_task("push_android") 21 def target_tasks_push(full_task_graph, parameters, graph_config): 22 filtered_for_candidates = target_tasks_promote( 23 full_task_graph, 24 parameters, 25 graph_config, 26 ) 27 return _filter_release_promotion( 28 full_task_graph, parameters, filtered_for_candidates, shipping_phase="push" 29 ) 30 31 32 @register_target_task("ship_android") 33 def target_tasks_ship(full_task_graph, parameters, graph_config): 34 filtered_for_candidates = target_tasks_push( 35 full_task_graph, 36 parameters, 37 graph_config, 38 ) 39 return _filter_release_promotion( 40 full_task_graph, parameters, filtered_for_candidates, shipping_phase="ship" 41 ) 42 43 44 def _filter_release_promotion( 45 full_task_graph, parameters, filtered_for_candidates, shipping_phase 46 ): 47 def filter(task, parameters): 48 # Include promotion tasks; these will be optimized out 49 if task.label in filtered_for_candidates: 50 return True 51 52 # Ship geckoview in firefox-android ship graph 53 if ( 54 shipping_phase == "ship" 55 and task.attributes.get("shipping_product") == "fennec" 56 and task.kind in ("beetmover-geckoview", "upload-symbols") 57 and parameters["release_product"] == "firefox-android" 58 ): 59 return True 60 61 # TODO: get rid of this release_type match 62 if ( 63 task.attributes.get("shipping_phase") == shipping_phase 64 and task.attributes.get("shipping_product") == parameters["release_product"] 65 and does_task_match_release_type(task, parameters["release_type"]) 66 ): 67 return True 68 69 return False 70 71 return [l for l, t in full_task_graph.tasks.items() if filter(t, parameters)] 72 73 74 @register_target_task("screenshots") 75 def target_tasks_screnshots(full_task_graph, parameters, graph_config): 76 """Select the set of tasks required to generate screenshots on a real device.""" 77 78 def filter(task, parameters): 79 return task.attributes.get("screenshots", False) 80 81 return [l for l, t in full_task_graph.tasks.items() if filter(t, parameters)] 82 83 84 @register_target_task("legacy_api_ui_tests") 85 def target_tasks_legacy_api_ui_tests(full_task_graph, parameters, graph_config): 86 """Select the set of tasks required to run select UI tests on other API.""" 87 88 def filter(task, parameters): 89 return task.attributes.get("legacy", False) 90 91 return [l for l, t in full_task_graph.tasks.items() if filter(t, parameters)]