From 9c7eee2747823530ccb9ea15ce3013a8922a77c4 Mon Sep 17 00:00:00 2001 From: Julien Cristau Date: Fri, 22 Mar 2024 10:19:02 +0100 Subject: [PATCH] feat(relpro): allow passing "version" in release-promotion input --- .../actions/release_promotion.py | 25 ++++++++++++--- test/actions/test_release_promotion.py | 31 +++++++++++++++++-- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/src/mozilla_taskgraph/actions/release_promotion.py b/src/mozilla_taskgraph/actions/release_promotion.py index 9cda060..9fad877 100644 --- a/src/mozilla_taskgraph/actions/release_promotion.py +++ b/src/mozilla_taskgraph/actions/release_promotion.py @@ -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": ( @@ -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) diff --git a/test/actions/test_release_promotion.py b/test/actions/test_release_promotion.py index 43c28ff..90e7527 100644 --- a/test/actions/test_release_promotion.py +++ b/test/actions/test_release_promotion.py @@ -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) @@ -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) @@ -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) @@ -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)