tor-browser

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

name_sanity.py (1845B)


      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 Generate labels for tasks without names, consistently.
      6 Uses attributes from primary dependency.
      7 """
      8 
      9 from taskgraph.transforms.base import TransformSequence
     10 from taskgraph.util.dependencies import get_primary_dependency
     11 
     12 transforms = TransformSequence()
     13 
     14 
     15 @transforms.add
     16 def make_label(config, jobs):
     17    """Generate a sane label for a new task constructed from a dependency
     18    Using attributes from the dependent job and the current task kind"""
     19    for job in jobs:
     20        dep_job = get_primary_dependency(config, job)
     21        assert dep_job
     22 
     23        attr = dep_job.attributes.get
     24 
     25        if attr("locale", job.get("locale")):
     26            template = "{kind}-{locale}-{build_platform}/{build_type}"
     27        elif attr("l10n_chunk"):
     28            template = "{kind}-{build_platform}-{l10n_chunk}/{build_type}"
     29        elif config.kind.startswith("release-eme-free") or config.kind.startswith(
     30            "release-partner-repack"
     31        ):
     32            suffix = job.get("extra", {}).get("repack_suffix", None) or job.get(
     33                "extra", {}
     34            ).get("repack_id", None)
     35            template = "{kind}-{build_platform}"
     36            if suffix:
     37                template += "-{}".format(suffix.replace("/", "-"))
     38        else:
     39            template = "{kind}-{build_platform}/{build_type}"
     40        job["label"] = template.format(
     41            kind=config.kind,
     42            build_platform=attr("build_platform"),
     43            build_type=attr("build_type"),
     44            locale=attr("locale", job.get("locale", "")),  # Locale can be absent
     45            l10n_chunk=attr("l10n_chunk", ""),  # Can be empty
     46        )
     47 
     48        yield job