summaryrefslogtreecommitdiffstats
path: root/taskcluster/gecko_taskgraph/transforms/reprocess_symbols.py
blob: 5ad359bd5ab8c186793d740cd04078f1f8071d73 (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
# 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/.
"""
Transform the reprocess-symbols task description template,
taskcluster/ci/reprocess-symbols/job-template.yml into an actual task description.
"""


import logging

from taskgraph.transforms.base import TransformSequence
from taskgraph.util.treeherder import inherit_treeherder_from_dep, join_symbol

from gecko_taskgraph.util.attributes import copy_attributes_from_dependent_job

logger = logging.getLogger(__name__)

transforms = TransformSequence()


@transforms.add
def fill_template(config, tasks):
    for task in tasks:
        assert len(task["dependent-tasks"]) == 2

        build_dep = task["primary-dependency"]
        upload_dep = None
        for dep_idx in task["dependent-tasks"]:
            dep = task["dependent-tasks"][dep_idx]
            if dep_idx != build_dep:
                upload_dep = dep

        task.pop("dependent-tasks", None)

        # Fill out the dynamic fields in the task description
        task["label"] = build_dep.label + "-reprocess-symbols"
        task["dependencies"] = {"build": build_dep.label, "upload": upload_dep.label}
        task["worker"]["env"]["GECKO_HEAD_REPOSITORY"] = config.params[
            "head_repository"
        ]
        task["worker"]["env"]["GECKO_HEAD_REV"] = config.params["head_rev"]
        task["worker"]["env"]["CRASHSTATS_SECRET"] = task["worker"]["env"][
            "CRASHSTATS_SECRET"
        ].format(level=config.params["level"])

        attributes = copy_attributes_from_dependent_job(build_dep)
        attributes.update(task.get("attributes", {}))
        task["attributes"] = attributes

        treeherder = inherit_treeherder_from_dep(task, build_dep)
        th = build_dep.task.get("extra")["treeherder"]
        th_symbol = th.get("symbol")
        th_groupsymbol = th.get("groupSymbol", "?")

        # Disambiguate the treeherder symbol.
        sym = "Rep" + (th_symbol[1:] if th_symbol.startswith("B") else th_symbol)
        treeherder.setdefault("symbol", join_symbol(th_groupsymbol, sym))
        task["treeherder"] = treeherder

        task["run-on-projects"] = build_dep.attributes.get("run_on_projects")
        task["optimization"] = {"reprocess-symbols": None}
        task["if-dependencies"] = ["build"]

        del task["primary-dependency"]

        yield task