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/.
5 Transform the beetmover task into an actual task description.
10 from taskgraph
.transforms
.base
import TransformSequence
11 from taskgraph
.util
.dependencies
import get_primary_dependency
12 from taskgraph
.util
.schema
import Schema
13 from taskgraph
.util
.taskcluster
import get_artifact_prefix
14 from voluptuous
import Optional
, Required
16 from gecko_taskgraph
.transforms
.beetmover
import craft_release_properties
17 from gecko_taskgraph
.transforms
.task
import task_description_schema
18 from gecko_taskgraph
.util
.attributes
import (
19 copy_attributes_from_dependent_job
,
21 from gecko_taskgraph
.util
.partners
import get_ftp_platform
, get_partner_config_by_kind
22 from gecko_taskgraph
.util
.scriptworker
import (
24 get_beetmover_bucket_scope
,
27 logger
= logging
.getLogger(__name__
)
30 beetmover_description_schema
= Schema(
32 # unique label to describe this beetmover task, defaults to {dep.label}-beetmover
33 Optional("label"): str,
34 Required("partner-path"): str,
35 Optional("extra"): object,
36 Optional("attributes"): task_description_schema
["attributes"],
37 Optional("dependencies"): task_description_schema
["dependencies"],
38 Required("shipping-phase"): task_description_schema
["shipping-phase"],
39 Optional("shipping-product"): task_description_schema
["shipping-product"],
40 Optional("priority"): task_description_schema
["priority"],
41 Optional("job-from"): task_description_schema
["job-from"],
45 transforms
= TransformSequence()
49 def remove_name(config
, jobs
):
56 transforms
.add_validate(beetmover_description_schema
)
60 def make_task_description(config
, jobs
):
62 dep_job
= get_primary_dependency(config
, job
)
65 repack_id
= dep_job
.task
.get("extra", {}).get("repack_id")
67 raise Exception("Cannot find repack id!")
69 attributes
= dep_job
.attributes
70 build_platform
= attributes
.get("build_platform")
71 if not build_platform
:
72 raise Exception("Cannot find build platform!")
74 label
= dep_job
.label
.replace("repackage-signing-l10n", "beetmover-")
75 label
= dep_job
.label
.replace("repackage-signing-", "beetmover-")
76 label
= label
.replace("repackage-", "beetmover-")
77 label
= label
.replace("chunking-dummy-", "beetmover-")
79 "Beetmover submission for repack_id '{repack_id}' for build '"
80 "{build_platform}/{build_type}'".format(
82 build_platform
=build_platform
,
83 build_type
=attributes
.get("build_type"),
89 base_label
= "release-partner-repack"
90 if "eme" in config
.kind
:
91 base_label
= "release-eme-free-repack"
92 dependencies
["build"] = f
"{base_label}-{build_platform}"
93 if "macosx" in build_platform
or "win" in build_platform
:
94 dependencies
["repackage"] = "{}-repackage-{}-{}".format(
95 base_label
, build_platform
, repack_id
.replace("/", "-")
97 dependencies
["repackage-signing"] = "{}-repackage-signing-{}-{}".format(
98 base_label
, build_platform
, repack_id
.replace("/", "-")
101 attributes
= copy_attributes_from_dependent_job(dep_job
)
105 "description": description
,
106 "dependencies": dependencies
,
107 "attributes": attributes
,
108 "run-on-projects": dep_job
.attributes
.get("run_on_projects"),
109 "shipping-phase": job
["shipping-phase"],
110 "shipping-product": job
.get("shipping-product"),
111 "partner-path": job
["partner-path"],
113 "repack_id": repack_id
,
116 # we may have reduced the priority for partner jobs, otherwise task.py will set it
117 if job
.get("priority"):
118 task
["priority"] = job
["priority"]
124 def populate_scopes_and_worker_type(config
, jobs
):
125 bucket_scope
= get_beetmover_bucket_scope(config
)
126 action_scope
= add_scope_prefix(config
, "beetmover:action:push-to-partner")
129 job
["scopes"] = [bucket_scope
, action_scope
]
130 job
["worker-type"] = "beetmover"
134 def generate_upstream_artifacts(
138 repackage_signing_task_ref
,
142 repack_stub_installer
=False,
144 upstream_artifacts
= []
145 artifact_prefix
= get_artifact_prefix(job
)
147 if "linux" in platform
:
148 upstream_artifacts
.append(
150 "taskId": {"task-reference": build_task_ref
},
152 "paths": [f
"{artifact_prefix}/{repack_id}/target.tar.bz2"],
153 "locale": partner_path
,
156 upstream_artifacts
.append(
158 "taskId": {"task-reference": repackage_signing_task_ref
},
159 "taskType": "repackage",
160 "paths": [f
"{artifact_prefix}/{repack_id}/target.tar.bz2.asc"],
161 "locale": partner_path
,
164 elif "macosx" in platform
:
165 upstream_artifacts
.append(
167 "taskId": {"task-reference": repackage_task_ref
},
168 "taskType": "repackage",
169 "paths": [f
"{artifact_prefix}/{repack_id}/target.dmg"],
170 "locale": partner_path
,
173 upstream_artifacts
.append(
175 "taskId": {"task-reference": repackage_signing_task_ref
},
176 "taskType": "repackage",
177 "paths": [f
"{artifact_prefix}/{repack_id}/target.dmg.asc"],
178 "locale": partner_path
,
181 elif "win" in platform
:
182 upstream_artifacts
.append(
184 "taskId": {"task-reference": repackage_signing_task_ref
},
185 "taskType": "repackage",
186 "paths": [f
"{artifact_prefix}/{repack_id}/target.installer.exe"],
187 "locale": partner_path
,
190 upstream_artifacts
.append(
192 "taskId": {"task-reference": repackage_signing_task_ref
},
193 "taskType": "repackage",
194 "paths": [f
"{artifact_prefix}/{repack_id}/target.installer.exe.asc"],
195 "locale": partner_path
,
198 if platform
.startswith("win32") and repack_stub_installer
:
199 upstream_artifacts
.append(
201 "taskId": {"task-reference": repackage_signing_task_ref
},
202 "taskType": "repackage",
204 "{}/{}/target.stub-installer.exe".format(
205 artifact_prefix
, repack_id
208 "locale": partner_path
,
211 upstream_artifacts
.append(
213 "taskId": {"task-reference": repackage_signing_task_ref
},
214 "taskType": "repackage",
216 "{}/{}/target.stub-installer.exe.asc".format(
217 artifact_prefix
, repack_id
220 "locale": partner_path
,
224 if not upstream_artifacts
:
225 raise Exception("Couldn't find any upstream artifacts.")
227 return upstream_artifacts
231 def make_task_worker(config
, jobs
):
233 platform
= job
["attributes"]["build_platform"]
234 repack_id
= job
["extra"]["repack_id"]
235 partner
, subpartner
, locale
= job
["extra"]["repack_id"].split("/")
236 partner_config
= get_partner_config_by_kind(config
, config
.kind
)
237 repack_stub_installer
= partner_config
[partner
][subpartner
].get(
238 "repack_stub_installer"
241 repackage_task
= None
242 repackage_signing_task
= None
244 for dependency
in job
["dependencies"].keys():
245 if "repackage-signing" in dependency
:
246 repackage_signing_task
= dependency
247 elif "repackage" in dependency
:
248 repackage_task
= dependency
252 build_task_ref
= "<" + str(build_task
) + ">"
253 repackage_task_ref
= "<" + str(repackage_task
) + ">"
254 repackage_signing_task_ref
= "<" + str(repackage_signing_task
) + ">"
256 # generate the partner path; we'll send this to beetmover as the "locale"
257 ftp_platform
= get_ftp_platform(platform
)
259 "build_number": config
.params
["build_number"],
262 "platform": ftp_platform
,
263 "release_partner_build_number": config
.params
[
264 "release_partner_build_number"
266 "subpartner": subpartner
,
267 "version": config
.params
["version"],
269 partner_path
= job
["partner-path"].format(**repl_dict
)
270 del job
["partner-path"]
273 "implementation": "beetmover",
274 "release-properties": craft_release_properties(config
, job
),
275 "upstream-artifacts": generate_upstream_artifacts(
279 repackage_signing_task_ref
,
283 repack_stub_installer
,
286 job
["worker"] = worker