Skip to content

Commit 2a56c4b

Browse files
Eijebonghneiva
authored andcommitted
WIP: Add release promotion + mozilla_version dependency
this is mostly copied from firefox-android and fixed to work with firefox-ios
1 parent 8d12fd8 commit 2a56c4b

File tree

5 files changed

+220
-1
lines changed

5 files changed

+220
-1
lines changed

taskcluster/config.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,12 @@ workers:
3535

3636
scriptworker:
3737
scope-prefix: project:mobile:firefox-ios:releng
38+
39+
release-promotion:
40+
flavors:
41+
promote:
42+
target-tasks-method: promote
43+
push:
44+
target-tasks-method: push
45+
ship:
46+
target-tasks-method: ship

taskcluster/ffios_taskgraph/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def register(graph_config):
2222
# Setup mozilla-taskgraph
2323
register_mozilla_taskgraph(graph_config)
2424

25-
_import_modules(["job", "parameters", "routes", "target_tasks"])
25+
_import_modules(["job", "parameters", "routes", "target_tasks", "release_promotion"])
2626

2727

2828
def _import_modules(modules):
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
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+
6+
import os
7+
8+
from mozilla_version.mobile import MobileVersion
9+
from taskgraph.actions.registry import register_callback_action
10+
from taskgraph.decision import taskgraph_decision
11+
from taskgraph.parameters import Parameters
12+
from taskgraph.taskgraph import TaskGraph
13+
from taskgraph.util.taskcluster import get_artifact
14+
from taskgraph.util.taskgraph import (
15+
find_decision_task,
16+
find_existing_tasks_from_previous_kinds,
17+
)
18+
19+
RELEASE_PROMOTION_PROJECTS = (
20+
"https://github.com/mozilla-mobile/firefox-ios",
21+
"https://github.com/mozilla-mobile/staging-firefox-ios",
22+
)
23+
24+
25+
def is_release_promotion_available(parameters):
26+
return parameters["head_repository"] in RELEASE_PROMOTION_PROJECTS
27+
28+
29+
@register_callback_action(
30+
name="release-promotion",
31+
title="Release Promotion",
32+
symbol="${input.release_promotion_flavor}",
33+
description="Release Promotion",
34+
permission="release-promotion",
35+
order=500,
36+
context=[],
37+
available=is_release_promotion_available,
38+
schema=lambda graph_config: {
39+
"type": "object",
40+
"properties": {
41+
"build_number": {
42+
"type": "integer",
43+
"default": 1,
44+
"minimum": 1,
45+
"title": "The release build number",
46+
"description": (
47+
"The release build number. Starts at 1 per "
48+
"release version, and increments on rebuild."
49+
),
50+
},
51+
"do_not_optimize": {
52+
"type": "array",
53+
"description": (
54+
"Optional: a list of labels to avoid optimizing out "
55+
"of the graph (to force a rerun of, say, "
56+
"funsize docker-image tasks)."
57+
),
58+
"items": {
59+
"type": "string",
60+
},
61+
},
62+
"revision": {
63+
"type": "string",
64+
"title": "Optional: revision to ship",
65+
"description": ("Optional: the revision to ship."),
66+
},
67+
"release_promotion_flavor": {
68+
"type": "string",
69+
"description": "The flavor of release promotion to perform.",
70+
"default": "build",
71+
"enum": sorted(graph_config["release-promotion"]["flavors"].keys()),
72+
},
73+
"rebuild_kinds": {
74+
"type": "array",
75+
"description": (
76+
"Optional: an array of kinds to ignore from the previous "
77+
"graph(s)."
78+
),
79+
"default": graph_config["release-promotion"].get("rebuild-kinds", []),
80+
"items": {
81+
"type": "string",
82+
},
83+
},
84+
"previous_graph_ids": {
85+
"type": "array",
86+
"description": (
87+
"Optional: an array of taskIds of decision or action "
88+
"tasks from the previous graph(s) to use to populate "
89+
"our `previous_graph_kinds`."
90+
),
91+
"items": {
92+
"type": "string",
93+
},
94+
},
95+
"version": {
96+
"type": "string",
97+
"description": (
98+
"Optional: override the version for release promotion. "
99+
"Occasionally we'll land a taskgraph fix in a later "
100+
"commit, but want to act on a build from a previous "
101+
"commit. If a version bump has landed in the meantime, "
102+
"relying on the in-tree version will break things."
103+
),
104+
"default": "",
105+
},
106+
"next_version": {
107+
"type": "string",
108+
"description": "Next version.",
109+
"default": "",
110+
},
111+
},
112+
"required": [
113+
"release_promotion_flavor",
114+
"version",
115+
"build_number",
116+
"next_version",
117+
],
118+
},
119+
)
120+
def release_promotion_action(parameters, graph_config, input, task_group_id, task_id):
121+
release_promotion_flavor = input["release_promotion_flavor"]
122+
promotion_config = graph_config["release-promotion"]["flavors"][
123+
release_promotion_flavor
124+
]
125+
126+
target_tasks_method = promotion_config["target-tasks-method"].format(
127+
project=parameters["project"]
128+
)
129+
rebuild_kinds = input.get(
130+
"rebuild_kinds", promotion_config.get("rebuild-kinds", [])
131+
)
132+
do_not_optimize = input.get(
133+
"do_not_optimize", promotion_config.get("do-not-optimize", [])
134+
)
135+
136+
# make parameters read-write
137+
parameters = dict(parameters)
138+
# Build previous_graph_ids from ``previous_graph_ids`` or ``revision``.
139+
previous_graph_ids = input.get("previous_graph_ids")
140+
if not previous_graph_ids:
141+
previous_graph_ids = [find_decision_task(parameters, graph_config)]
142+
143+
# Download parameters from the first decision task
144+
parameters = get_artifact(previous_graph_ids[0], "public/parameters.yml")
145+
# Download and combine full task graphs from each of the previous_graph_ids.
146+
# Sometimes previous relpro action tasks will add tasks, like partials,
147+
# that didn't exist in the first full_task_graph, so combining them is
148+
# important. The rightmost graph should take precedence in the case of
149+
# conflicts.
150+
combined_full_task_graph = {}
151+
for graph_id in previous_graph_ids:
152+
full_task_graph = get_artifact(graph_id, "public/full-task-graph.json")
153+
combined_full_task_graph.update(full_task_graph)
154+
_, combined_full_task_graph = TaskGraph.from_json(combined_full_task_graph)
155+
parameters["existing_tasks"] = find_existing_tasks_from_previous_kinds(
156+
combined_full_task_graph, previous_graph_ids, rebuild_kinds
157+
)
158+
parameters["do_not_optimize"] = do_not_optimize
159+
parameters["target_tasks_method"] = target_tasks_method
160+
parameters["build_number"] = int(input["build_number"])
161+
# When doing staging releases on try, we still want to re-use tasks from
162+
# previous graphs.
163+
parameters["optimize_target_tasks"] = True
164+
parameters["shipping_phase"] = input["release_promotion_flavor"]
165+
166+
version_in_file = read_version_file()
167+
version_string = input.get("version", None)
168+
169+
# shipit uses the version in version.txt to determine next version number; check that its passed in
170+
# in the payload
171+
if not version_string:
172+
version_string = version_in_file
173+
elif version_string != version_in_file:
174+
raise ValueError(
175+
"Version given in tag ({}) does not match the one in version.txt ({})".format(
176+
version_string, version_in_file
177+
)
178+
)
179+
180+
parameters["version"] = version_string
181+
parameters["head_tag"] = "v{}".format(version_string)
182+
parameters["next_version"] = input["next_version"]
183+
184+
release_type = "release"
185+
version = MobileVersion.parse(version_string)
186+
if version.is_beta:
187+
release_type = "beta"
188+
189+
parameters["release_type"] = release_type
190+
parameters["tasks_for"] = "action"
191+
parameters["pull_request_number"] = None
192+
193+
# make parameters read-only
194+
parameters = Parameters(**parameters)
195+
196+
taskgraph_decision({"root": graph_config.root_dir}, parameters=parameters)
197+
198+
199+
def read_version_file():
200+
with open(os.path.join(os.path.dirname(__file__), "..", "..", "version.txt")) as f:
201+
return f.read().strip()

