|
| 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 | +from typing import Optional |
| 6 | + |
| 7 | +from taskgraph.transforms.base import TransformSequence |
| 8 | +from taskgraph.util.dependencies import get_primary_dependency |
| 9 | +from taskgraph.util.schema import Schema |
| 10 | +from taskgraph.util.treeherder import inherit_treeherder_from_dep |
| 11 | + |
| 12 | +from gecko_taskgraph.transforms.task import TaskDescriptionSchema |
| 13 | +from gecko_taskgraph.util.attributes import copy_attributes_from_dependent_job |
| 14 | +from gecko_taskgraph.util.scriptworker import get_signing_type_per_platform |
| 15 | + |
| 16 | + |
| 17 | +class RepackagePkgSigningSchema(Schema, kw_only=True): |
| 18 | + label: Optional[str] = None |
| 19 | + description: Optional[str] = None |
| 20 | + attributes: TaskDescriptionSchema.__annotations__["attributes"] = None |
| 21 | + dependencies: TaskDescriptionSchema.__annotations__["dependencies"] = None |
| 22 | + task_from: TaskDescriptionSchema.__annotations__["task_from"] = None |
| 23 | + treeherder: TaskDescriptionSchema.__annotations__["treeherder"] = None |
| 24 | + shipping_product: TaskDescriptionSchema.__annotations__["shipping_product"] = None |
| 25 | + shipping_phase: TaskDescriptionSchema.__annotations__["shipping_phase"] = None |
| 26 | + run_on_repo_type: TaskDescriptionSchema.__annotations__["run_on_repo_type"] = None |
| 27 | + |
| 28 | + |
| 29 | +transforms = TransformSequence() |
| 30 | + |
| 31 | + |
| 32 | +@transforms.add |
| 33 | +def remove_name(config, jobs): |
| 34 | + for job in jobs: |
| 35 | + if "name" in job: |
| 36 | + del job["name"] |
| 37 | + yield job |
| 38 | + |
| 39 | + |
| 40 | +transforms.add_validate(RepackagePkgSigningSchema) |
| 41 | + |
| 42 | + |
| 43 | +@transforms.add |
| 44 | +def make_task_description(config, tasks): |
| 45 | + for task in tasks: |
| 46 | + dep = get_primary_dependency(config, task) |
| 47 | + assert dep |
| 48 | + |
| 49 | + # Collect all dependencies from this group. For en-US builds there is |
| 50 | + # a single dependency; for l10n builds each locale in the chunk is a |
| 51 | + # separate upstream repackage-l10n task. |
| 52 | + all_deps = [ |
| 53 | + config.kind_dependencies_tasks[label] |
| 54 | + for label in task.get("dependencies", {}).values() |
| 55 | + if label in config.kind_dependencies_tasks |
| 56 | + ] |
| 57 | + if not all_deps: |
| 58 | + all_deps = [dep] |
| 59 | + |
| 60 | + upstream_artifacts = [] |
| 61 | + dependencies = {} |
| 62 | + for d in all_deps: |
| 63 | + dep_key = d.label if len(all_deps) > 1 else d.kind |
| 64 | + dependencies[dep_key] = d.label |
| 65 | + dependencies.update(d.dependencies) |
| 66 | + for artifact in d.attributes.get("release_artifacts", []): |
| 67 | + if artifact.endswith(".pkg"): |
| 68 | + upstream_artifacts.append({ |
| 69 | + "taskId": {"task-reference": f"<{dep_key}>"}, |
| 70 | + "taskType": "repackage", |
| 71 | + "paths": [artifact], |
| 72 | + "formats": ["mac_single_file"], |
| 73 | + }) |
| 74 | + |
| 75 | + is_shippable = bool(dep.attributes.get("shippable")) |
| 76 | + |
| 77 | + th = inherit_treeherder_from_dep(task, dep) |
| 78 | + l10n_chunk = dep.attributes.get("l10n_chunk", "") |
| 79 | + th["symbol"] = f"pkg-Rpk(S{l10n_chunk})" |
| 80 | + |
| 81 | + # For chunked l10n tasks, override the label to use the chunk number |
| 82 | + # instead of the locale name that name_sanity generates. |
| 83 | + label = task["label"] |
| 84 | + if l10n_chunk: |
| 85 | + label = ( |
| 86 | + f"{config.kind}-{dep.attributes['build_platform']}" |
| 87 | + f"-{l10n_chunk}/{dep.attributes['build_type']}" |
| 88 | + ) |
| 89 | + |
| 90 | + attributes = copy_attributes_from_dependent_job(dep) |
| 91 | + if len(all_deps) > 1: |
| 92 | + attributes["chunk_locales"] = sorted( |
| 93 | + d.attributes["locale"] for d in all_deps if d.attributes.get("locale") |
| 94 | + ) |
| 95 | + |
| 96 | + yield { |
| 97 | + "label": label, |
| 98 | + "description": f"MacOS pkg signing {l10n_chunk}".strip(), |
| 99 | + "worker-type": "mac-signing" if is_shippable else "mac-depsigning", |
| 100 | + "worker": { |
| 101 | + "signing-type": get_signing_type_per_platform( |
| 102 | + dep.attributes.get("build_platform"), is_shippable, config |
| 103 | + ), |
| 104 | + "implementation": "iscript", |
| 105 | + "upstream-artifacts": upstream_artifacts, |
| 106 | + "mac-behavior": "mac_sign_pkg", |
| 107 | + }, |
| 108 | + "dependencies": dependencies, |
| 109 | + "attributes": attributes, |
| 110 | + "run-on-projects": dep.attributes.get("run_on_projects"), |
| 111 | + "treeherder": th, |
| 112 | + } |
0 commit comments