tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

merge_automation.py (3432B)


      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 from taskgraph.parameters import Parameters
      6 
      7 from gecko_taskgraph.actions.registry import register_callback_action
      8 from gecko_taskgraph.decision import taskgraph_decision
      9 from gecko_taskgraph.util.attributes import RELEASE_PROMOTION_PROJECTS
     10 
     11 
     12 def is_release_promotion_available(parameters):
     13    return parameters["project"] in RELEASE_PROMOTION_PROJECTS
     14 
     15 
     16 @register_callback_action(
     17    name="merge-automation",
     18    title="Merge Day Automation",
     19    symbol="${input.behavior}",
     20    description="Merge repository branches.",
     21    permission="merge-automation",
     22    order=500,
     23    context=[],
     24    available=is_release_promotion_available,
     25    schema=lambda graph_config: {
     26        "type": "object",
     27        "properties": {
     28            "force-dry-run": {
     29                "type": "boolean",
     30                "description": "Override other options and do not push changes",
     31                "default": True,
     32            },
     33            "push": {
     34                "type": "boolean",
     35                "description": "Push changes using to_repo and to_branch (mercurial only)",
     36            },
     37            "behavior": {
     38                "type": "string",
     39                "description": "The type of release promotion to perform.",
     40                # this enum should be kept in sync with the merge-automation kind
     41                "enum": [
     42                    "bump-main",
     43                    "bump-esr140",
     44                    "early-to-late-beta",
     45                    "main-to-beta",
     46                    "beta-to-release",
     47                    "release-to-esr",
     48                ],
     49                "default": "REPLACE ME",
     50            },
     51            "from-repo": {
     52                "type": "string",
     53                "description": "The URI of the source repository",
     54            },
     55            "to-repo": {
     56                "type": "string",
     57                "description": "The push URI of the target repository",
     58            },
     59            "from-branch": {
     60                "type": "string",
     61                "description": "The fx head of the source, such as central",
     62            },
     63            "to-branch": {
     64                "type": "string",
     65                "description": "The fx head of the target, such as beta",
     66            },
     67            "fetch-version-from": {
     68                "type": "string",
     69                "description": "Path to file used when querying current version.",
     70            },
     71        },
     72        "required": ["behavior"],
     73    },
     74 )
     75 def merge_automation_action(parameters, graph_config, input, task_group_id, task_id):
     76    # make parameters read-write
     77    parameters = dict(parameters)
     78 
     79    parameters["target_tasks_method"] = "merge_automation"
     80    parameters["merge_config"] = {
     81        "force-dry-run": input.get("force-dry-run", False),
     82        "behavior": input["behavior"],
     83    }
     84 
     85    for field in [
     86        "from-repo",
     87        "from-branch",
     88        "to-repo",
     89        "to-branch",
     90        "push",
     91        "fetch-version-from",
     92    ]:
     93        if input.get(field):
     94            parameters["merge_config"][field] = input[field]
     95    parameters["tasks_for"] = "action"
     96 
     97    # make parameters read-only
     98    parameters = Parameters(**parameters)
     99 
    100    taskgraph_decision({"root": graph_config.root_dir}, parameters=parameters)