taskcluster/requirements.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
# https://taskcluster-taskgraph.readthedocs.io/en/latest/howto/bootstrap-taskgraph.html
33

44
mozilla-taskgraph>=3.0.3
5+
mozilla-version>=3.1.0
56
taskcluster-taskgraph>=13.1.0

taskcluster/requirements.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ arrow==1.3.0 \
88
--hash=sha256:c728b120ebc00eb84e01882a6f5e7927a53960aa990ce7dd2b10f39005a67f80 \
99
--hash=sha256:d4540617648cb5f895730f1ad8c82a65f2dad0166f57b75f3ca54759c4d67a85
1010
# via cookiecutter
11+
attrs==25.1.0 \
12+
--hash=sha256:1c97078a80c814273a76b2a298a932eb681c87415c11dee0a6921de7f1b02c3e \
13+
--hash=sha256:c75a69e28a550a7e93789579c22aa26b0f5b83b75dc4e08fe092980051e1090a
14+
# via mozilla-version
1115
binaryornot==0.4.4 \
1216
--hash=sha256:359501dfc9d40632edc9fac890e19542db1a287bbcfa58175b66658392018061 \
1317
--hash=sha256:b8b71173c917bddcd2c16070412e369c3ed7f0528926f70cac18a6c97fd563e4
@@ -214,6 +218,10 @@ mozilla-taskgraph==3.0.3 \
214218
--hash=sha256:0a9a4ad20163fb85f56584ce05c5c9fdd4948e2ddfe1a568446b7e63e5da95fd \
215219
--hash=sha256:65d0dcadae2960d7a45ffeb07479dcf9f4d9c5478555e5b6f3ba2098c5af3f06
216220
# via -r requirements.in
221+
mozilla-version==3.1.0 \
222+
--hash=sha256:3a9463ebcf2249dc8bcf504e246b6b5977c902dfa819de31602e10bce032ed93 \
223+
--hash=sha256:f798e716da9063608a0b49ca1ec0a51b73ac810c3cc8a4bcc2c461df902b147c
224+
# via -r requirements.in
217225
pygments==2.18.0 \
218226
--hash=sha256:786ff802f32e91311bff3889f6e9a86e81505fe99f2735bb6d60ae0c5004f199 \
219227
--hash=sha256:b8e6aca0523f3ab76fee51799c488e38782ac06eafcf95e7ba832985c8e7b13a

0 commit comments

Comments
 (0)