From 8448ae9a8add1833e5002dbb8075e06b9c3d5bd3 Mon Sep 17 00:00:00 2001 From: Gabriel Bustamante Date: Mon, 8 Apr 2024 14:23:41 -0500 Subject: [PATCH] merge automation as shipit ff product --- api/products.yml | 15 ++++ api/src/backend_common/__init__.py | 5 ++ api/src/backend_common/action.json | 101 ++++++++++++++++++++++++ api/src/shipit_api/admin/api.py | 1 + api/src/shipit_api/admin/tasks.py | 9 ++- api/src/shipit_api/public/api.py | 16 ++++ frontend/src/configs/development.js | 17 ++++ frontend/src/views/NewRelease/index.jsx | 18 +++-- 8 files changed, 174 insertions(+), 8 deletions(-) create mode 100644 api/src/backend_common/action.json diff --git a/api/products.yml b/api/products.yml index cfd9a781c..df7c3b7d8 100644 --- a/api/products.yml +++ b/api/products.yml @@ -39,6 +39,21 @@ firefox: - push_firefox - ship_firefox version-class: "mozilla_version.gecko.FirefoxVersion" +merge-automation: + can-be-disabled: true + authorized-ldap-groups: + - shipit_firefox + - shipit_relman + phases: + [ + "beta-to-release", + "bump-central", + "bump-esr115", + "central-to-beta", + "early-to-late-beta", + "release-to-esr", + ] + version-class: "mozilla_version.gecko.FirefoxVersion" firefox-android: can-be-disabled: true authorized-ldap-groups: diff --git a/api/src/backend_common/__init__.py b/api/src/backend_common/__init__.py index d09cd6ebf..1d72ddeff 100644 --- a/api/src/backend_common/__init__.py +++ b/api/src/backend_common/__init__.py @@ -65,6 +65,8 @@ def create_app(project_name, app_name, root_path, extensions=[], config=None, re if redirect_root_to_api: app.add_url_rule("/", "root", lambda: flask.redirect(app.api.swagger_url)) + # from pprint import pformat + # logger.warn(pformat(build_api_specification(root_path))) app.api.register(build_api_specification(root_path)) logger.debug("Initialized %s", app.name) return app @@ -94,11 +96,14 @@ def _read_specification_file(path): def get_product_names(include_legacy=False): products_config = get_products_config() + # logger.warn(products_config) + # logger.warn([product_name for product_name, product_config in products_config.items() if not product_config["legacy"] or include_legacy]) return [product_name for product_name, product_config in products_config.items() if not product_config["legacy"] or include_legacy] @cache def get_products_config(): + # logger.warn(_PRODUCT_YML_PATH) with open(_PRODUCT_YML_PATH) as f: products_config = yaml.safe_load(f) diff --git a/api/src/backend_common/action.json b/api/src/backend_common/action.json new file mode 100644 index 000000000..adf85dc9e --- /dev/null +++ b/api/src/backend_common/action.json @@ -0,0 +1,101 @@ +{ + "context": [], + "description": "Merge repository branches.", + "extra": { + "actionPerm": "merge-automation" + }, + "hookGroupId": "project-gecko", + "hookId": "in-tree-action-3-merge-automation/f526da500b", + "hookPayload": { + "decision": { + "action": { + "cb_name": "merge-automation", + "description": "Merge repository branches.", + "name": "merge-automation", + "symbol": "${input.behavior}", + "taskGroupId": "Q3lH6-MQQA68FxgMpa89Cw", + "title": "Merge Day Automation" + }, + "push": { + "base_revision": "2a006ccd4a0f986d95177aa1cf2875b054b4e52b", + "owner": "mozilla-taskcluster-maintenance@mozilla.com", + "pushlog_id": "19187", + "revision": "bcf5880a2381bd2062bb754047fe6b64308de475" + }, + "repository": { + "level": "3", + "project": "mozilla-beta", + "url": "https://hg.mozilla.org/releases/mozilla-beta" + } + }, + "user": { + "input": { + "$eval": "input" + }, + "taskGroupId": { + "$eval": "taskGroupId" + }, + "taskId": { + "$eval": "taskId" + } + } + }, + "kind": "hook", + "name": "merge-automation", + "schema": { + "properties": { + "behavior": { + "default": "central-to-beta", + "description": "The type of release promotion to perform.", + "enum": [ + "beta-to-release", + "bump-central", + "bump-esr115", + "central-to-beta", + "early-to-late-beta", + "release-to-esr" + ], + "type": "string" + }, + "fetch-version-from": { + "description": "Path to file used when querying current version.", + "type": "string" + }, + "force-dry-run": { + "default": true, + "description": "Override other options and do not push changes", + "type": "boolean" + }, + "from-branch": { + "description": "The fx head of the source, such as central", + "type": "string" + }, + "from-repo": { + "description": "The URI of the source repository", + "type": "string" + }, + "push": { + "default": false, + "description": "Push changes using to_repo and to_branch", + "type": "boolean" + }, + "ssh-user-alias": { + "description": "The alias of an ssh account to use when pushing changes.", + "type": "string" + }, + "to-branch": { + "description": "The fx head of the target, such as beta", + "type": "string" + }, + "to-repo": { + "description": "The push URI of the target repository", + "type": "string" + } + }, + "required": [ + "behavior" + ], + "type": "object" + }, + "title": "Merge Day Automation" +} \ No newline at end of file diff --git a/api/src/shipit_api/admin/api.py b/api/src/shipit_api/admin/api.py index 7908b4e9e..698d03f61 100644 --- a/api/src/shipit_api/admin/api.py +++ b/api/src/shipit_api/admin/api.py @@ -92,6 +92,7 @@ def add_release(body): ) try: next_version = bump_version(release.product, release.version) + # this is input to the release-promotion action - the merge-automation action has a diff input schema common_input = { "build_number": release.build_number, "next_version": next_version, diff --git a/api/src/shipit_api/admin/tasks.py b/api/src/shipit_api/admin/tasks.py index cd8f41b6e..69efc4b0d 100644 --- a/api/src/shipit_api/admin/tasks.py +++ b/api/src/shipit_api/admin/tasks.py @@ -233,8 +233,13 @@ def get_parameters(decision_task_id): def release_promotion_flavors(release, actions, verify_supported_flavors=True): - relpro = find_action("release-promotion", actions) - avail_flavors = relpro["schema"]["properties"]["release_promotion_flavor"]["enum"] + if release.product == "merge-automation": # I am just exploring, so I special cased merge-automation here (cuz it's not release-promotion) + action_name = "merge-automation" + else: + action_name = "release-promotion" + action = find_action(action_name, actions) + flavors_key = "release_promotion_flavor" if release.product != "merge-automation" else "behavior" + avail_flavors = action["schema"]["properties"][flavors_key]["enum"] if verify_supported_flavors: return extract_our_flavors(avail_flavors, release.product, release.version, release.partial_updates, release.product_key) return [{"name": name, "in_previous_graph_ids": True} for name in avail_flavors] diff --git a/api/src/shipit_api/public/api.py b/api/src/shipit_api/public/api.py index a77185b09..cbb2714a3 100644 --- a/api/src/shipit_api/public/api.py +++ b/api/src/shipit_api/public/api.py @@ -43,10 +43,26 @@ def list_releases(product=None, branch=None, version=None, build_number=None, st releases = releases.filter(Release.build_number == build_number) elif build_number: raise BadRequest(description="Filtering by build_number without version is not supported.") + if product == "merge-automation": + print(product) + print(branch) + print(version) + print(build_number) + print(status) releases = releases.filter(Release.status.in_(status)) + if product == "merge-automation": + print(releases) releases = [r.json for r in releases.all()] + if product == "merge-automation": + print(releases) + return releases # filter out not parsable releases, like 1.1, 1.1b1, etc releases = filter(good_version, releases) + if product == "merge-automation": + print(releases) + print(_sort_releases_by_product_then_version(releases)) + import sys + sys.stdout.flush() return _sort_releases_by_product_then_version(releases) diff --git a/frontend/src/configs/development.js b/frontend/src/configs/development.js index e589162ca..cc5779ced 100644 --- a/frontend/src/configs/development.js +++ b/frontend/src/configs/development.js @@ -92,6 +92,23 @@ module.exports = { ], enablePartials: false, }, + { + product: 'merge-automation', + prettyName: 'Merge Automation', + appName: 'merge-automation', + branches: [ + { + prettyName: 'Beta', + project: 'mozilla-beta', + branch: 'releases/mozilla-beta', + repo: 'https://hg.mozilla.org/releases/mozilla-beta', + enableReleaseEta: false, + disableable: true, + versionFile: 'browser/config/version_display.txt', + }, + ], + enablePartials: false, + }, ], thunderbird: [ { diff --git a/frontend/src/views/NewRelease/index.jsx b/frontend/src/views/NewRelease/index.jsx index d791ea641..c2581b35c 100644 --- a/frontend/src/views/NewRelease/index.jsx +++ b/frontend/src/views/NewRelease/index.jsx @@ -409,14 +409,20 @@ export default function NewRelease() { }; const renderReleaseInfo = () => { + // shipit is looking for a version_display.txt file here: + // https://hg.mozilla.org/try/raw-file/bd34c4d287cae93983357f5ef26f41d29f590878/merge-automation/config/version_display.txt return ( - - Version: {version} - - - Build #: {buildNumber} - + {version && ( + + Version: {version} + + )} + {buildNumber && ( + + Build #: {buildNumber} + + )} ); };