tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

reprocess_symbols.py (2547B)


      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 Transform the reprocess-symbols task description template,
      6 taskcluster/kinds/reprocess-symbols/job-template.yml into an actual task description.
      7 """
      8 
      9 import logging
     10 
     11 from taskgraph.transforms.base import TransformSequence
     12 from taskgraph.util.dependencies import get_dependencies, get_primary_dependency
     13 from taskgraph.util.treeherder import inherit_treeherder_from_dep, join_symbol
     14 
     15 from gecko_taskgraph.util.attributes import (
     16    copy_attributes_from_dependent_job,
     17    sorted_unique_list,
     18 )
     19 
     20 logger = logging.getLogger(__name__)
     21 
     22 transforms = TransformSequence()
     23 
     24 
     25 @transforms.add
     26 def gather_required_signoffs(config, jobs):
     27    for job in jobs:
     28        job.setdefault("attributes", {})["required_signoffs"] = sorted_unique_list(
     29            *(
     30                dep.attributes.get("required_signoffs", [])
     31                for dep in get_dependencies(config, job)
     32            )
     33        )
     34        yield job
     35 
     36 
     37 @transforms.add
     38 def fill_template(config, tasks):
     39    for task in tasks:
     40        dep = get_primary_dependency(config, task)
     41        assert dep
     42 
     43        # Fill out the dynamic fields in the task description
     44        task["label"] = dep.label + "-reprocess-symbols"
     45        task["worker"]["env"]["GECKO_HEAD_REPOSITORY"] = config.params[
     46            "head_repository"
     47        ]
     48        task["worker"]["env"]["GECKO_HEAD_REV"] = config.params["head_rev"]
     49        task["worker"]["env"]["CRASHSTATS_SECRET"] = task["worker"]["env"][
     50            "CRASHSTATS_SECRET"
     51        ].format(level=config.params["level"])
     52 
     53        attributes = copy_attributes_from_dependent_job(dep)
     54        attributes.update(task.get("attributes", {}))
     55        task["attributes"] = attributes
     56 
     57        treeherder = inherit_treeherder_from_dep(task, dep)
     58        th = dep.task["extra"]["treeherder"]
     59        th_symbol = th.get("symbol")
     60        th_groupsymbol = th.get("groupSymbol", "?")
     61 
     62        # Disambiguate the treeherder symbol.
     63        sym = "Rep" + (th_symbol[1:] if th_symbol.startswith("B") else th_symbol)
     64        treeherder.setdefault("symbol", join_symbol(th_groupsymbol, sym))
     65        task["treeherder"] = treeherder
     66 
     67        task["run-on-projects"] = dep.attributes.get("run_on_projects")
     68        task["optimization"] = {"reprocess-symbols": None}
     69        task["if-dependencies"] = [task["attributes"]["primary-kind-dependency"]]
     70 
     71        yield task