tor-browser

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

shippable_l10n_signing.py (2906B)


      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 signing task into an actual task description.
      6 """
      7 
      8 from taskgraph.transforms.base import TransformSequence
      9 from taskgraph.util.dependencies import get_primary_dependency
     10 from taskgraph.util.treeherder import join_symbol
     11 
     12 from gecko_taskgraph.util.attributes import copy_attributes_from_dependent_job
     13 from gecko_taskgraph.util.signed_artifacts import (
     14    generate_specifications_of_artifacts_to_sign,
     15 )
     16 
     17 transforms = TransformSequence()
     18 
     19 
     20 @transforms.add
     21 def make_signing_description(config, jobs):
     22    for job in jobs:
     23        dep_job = get_primary_dependency(config, job)
     24 
     25        # add the chunk number to the TH symbol
     26        symbol = job.get("treeherder", {}).get("symbol", "Bs")
     27        symbol = "{}{}".format(symbol, dep_job.attributes.get("l10n_chunk"))
     28        group = "L10n"
     29 
     30        job["treeherder"] = {
     31            "symbol": join_symbol(group, symbol),
     32        }
     33 
     34        yield job
     35 
     36 
     37 @transforms.add
     38 def define_upstream_artifacts(config, jobs):
     39    for job in jobs:
     40        dep_job = get_primary_dependency(config, job)
     41 
     42        job.setdefault("attributes", {}).update(
     43            copy_attributes_from_dependent_job(dep_job)
     44        )
     45        if dep_job.attributes.get("chunk_locales"):
     46            # Used for l10n attribute passthrough
     47            job["attributes"]["chunk_locales"] = dep_job.attributes.get("chunk_locales")
     48 
     49        locale_specifications = generate_specifications_of_artifacts_to_sign(
     50            config,
     51            job,
     52            keep_locale_template=True,
     53            dep_kind=dep_job.kind,
     54        )
     55 
     56        upstream_artifacts = []
     57        for spec in locale_specifications:
     58            upstream_task_type = "l10n"
     59            if dep_job.kind.endswith(("-mac-notarization", "-mac-signing")):
     60                # Upstream is mac signing or notarization
     61                upstream_task_type = "scriptworker"
     62            upstream_artifacts.append({
     63                "taskId": {"task-reference": f"<{dep_job.kind}>"},
     64                "taskType": upstream_task_type,
     65                # Set paths based on artifacts in the specs (above) one per
     66                # locale present in the chunk this is signing stuff for.
     67                # Pass paths through set and sorted() so we get a list back
     68                # and we remove any duplicates (e.g. hardcoded ja-JP-mac langpack)
     69                "paths": sorted({
     70                    path_template.format(locale=locale)
     71                    for locale in dep_job.attributes.get("chunk_locales", [])
     72                    for path_template in spec["artifacts"]
     73                }),
     74                "formats": spec["formats"],
     75            })
     76 
     77        job["upstream-artifacts"] = upstream_artifacts
     78 
     79        yield job