beetmover_emefree_checksums.py (5189B)
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 release-beetmover-source-checksums 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 voluptuous import Optional 12 13 from gecko_taskgraph.transforms.beetmover import craft_release_properties 14 from gecko_taskgraph.transforms.task import task_description_schema 15 from gecko_taskgraph.util.attributes import copy_attributes_from_dependent_job 16 17 beetmover_checksums_description_schema = Schema({ 18 Optional("label"): str, 19 Optional("extra"): object, 20 Optional("shipping-phase"): task_description_schema["shipping-phase"], 21 Optional("shipping-product"): task_description_schema["shipping-product"], 22 Optional("task-from"): task_description_schema["task-from"], 23 Optional("attributes"): task_description_schema["attributes"], 24 Optional("dependencies"): task_description_schema["dependencies"], 25 Optional("run-on-repo-type"): task_description_schema["run-on-repo-type"], 26 }) 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(beetmover_checksums_description_schema) 41 42 43 @transforms.add 44 def make_beetmover_checksums_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 = attributes.get("build_platform") 51 if not build_platform: 52 raise Exception("Cannot find build platform!") 53 repack_id = dep_job.task.get("extra", {}).get("repack_id") 54 if not repack_id: 55 raise Exception("Cannot find repack id!") 56 57 label = dep_job.label.replace("beetmover-", "beetmover-checksums-") 58 description = ( 59 "Beetmove checksums for repack_id '{repack_id}' for build '" 60 "{build_platform}/{build_type}'".format( 61 repack_id=repack_id, 62 build_platform=build_platform, 63 build_type=attributes.get("build_type"), 64 ) 65 ) 66 67 extra = {} 68 extra["partner_path"] = dep_job.task["payload"]["upstreamArtifacts"][0][ 69 "locale" 70 ] 71 extra["repack_id"] = repack_id 72 73 dependencies = {dep_job.kind: dep_job.label} 74 for k, v in dep_job.dependencies.items(): 75 if k.startswith("beetmover"): 76 dependencies[k] = v 77 78 attributes = copy_attributes_from_dependent_job(dep_job) 79 80 task = { 81 "label": label, 82 "description": description, 83 "worker-type": "{}/{}".format( 84 dep_job.task["provisionerId"], 85 dep_job.task["workerType"], 86 ), 87 "scopes": dep_job.task["scopes"], 88 "dependencies": dependencies, 89 "attributes": attributes, 90 "run-on-projects": dep_job.attributes.get("run_on_projects"), 91 "extra": extra, 92 } 93 94 if "shipping-phase" in job: 95 task["shipping-phase"] = job["shipping-phase"] 96 97 if "shipping-product" in job: 98 task["shipping-product"] = job["shipping-product"] 99 100 yield task 101 102 103 def generate_upstream_artifacts(refs, partner_path): 104 # Until bug 1331141 is fixed, if you are adding any new artifacts here that 105 # need to be transfered to S3, please be aware you also need to follow-up 106 # with a beetmover patch in https://github.com/mozilla-releng/beetmoverscript/. 107 # See example in bug 1348286 108 common_paths = [ 109 "public/target.checksums", 110 ] 111 112 upstream_artifacts = [ 113 { 114 "taskId": {"task-reference": refs["beetmover"]}, 115 "taskType": "signing", 116 "paths": common_paths, 117 "locale": f"beetmover-checksums/{partner_path}", 118 } 119 ] 120 121 return upstream_artifacts 122 123 124 @transforms.add 125 def make_beetmover_checksums_worker(config, jobs): 126 for job in jobs: 127 valid_beetmover_job = len(job["dependencies"]) == 1 128 if not valid_beetmover_job: 129 raise NotImplementedError("Beetmover checksums must have one dependency.") 130 131 refs = { 132 "beetmover": None, 133 } 134 for dependency in job["dependencies"].keys(): 135 if dependency.endswith("beetmover"): 136 refs["beetmover"] = f"<{dependency}>" 137 if None in refs.values(): 138 raise NotImplementedError( 139 "Beetmover checksums must have a beetmover dependency!" 140 ) 141 142 worker = { 143 "implementation": "beetmover", 144 "os": "linux", 145 "release-properties": craft_release_properties(config, job), 146 "upstream-artifacts": generate_upstream_artifacts( 147 refs, 148 job["extra"]["partner_path"], 149 ), 150 } 151 152 job["worker"] = worker 153 154 yield job