tor-browser

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

release_msix_push.py (3180B)


      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 release-msix-push kind into an actual task description.
      6 """
      7 
      8 from taskgraph.transforms.base import TransformSequence
      9 from taskgraph.util.schema import Schema, optionally_keyed_by, resolve_keyed_by
     10 from voluptuous import Optional, Required
     11 
     12 from gecko_taskgraph.transforms.task import task_description_schema
     13 from gecko_taskgraph.util.attributes import release_level
     14 from gecko_taskgraph.util.scriptworker import add_scope_prefix
     15 
     16 push_msix_description_schema = Schema({
     17    Required("name"): str,
     18    Required("task-from"): task_description_schema["task-from"],
     19    Required("dependencies"): task_description_schema["dependencies"],
     20    Required("description"): task_description_schema["description"],
     21    Required("treeherder"): task_description_schema["treeherder"],
     22    Required("run-on-projects"): task_description_schema["run-on-projects"],
     23    Required("worker-type"): optionally_keyed_by("release-level", str),
     24    Required("worker"): object,
     25    Optional("scopes"): [str],
     26    Required("shipping-phase"): task_description_schema["shipping-phase"],
     27    Required("shipping-product"): task_description_schema["shipping-product"],
     28    Optional("extra"): task_description_schema["extra"],
     29    Optional("attributes"): task_description_schema["attributes"],
     30    Optional("run-on-repo-type"): task_description_schema["run-on-repo-type"],
     31 })
     32 
     33 transforms = TransformSequence()
     34 transforms.add_validate(push_msix_description_schema)
     35 
     36 
     37 @transforms.add
     38 def make_task_description(config, jobs):
     39    for job in jobs:
     40        job["worker"]["upstream-artifacts"] = generate_upstream_artifacts(
     41            job["dependencies"]
     42        )
     43 
     44        resolve_keyed_by(
     45            job,
     46            "worker.channel",
     47            item_name=job["name"],
     48            **{"release-type": config.params["release_type"]},
     49        )
     50        resolve_keyed_by(
     51            job,
     52            "worker.publish-mode",
     53            item_name=job["name"],
     54            **{"release-type": config.params["release_type"]},
     55        )
     56        resolve_keyed_by(
     57            job,
     58            "worker-type",
     59            item_name=job["name"],
     60            **{"release-level": release_level(config.params)},
     61        )
     62        if release_level(config.params) == "production":
     63            job.setdefault("scopes", []).append(
     64                add_scope_prefix(
     65                    config,
     66                    "microsoftstore:{}".format(job["worker"]["channel"]),
     67                )
     68            )
     69 
     70        # Override shipping-phase for release: push to the Store early to
     71        # allow time for certification.
     72        if job["worker"]["publish-mode"] == "Manual":
     73            job["shipping-phase"] = "promote"
     74 
     75        yield job
     76 
     77 
     78 def generate_upstream_artifacts(dependencies):
     79    return [
     80        {
     81            "taskId": {"task-reference": f"<{task_kind}>"},
     82            "taskType": "build",
     83            "paths": ["public/build/target.store.msix"],
     84        }
     85        for task_kind in dependencies.keys()
     86    ]