tor-browser

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

repackage_signing_partner.py (6467B)


      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 repackage 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.schema import Schema
     11 from taskgraph.util.taskcluster import get_artifact_path
     12 from voluptuous import Optional
     13 
     14 from gecko_taskgraph.transforms.task import task_description_schema
     15 from gecko_taskgraph.util.attributes import copy_attributes_from_dependent_job
     16 from gecko_taskgraph.util.partners import get_partner_config_by_kind
     17 from gecko_taskgraph.util.scriptworker import get_signing_type_per_platform
     18 
     19 transforms = TransformSequence()
     20 
     21 repackage_signing_description_schema = Schema({
     22    Optional("label"): str,
     23    Optional("extra"): object,
     24    Optional("attributes"): task_description_schema["attributes"],
     25    Optional("dependencies"): task_description_schema["dependencies"],
     26    Optional("shipping-product"): task_description_schema["shipping-product"],
     27    Optional("shipping-phase"): task_description_schema["shipping-phase"],
     28    Optional("priority"): task_description_schema["priority"],
     29    Optional("task-from"): task_description_schema["task-from"],
     30    Optional("run-on-repo-type"): task_description_schema["run-on-repo-type"],
     31 })
     32 
     33 
     34 @transforms.add
     35 def remove_name(config, jobs):
     36    for job in jobs:
     37        if "name" in job:
     38            del job["name"]
     39        yield job
     40 
     41 
     42 transforms.add_validate(repackage_signing_description_schema)
     43 
     44 
     45 @transforms.add
     46 def make_repackage_signing_description(config, jobs):
     47    for job in jobs:
     48        dep_job = get_primary_dependency(config, job)
     49        assert dep_job
     50 
     51        repack_id = dep_job.task["extra"]["repack_id"]
     52        attributes = dep_job.attributes
     53        build_platform = dep_job.attributes.get("build_platform")
     54        is_shippable = dep_job.attributes.get("shippable")
     55 
     56        # Mac & windows
     57        label = dep_job.label.replace("repackage-", "repackage-signing-")
     58        # Linux
     59        label = label.replace("chunking-dummy-", "repackage-signing-")
     60        description = (
     61            "Signing of repackaged artifacts for partner repack id '{repack_id}' for build '"
     62            "{build_platform}/{build_type}'".format(  # NOQA: E501
     63                repack_id=repack_id,
     64                build_platform=attributes.get("build_platform"),
     65                build_type=attributes.get("build_type"),
     66            )
     67        )
     68 
     69        if "linux" in build_platform:
     70            # we want the repack job, via the dependencies for the the chunking-dummy dep_job
     71            for dep in dep_job.dependencies.values():
     72                if dep.startswith("release-partner-repack"):
     73                    dependencies = {"repack": dep}
     74                    break
     75        else:
     76            # we have a genuine repackage job as our parent
     77            dependencies = {"repackage": dep_job.label}
     78 
     79        attributes = copy_attributes_from_dependent_job(dep_job)
     80        attributes["repackage_type"] = "repackage-signing"
     81 
     82        signing_type = get_signing_type_per_platform(
     83            build_platform, is_shippable, config
     84        )
     85 
     86        if "win" in build_platform:
     87            upstream_artifacts = [
     88                {
     89                    "taskId": {"task-reference": "<repackage>"},
     90                    "taskType": "repackage",
     91                    "paths": [
     92                        get_artifact_path(dep_job, f"{repack_id}/target.installer.exe"),
     93                    ],
     94                    "formats": [
     95                        "gcp_prod_autograph_authenticode_202412",
     96                        "gcp_prod_autograph_gpg",
     97                    ],
     98                }
     99            ]
    100 
    101            partner_config = get_partner_config_by_kind(config, config.kind)
    102            partner, subpartner, _ = repack_id.split("/")
    103            repack_stub_installer = partner_config[partner][subpartner].get(
    104                "repack_stub_installer"
    105            )
    106            if build_platform.startswith("win32") and repack_stub_installer:
    107                upstream_artifacts.append({
    108                    "taskId": {"task-reference": "<repackage>"},
    109                    "taskType": "repackage",
    110                    "paths": [
    111                        get_artifact_path(
    112                            dep_job,
    113                            f"{repack_id}/target.stub-installer.exe",
    114                        ),
    115                    ],
    116                    "formats": [
    117                        "gcp_prod_autograph_authenticode_202412",
    118                        "gcp_prod_autograph_gpg",
    119                    ],
    120                })
    121        elif "mac" in build_platform:
    122            upstream_artifacts = [
    123                {
    124                    "taskId": {"task-reference": "<repackage>"},
    125                    "taskType": "repackage",
    126                    "paths": [
    127                        get_artifact_path(dep_job, f"{repack_id}/target.dmg"),
    128                    ],
    129                    "formats": ["gcp_prod_autograph_gpg"],
    130                }
    131            ]
    132        elif "linux" in build_platform:
    133            upstream_artifacts = [
    134                {
    135                    "taskId": {"task-reference": "<repack>"},
    136                    "taskType": "repackage",
    137                    "paths": [
    138                        get_artifact_path(dep_job, f"{repack_id}/target.tar.xz"),
    139                    ],
    140                    "formats": ["gcp_prod_autograph_gpg"],
    141                }
    142            ]
    143 
    144        task = {
    145            "label": label,
    146            "description": description,
    147            "worker-type": "linux-signing",
    148            "worker": {
    149                "implementation": "scriptworker-signing",
    150                "signing-type": signing_type,
    151                "upstream-artifacts": upstream_artifacts,
    152            },
    153            "dependencies": dependencies,
    154            "attributes": attributes,
    155            "run-on-projects": dep_job.attributes.get("run_on_projects"),
    156            "run-on-repo-type": job.get("run-on-repo-type", ["git", "hg"]),
    157            "extra": {
    158                "repack_id": repack_id,
    159            },
    160        }
    161        # we may have reduced the priority for partner jobs, otherwise task.py will set it
    162        if job.get("priority"):
    163            task["priority"] = job["priority"]
    164 
    165        yield task