diff --git a/python/mozbuild/mozbuild/test/test_manifest.py b/python/mozbuild/mozbuild/test/test_manifest.py index c50cef9ec6d8..61ea72f6373e 100644 --- a/python/mozbuild/mozbuild/test/test_manifest.py +++ b/python/mozbuild/mozbuild/test/test_manifest.py @@ -41,10 +41,7 @@ class TestManifest(unittest.TestCase): "revision": "AA001122334455", "url": "https://www.cairographics.org/", }, - "bugzilla": { - "component": "Graphics", - "product": "Core", - }, + "bugzilla": {"component": "Graphics", "product": "Core"}, } self.process_test_vectors( @@ -104,10 +101,7 @@ bugzilla: "revision": "AA001122334455", "url": "https://www.cairographics.org/", }, - "bugzilla": { - "component": "Graphics", - "product": "Core", - }, + "bugzilla": {"component": "Graphics", "product": "Core"}, "updatebot": { "maintainer-phab": "tjr", "maintainer-bz": "a@example.com", @@ -145,10 +139,7 @@ updatebot: "revision": "AA001122334455", "url": "https://www.cairographics.org/", }, - "bugzilla": { - "component": "Graphics", - "product": "Core", - }, + "bugzilla": {"component": "Graphics", "product": "Core"}, "vendoring": { "url": "https://example.com", "source-hosting": "gitlab", @@ -156,6 +147,7 @@ updatebot: "updatebot": { "maintainer-phab": "tjr", "maintainer-bz": "a@example.com", + "tracking": "commit", "tasks": [{"type": "commit-alert"}], }, }, @@ -196,10 +188,7 @@ updatebot: "revision": "AA001122334455", "url": "https://www.cairographics.org/", }, - "bugzilla": { - "component": "Graphics", - "product": "Core", - }, + "bugzilla": {"component": "Graphics", "product": "Core"}, "vendoring": { "url": "https://example.com", "source-hosting": "gitlab", @@ -207,11 +196,9 @@ updatebot: "updatebot": { "maintainer-phab": "tjr", "maintainer-bz": "a@example.com", + "tracking": "commit", "tasks": [ - { - "type": "commit-alert", - "frequency": "release", - }, + {"type": "commit-alert", "frequency": "release"}, { "type": "vendoring", "branch": "foo", @@ -244,6 +231,7 @@ bugzilla: updatebot: maintainer-phab: tjr maintainer-bz: a@example.com + tracking: commit tasks: - type: commit-alert frequency: release @@ -267,10 +255,7 @@ updatebot: "revision": "AA001122334455", "url": "https://www.cairographics.org/", }, - "bugzilla": { - "component": "Graphics", - "product": "Core", - }, + "bugzilla": {"component": "Graphics", "product": "Core"}, "vendoring": { "url": "https://example.com", "source-hosting": "gitlab", @@ -278,6 +263,7 @@ updatebot: "updatebot": { "maintainer-phab": "tjr", "maintainer-bz": "a@example.com", + "tracking": "commit", "tasks": [ { "type": "vendoring", @@ -746,10 +732,7 @@ updatebot: "revision": "v1.6.37", "url": "https://www.cairographics.org/", }, - "bugzilla": { - "component": "Graphics", - "product": "Core", - }, + "bugzilla": {"component": "Graphics", "product": "Core"}, }, b""" --- diff --git a/python/mozbuild/mozbuild/vendor/moz_yaml.py b/python/mozbuild/mozbuild/vendor/moz_yaml.py index 032908c5ff82..55fa3b364c9d 100644 --- a/python/mozbuild/mozbuild/vendor/moz_yaml.py +++ b/python/mozbuild/mozbuild/vendor/moz_yaml.py @@ -121,6 +121,10 @@ updatebot: # Bugzilla email address for a maintainer of the library, used for needinfos maintainer-bz: tom@mozilla.com + # Type of git reference (commit, tag) to track updates from. + # If omitted, will default to tracking commits. + tracking: commit + # The tasks that Updatebot can run. Only one of each task is currently permitted # optional tasks: @@ -361,15 +365,13 @@ def _schema_1(): "updatebot": { Required("maintainer-phab"): All(str, Length(min=1)), Required("maintainer-bz"): All(str, Length(min=1)), + "tracking": All(str, Length(min=1)), "tasks": All( UpdatebotTasks(), [ { Required("type"): In( - [ - "vendoring", - "commit-alert", - ], + ["vendoring", "commit-alert"], msg="Invalid type specified in tasks", ), "branch": All(str, Length(min=1)), @@ -377,11 +379,7 @@ def _schema_1(): "cc": Unique([str]), "needinfo": Unique([str]), "filter": In( - [ - "none", - "security", - "source-extensions", - ], + ["none", "security", "source-extensions"], msg="Invalid filter value specified in tasks", ), "source-extensions": Unique([str]), @@ -460,8 +458,19 @@ def _schema_1_additional(filename, manifest, require_license_file=True): if "vendoring" in manifest and "origin" not in manifest: raise ValueError('"vendoring" requires an "origin"') - # If there are Updatebot tasks, then certain fields must be present + # If there are Updatebot tasks, then certain fields must be present and + # defaults need to be set. if "updatebot" in manifest and "tasks" in manifest["updatebot"]: + if "tracking" not in manifest["updatebot"]: + manifest["updatebot"]["tracking"] = "commit" + if ( + manifest["updatebot"]["tracking"] != "commit" + and manifest["updatebot"]["tracking"] != "tag" + ): + raise ValueError( + "Only commit or tag is supported for git references to track, %s was given." + % manifest["updatebot"]["tracking"] + ) if "vendoring" not in manifest or "url" not in manifest["vendoring"]: raise ValueError( "If Updatebot tasks are specified, a vendoring url must be included."