summaryrefslogtreecommitdiffstats
path: root/taskcluster/gecko_taskgraph/actions/raptor_extra_options.py
blob: 43b26d284d71e591f154aaba876b5f543ef02ccb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# 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_task_definition

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

logger = logging.getLogger(__name__)


@register_callback_action(
    title="Raptor Extra Options",
    name="raptor-extra-options",
    symbol="rxo",
    description=(
        "Allows the user to rerun raptor-browsertime tasks with additional arguments."
    ),
    order=200,
    context=[{"test-type": "raptor"}],
    schema={
        "type": "object",
        "properties": {
            "extra_options": {
                "type": "string",
                "default": "",
                "description": "A space-delimited string of extra options "
                "to be passed into a raptor-browsertime test."
                "This also works with options with values, where the values "
                "should be set as an assignment e.g. browser-cycles=3 "
                "Passing multiple extra options could look something this:  "
                "`verbose browser-cycles=3` where the test runs with verbose "
                "mode on and the browser cycles only 3 times.",
            }
        },
    },
    available=lambda parameters: True,
)
def raptor_extra_options_action(
    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
    )
    task = get_task_definition(task_id)
    label = task["metadata"]["name"]

    def modifier(task):
        if task.label != label:
            return task

        if task.task["payload"]["env"].get("PERF_FLAGS"):
            task.task["payload"]["env"]["PERF_FLAGS"] += " " + input.get(
                "extra_options"
            )
        else:
            task.task["payload"]["env"].setdefault(
                "PERF_FLAGS", input.get("extra_options")
            )

        task.task["extra"]["treeherder"]["symbol"] += "-rxo"
        task.task["extra"]["treeherder"]["groupName"] += " (extra options run)"
        return task

    create_tasks(
        graph_config,
        [label],
        full_task_graph,
        label_to_taskid,
        parameters,
        decision_task_id,
        modifier=modifier,
    )