tor-browser

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

geckodriver_mac_notarization.py (3020B)


      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 geckodriver notarization 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.schema import Schema
     11 from voluptuous import Optional
     12 
     13 from gecko_taskgraph.transforms.task import task_description_schema
     14 from gecko_taskgraph.util.attributes import copy_attributes_from_dependent_job
     15 
     16 geckodriver_notarization_description_schema = Schema({
     17    Optional("label"): str,
     18    Optional("treeherder"): task_description_schema["treeherder"],
     19    Optional("shipping-phase"): task_description_schema["shipping-phase"],
     20    Optional("worker"): task_description_schema["worker"],
     21    Optional("worker-type"): task_description_schema["worker-type"],
     22    Optional("task-from"): task_description_schema["task-from"],
     23    Optional("attributes"): task_description_schema["attributes"],
     24    Optional("dependencies"): task_description_schema["dependencies"],
     25    Optional("run-on-repo-type"): task_description_schema["run-on-repo-type"],
     26 })
     27 
     28 transforms = TransformSequence()
     29 
     30 
     31 @transforms.add
     32 def remove_name(config, jobs):
     33    for job in jobs:
     34        if "name" in job:
     35            del job["name"]
     36        yield job
     37 
     38 
     39 transforms.add_validate(geckodriver_notarization_description_schema)
     40 
     41 
     42 @transforms.add
     43 def geckodriver_mac_notarization(config, jobs):
     44    for job in jobs:
     45        dep_job = get_primary_dependency(config, job)
     46        assert dep_job
     47 
     48        attributes = copy_attributes_from_dependent_job(dep_job)
     49        treeherder = job.get("treeherder", {})
     50        dep_treeherder = dep_job.task.get("extra", {}).get("treeherder", {})
     51        treeherder.setdefault(
     52            "platform", dep_job.task.get("extra", {}).get("treeherder-platform")
     53        )
     54        treeherder.setdefault("tier", dep_treeherder.get("tier", 1))
     55        treeherder.setdefault("kind", "build")
     56 
     57        dependencies = {dep_job.kind: dep_job.label}
     58 
     59        description = "Mac notarization - Geckodriver for build '{}'".format(
     60            attributes.get("build_platform"),
     61        )
     62 
     63        build_platform = dep_job.attributes.get("build_platform")
     64 
     65        job["worker"]["signing-type"] = "release-apple-notarization"
     66 
     67        platform = build_platform.rsplit("-", 1)[0]
     68 
     69        task = {
     70            "label": job["label"],
     71            "description": description,
     72            "worker-type": job["worker-type"],
     73            "worker": job["worker"],
     74            "dependencies": dependencies,
     75            "attributes": attributes,
     76            "treeherder": treeherder,
     77            "run-on-projects": ["mozilla-central"],
     78            "run-on-repo-type": job.get("run-on-repo-type", ["git", "hg"]),
     79            "index": {"product": "geckodriver", "job-name": f"{platform}-notarized"},
     80        }
     81        yield task