run_missing_tests.py (1956B)
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 6 import logging 7 8 from taskgraph.util.taskcluster import get_artifact 9 10 from ..util.constants import TEST_KINDS 11 from .registry import register_callback_action 12 from .util import create_tasks, fetch_graph_and_labels 13 14 logger = logging.getLogger(__name__) 15 16 17 @register_callback_action( 18 name="run-missing-tests", 19 title="Run Missing Tests", 20 symbol="rmt", 21 description=( 22 "Run tests in the selected push that were optimized away, usually by SETA." 23 "\n" 24 "This action is for use on pushes that will be merged into another branch," 25 "to check that optimization hasn't hidden any failures." 26 ), 27 order=250, 28 context=[], # Applies to decision task 29 ) 30 def run_missing_tests(parameters, graph_config, input, task_group_id, task_id): 31 decision_task_id, full_task_graph, label_to_taskid, _ = fetch_graph_and_labels( 32 parameters, graph_config 33 ) 34 target_tasks = get_artifact(decision_task_id, "public/target-tasks.json") 35 36 # The idea here is to schedule all tasks of the `test` kind that were 37 # targetted but did not appear in the final task-graph -- those were the 38 # optimized tasks. 39 to_run = [] 40 already_run = 0 41 for label in target_tasks: 42 task = full_task_graph.tasks[label] 43 if task.kind not in TEST_KINDS: 44 continue # not a test 45 if label in label_to_taskid: 46 already_run += 1 47 continue 48 to_run.append(label) 49 50 create_tasks( 51 graph_config, 52 to_run, 53 full_task_graph, 54 label_to_taskid, 55 parameters, 56 decision_task_id, 57 ) 58 59 logger.info( 60 f"Out of {already_run + len(to_run)} test tasks, {already_run} already existed and the action created {len(to_run)}" 61 )