openh264_signing.py (4284B)
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.treeherder import inherit_treeherder_from_dep 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.scriptworker import get_signing_type_per_platform 17 18 transforms = TransformSequence() 19 20 signing_description_schema = Schema({ 21 Optional("label"): str, 22 Optional("extra"): object, 23 Optional("shipping-product"): task_description_schema["shipping-product"], 24 Optional("shipping-phase"): task_description_schema["shipping-phase"], 25 Optional("attributes"): task_description_schema["attributes"], 26 Optional("dependencies"): task_description_schema["dependencies"], 27 Optional("task-from"): task_description_schema["task-from"], 28 Optional("run-on-repo-type"): task_description_schema["run-on-repo-type"], 29 }) 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(signing_description_schema) 41 42 43 @transforms.add 44 def make_signing_description(config, jobs): 45 for job in jobs: 46 dep_job = get_primary_dependency(config, job) 47 assert dep_job 48 49 attributes = dep_job.attributes 50 build_platform = dep_job.attributes.get("build_platform") 51 is_nightly = True # cert_scope_per_platform uses this to choose the right cert 52 53 description = ( 54 "Signing of OpenH264 Binaries for '{build_platform}/{build_type}'".format( 55 build_platform=attributes.get("build_platform"), 56 build_type=attributes.get("build_type"), 57 ) 58 ) 59 60 # we have a genuine repackage job as our parent 61 dependencies = {"openh264": dep_job.label} 62 63 my_attributes = copy_attributes_from_dependent_job(dep_job) 64 65 signing_type = get_signing_type_per_platform(build_platform, is_nightly, config) 66 67 worker_type = "linux-signing" 68 worker = { 69 "implementation": "scriptworker-signing", 70 "signing-type": signing_type, 71 } 72 rev = attributes["openh264_rev"] 73 upstream_artifact = { 74 "taskId": {"task-reference": "<openh264>"}, 75 "taskType": "build", 76 } 77 78 if "win" in build_platform: 79 upstream_artifact["formats"] = ["gcp_prod_autograph_authenticode_202412"] 80 elif "mac" in build_platform: 81 upstream_artifact["formats"] = ["mac_single_file"] 82 upstream_artifact["singleFileGlobs"] = ["libgmpopenh264.dylib"] 83 worker_type = "mac-signing" 84 worker["implementation"] = "iscript" 85 worker["mac-behavior"] = "mac_notarize_single_file" 86 else: 87 upstream_artifact["formats"] = ["gcp_prod_autograph_gpg"] 88 89 upstream_artifact["paths"] = [ 90 f"private/openh264/openh264-{build_platform}-{rev}.zip", 91 ] 92 worker["upstream-artifacts"] = [upstream_artifact] 93 94 treeherder = inherit_treeherder_from_dep(job, dep_job) 95 treeherder.setdefault( 96 "symbol", 97 _generate_treeherder_symbol( 98 dep_job.task.get("extra", {}).get("treeherder", {}).get("symbol") 99 ), 100 ) 101 102 task = { 103 "label": job["label"], 104 "description": description, 105 "worker-type": worker_type, 106 "worker": worker, 107 "dependencies": dependencies, 108 "attributes": my_attributes, 109 "run-on-projects": dep_job.attributes.get("run_on_projects"), 110 "run-on-repo-type": job.get("run-on-repo-type", ["git", "hg"]), 111 "treeherder": treeherder, 112 } 113 114 yield task 115 116 117 def _generate_treeherder_symbol(build_symbol): 118 symbol = build_symbol + "s" 119 return symbol