taskcluster/gecko_taskgraph/actions/run_missing_tests.py
author Ting-Yu Lin <tlin@mozilla.com>
Sat, 01 Apr 2023 04:17:05 +0000
changeset 658805 7437637d0b5c2745440bfeba4adb64689d24044f
parent 608786 3867035dfc2256e1ebcdfdcdf9d5f4fe8c018a3e
permissions -rw-r--r--
Bug 1055894 - Add GetLogicalNormalRect() and adapt some callers of GetNormalRect(). r=emilio This patch makes the API nicer, and shouldn't change the behavior. Differential Revision: https://phabricator.services.mozilla.com/D174344

# 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/.


import logging

from taskgraph.util.taskcluster import get_artifact

from .registry import register_callback_action
from .util import create_tasks, fetch_graph_and_labels

logger = logging.getLogger(__name__)


@register_callback_action(
    name="run-missing-tests",
    title="Run Missing Tests",
    symbol="rmt",
    description=(
        "Run tests in the selected push that were optimized away, usually by SETA."
        "\n"
        "This action is for use on pushes that will be merged into another branch,"
        "to check that optimization hasn't hidden any failures."
    ),
    order=250,
    context=[],  # Applies to decision task
)
def run_missing_tests(parameters, graph_config, input, task_group_id, task_id):
    decision_task_id, full_task_graph, label_to_taskid = fetch_graph_and_labels(
        parameters, graph_config
    )
    target_tasks = get_artifact(decision_task_id, "public/target-tasks.json")

    # The idea here is to schedule all tasks of the `test` kind that were
    # targetted but did not appear in the final task-graph -- those were the
    # optimized tasks.
    to_run = []
    already_run = 0
    for label in target_tasks:
        task = full_task_graph.tasks[label]
        if task.kind != "test":
            continue  # not a test
        if label in label_to_taskid:
            already_run += 1
            continue
        to_run.append(label)

    create_tasks(
        graph_config,
        to_run,
        full_task_graph,
        label_to_taskid,
        parameters,
        decision_task_id,
    )

    logger.info(
        "Out of {} test tasks, {} already existed and the action created {}".format(
            already_run + len(to_run), already_run, len(to_run)
        )
    )