From 98be2e7ddde69ae82c37a89fe1fbb1a043b45f05 Mon Sep 17 00:00:00 2001 From: Tom Ritter Date: Tue, 1 Nov 2022 14:13:42 +0000 Subject: [PATCH] Bug 1797325: Support try presets in moz.yaml r=andi Differential Revision: https://phabricator.services.mozilla.com/D160232 --- .../mozbuild/mozbuild/test/test_manifest.py | 70 +++++++++++++++++++ python/mozbuild/mozbuild/vendor/moz_yaml.py | 21 ++++-- 2 files changed, 87 insertions(+), 4 deletions(-) diff --git a/python/mozbuild/mozbuild/test/test_manifest.py b/python/mozbuild/mozbuild/test/test_manifest.py index fb46f32142d6..dc4f018d5d86 100644 --- a/python/mozbuild/mozbuild/test/test_manifest.py +++ b/python/mozbuild/mozbuild/test/test_manifest.py @@ -161,6 +161,46 @@ bugzilla: product: Core component: Graphics updatebot: + maintainer-phab: tjr + maintainer-bz: a@example.com + """.strip(), + ), + # ------------------------------------------------- + ( + { + "schema": "1", + "origin": { + "description": "2D Graphics Library", + "license": ["MPL-1.1", "LGPL-2.1"], + "name": "cairo", + "release": "version 1.6.4", + "revision": "001122334455", + "url": "https://www.cairographics.org/", + }, + "bugzilla": {"component": "Graphics", "product": "Core"}, + "updatebot": { + "try-preset": "foo", + "maintainer-phab": "tjr", + "maintainer-bz": "a@example.com", + }, + }, + b""" +--- +schema: 1 +origin: + name: cairo + description: 2D Graphics Library + url: https://www.cairographics.org/ + release: version 1.6.4 + license: + - MPL-1.1 + - LGPL-2.1 + revision: 001122334455 +bugzilla: + product: Core + component: Graphics +updatebot: + try-preset: foo maintainer-phab: tjr maintainer-bz: a@example.com """.strip(), @@ -208,6 +248,36 @@ bugzilla: product: Core component: Graphics updatebot: + fuzzy-query: "!linux64" + maintainer-phab: tjr + maintainer-bz: a@example.com + tasks: + - type: commit-alert + """.strip(), + ), + # ------------------------------------------------- + ( + "exception", + b""" +--- +schema: 1 +origin: + name: cairo + description: 2D Graphics Library + url: https://www.cairographics.org/ + release: version 1.6.4 + license: + - MPL-1.1 + - LGPL-2.1 + revision: AA001122334455 +vendoring: + url: https://example.com + source-hosting: gitlab +bugzilla: + product: Core + component: Graphics +updatebot: + try-preset: foo fuzzy-query: "!linux64" maintainer-phab: tjr maintainer-bz: a@example.com diff --git a/python/mozbuild/mozbuild/vendor/moz_yaml.py b/python/mozbuild/mozbuild/vendor/moz_yaml.py index ca3335a72b91..9fbc8f85d2e7 100644 --- a/python/mozbuild/mozbuild/vendor/moz_yaml.py +++ b/python/mozbuild/mozbuild/vendor/moz_yaml.py @@ -284,12 +284,16 @@ updatebot: # Bugzilla email address for a maintainer of the library, used for needinfos maintainer-bz: tom@mozilla.com - # Optional: A query string for ./mach try fuzzy. If it and fuzzy-paths are omitted then - # ./mach try auto will be used + # Optional: A preset for ./mach try to use. If present, fuzzy-query and fuzzy-paths will + # be ignored. If it, fuzzy-query, and fuzzy-path are omitted, ./mach try auto will be used + try-preset: media + + # Optional: A query string for ./mach try fuzzy. If try-preset, it and fuzzy-paths are omitted + # then ./mach try auto will be used fuzzy-query: media - # Optional: An array of test paths for ./mach try fuzzy. If it and fuzzy-query are omitted then - # ./mach try auto will be used + # Optional: An array of test paths for ./mach try fuzzy. If try-preset, it and fuzzy-query are + # omitted then ./mach try auto will be used fuzzy-paths: ['media'] # The tasks that Updatebot can run. Only one of each task is currently permitted @@ -389,6 +393,7 @@ def _schema_1(): "updatebot": { Required("maintainer-phab"): All(str, Length(min=1)), Required("maintainer-bz"): All(str, Length(min=1)), + "try-preset": All(str, Length(min=1)), "fuzzy-query": All(str, Length(min=1)), "fuzzy-paths": All([str], Length(min=1)), "tasks": All( @@ -571,6 +576,14 @@ def _schema_1_additional(filename, manifest, require_license_file=True): "The individual-files flavor of update must include 'individual-files'" ) + if "updatebot" in manifest: + if "try-preset" in manifest["updatebot"]: + for f in ["fuzzy-query", "fuzzy-paths"]: + if f in manifest["updatebot"]: + raise ValueError( + "If 'try-preset' is specified, then %s cannot be" % f + ) + # Check for a simple YAML file with open(filename, "r") as f: has_schema = False