build_signing.py (2372B)
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 11 from gecko_taskgraph.util.attributes import copy_attributes_from_dependent_job 12 from gecko_taskgraph.util.signed_artifacts import ( 13 generate_specifications_of_artifacts_to_sign, 14 ) 15 16 transforms = TransformSequence() 17 18 19 @transforms.add 20 def add_signed_routes(config, jobs): 21 """Add routes corresponding to the routes of the build task 22 this corresponds to, with .signed inserted, for all gecko.v2 routes""" 23 24 for job in jobs: 25 dep_job = get_primary_dependency(config, job) 26 enable_signing_routes = job.pop("enable-signing-routes", True) 27 28 job["routes"] = [] 29 if dep_job.attributes.get("shippable") and enable_signing_routes: 30 for dep_route in dep_job.task.get("routes", []): 31 if not dep_route.startswith("index.gecko.v2"): 32 continue 33 branch = dep_route.split(".")[3] 34 rest = ".".join(dep_route.split(".")[4:]) 35 job["routes"].append(f"index.gecko.v2.{branch}.signed.{rest}") 36 37 yield job 38 39 40 @transforms.add 41 def define_upstream_artifacts(config, jobs): 42 for job in jobs: 43 dep_job = get_primary_dependency(config, job) 44 45 job.setdefault("attributes", {}).update( 46 copy_attributes_from_dependent_job(dep_job) 47 ) 48 49 artifacts_specifications = generate_specifications_of_artifacts_to_sign( 50 config, 51 job, 52 keep_locale_template=False, 53 kind=config.kind, 54 dep_kind=dep_job.kind, 55 ) 56 57 task_ref = f"<{dep_job.kind}>" 58 task_type = "build" 59 if "notarization" in dep_job.kind: 60 task_type = "scriptworker" 61 62 job["upstream-artifacts"] = [ 63 { 64 "taskId": {"task-reference": task_ref}, 65 "taskType": task_type, 66 "paths": spec["artifacts"], 67 "formats": spec["formats"], 68 } 69 for spec in artifacts_specifications 70 ] 71 72 yield job