partner_signing.py (2380B)
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.partners import get_partner_config_by_kind 13 from gecko_taskgraph.util.signed_artifacts import ( 14 generate_specifications_of_artifacts_to_sign, 15 ) 16 17 transforms = TransformSequence() 18 19 20 @transforms.add 21 def set_mac_label(config, jobs): 22 for job in jobs: 23 dep_job = get_primary_dependency(config, job) 24 if "mac-notarization" in config.kind: 25 default_label = dep_job.label.replace("mac-signing", "mac-notarization") 26 job.setdefault("label", default_label) 27 assert job["label"] != dep_job.label, ( 28 f"Unable to determine label for {config.kind}" 29 ) 30 yield job 31 32 33 @transforms.add 34 def define_upstream_artifacts(config, jobs): 35 partner_configs = get_partner_config_by_kind(config, config.kind) 36 if not partner_configs: 37 return 38 39 for job in jobs: 40 dep_job = get_primary_dependency(config, job) 41 job.setdefault("attributes", {}).update( 42 copy_attributes_from_dependent_job(dep_job) 43 ) 44 45 repack_ids = job["extra"]["repack_ids"] 46 artifacts_specifications = generate_specifications_of_artifacts_to_sign( 47 config, 48 job, 49 keep_locale_template=True, 50 kind=config.kind, 51 ) 52 task_type = "build" 53 if "notarization" in dep_job.label or "mac-signing" in dep_job.label: 54 task_type = "scriptworker" 55 job["upstream-artifacts"] = [ 56 { 57 "taskId": {"task-reference": f"<{dep_job.kind}>"}, 58 "taskType": task_type, 59 "paths": [ 60 path_template.format(locale=repack_id) 61 for path_template in spec["artifacts"] 62 for repack_id in repack_ids 63 ], 64 "formats": spec["formats"], 65 } 66 for spec in artifacts_specifications 67 ] 68 yield job