Skip to content

Commit

Permalink
feat(relpro): allow passing "version" in release-promotion input
Browse files Browse the repository at this point in the history
  • Loading branch information
jcristau authored and ahal committed Mar 22, 2024
1 parent 3bb2c22 commit 9c7eee2
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 7 deletions.
25 changes: 20 additions & 5 deletions src/mozilla_taskgraph/actions/release_promotion.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@
"release version, and increments on rebuild."
),
},
"version": {
"type": "string",
"description": (
"Optional: override the version for release promotion. "
"Occasionally we'll land a taskgraph fix in a later "
"commit, but want to act on a build from a previous "
"commit. If a version bump has landed in the meantime, "
"relying on the in-tree version will break things."
),
"default": "",
},
"do_not_optimize": {
"type": "array",
"description": (
Expand Down Expand Up @@ -127,11 +138,15 @@ def release_promotion_action(parameters, graph_config, input, task_group_id, tas
parameters["shipping_phase"] = input["release_promotion_flavor"]
parameters["tasks_for"] = "action"

version_parser_objpath = "mozilla_taskgraph.version:default_parser"
if "version-parser" in graph_config:
version_parser_objpath = graph_config["version-parser"]
version_func = find_object(version_parser_objpath)
parameters["version"] = version_func(parameters)
if input["version"]:
parameters["version"] = input["version"]
else:
if "version-parser" in graph_config:
version_parser_objpath = graph_config["version-parser"]
else:
version_parser_objpath = "mozilla_taskgraph.version:default_parser"
version_func = find_object(version_parser_objpath)
parameters["version"] = version_func(parameters)

# make parameters read-only
parameters = Parameters(**parameters)
Expand Down
31 changes: 29 additions & 2 deletions test/actions/test_release_promotion.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def test_release_promotion(parameters, setup, run_action, datadir):
}
)

input = {"build_number": "2", "release_promotion_flavor": "promote"}
input = {"build_number": "2", "release_promotion_flavor": "promote", "version": ""}
mock = run_action("release-promotion", parameters, input)
assert_call(datadir, mock, expected_params)

Expand All @@ -122,7 +122,7 @@ def test_release_promotion_custom_version_parser(
graph_config = make_graph_config(
extra_config={"version-parser": "testver:fake_version"}
)
input = {"build_number": "2", "release_promotion_flavor": "promote"}
input = {"build_number": "2", "release_promotion_flavor": "promote", "version": ""}
try:
sys.path.insert(0, str(datadir))
mock = run_action("release-promotion", parameters, input, graph_config)
Expand Down Expand Up @@ -172,6 +172,7 @@ def test_release_promotion_combine_previous_graphs(
"build_number": "1",
"release_promotion_flavor": "ship",
"previous_graph_ids": ["d0", "d1"],
"version": "",
}
mock = run_action("release-promotion", parameters, input)
assert_call(datadir, mock, expected_params)
Expand Down Expand Up @@ -205,6 +206,32 @@ def test_release_promotion_rebuild_kinds(parameters, setup, run_action, datadir)
"release_promotion_flavor": "promote",
"rebuild_kinds": ["rebuild"],
"previous_graph_ids": ["d0"],
"version": "",
}
mock = run_action("release-promotion", parameters, input)
assert_call(datadir, mock, expected_params)


def test_release_promotion_version(parameters, setup, run_action, datadir):
setup()
expected_params = parameters.copy()
expected_params.update(
{
"build_number": 2,
"do_not_optimize": [],
"existing_tasks": {"a": 0, "b": 1},
"optimize_target_tasks": True,
"shipping_phase": "promote",
"target_tasks_method": "target_promote",
"tasks_for": "action",
"version": "2.0",
}
)

input = {
"build_number": "2",
"release_promotion_flavor": "promote",
"version": "2.0",
}
mock = run_action("release-promotion", parameters, input)
assert_call(datadir, mock, expected_params)

0 comments on commit 9c7eee2

Please sign in to comment.