зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1692575: Refactor the updatebot part of the moz.yaml schema to support multiple task types r=jewilde
Differential Revision: https://phabricator.services.mozilla.com/D105096
This commit is contained in:
Родитель
7e11c5d899
Коммит
9535519563
|
@ -12,6 +12,7 @@ from mozbuild.vendor.moz_yaml import load_moz_yaml, MozYamlVerifyError
|
|||
|
||||
|
||||
class TestManifest(unittest.TestCase):
|
||||
# ===========================================================================================
|
||||
def test_simple(self):
|
||||
simple_dict = {
|
||||
"schema": 1,
|
||||
|
@ -76,6 +77,407 @@ bugzilla:
|
|||
load_moz_yaml(tf.name, require_license_file=False), simple_dict
|
||||
)
|
||||
|
||||
# ===========================================================================================
|
||||
def test_updatebot(self):
|
||||
test_vectors = [
|
||||
(
|
||||
{
|
||||
"schema": 1,
|
||||
"origin": {
|
||||
"description": "2D Graphics Library",
|
||||
"license": ["MPL-1.1", "LGPL-2.1"],
|
||||
"name": "cairo",
|
||||
"release": "version 1.6.4",
|
||||
"revision": "AA001122334455",
|
||||
"url": "https://www.cairographics.org/",
|
||||
},
|
||||
"bugzilla": {
|
||||
"component": "Graphics",
|
||||
"product": "Core",
|
||||
},
|
||||
"updatebot": {
|
||||
"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: AA001122334455
|
||||
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": "AA001122334455",
|
||||
"url": "https://www.cairographics.org/",
|
||||
},
|
||||
"bugzilla": {
|
||||
"component": "Graphics",
|
||||
"product": "Core",
|
||||
},
|
||||
"updatebot": {
|
||||
"maintainer-phab": "tjr",
|
||||
"maintainer-bz": "a@example.com",
|
||||
"tasks": [{"type": "commit-alert"}],
|
||||
},
|
||||
},
|
||||
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
|
||||
bugzilla:
|
||||
product: Core
|
||||
component: Graphics
|
||||
updatebot:
|
||||
maintainer-phab: tjr
|
||||
maintainer-bz: a@example.com
|
||||
tasks:
|
||||
- type: commit-alert
|
||||
""".strip(),
|
||||
),
|
||||
# -------------------------------------------------
|
||||
(
|
||||
{
|
||||
"schema": 1,
|
||||
"origin": {
|
||||
"description": "2D Graphics Library",
|
||||
"license": ["MPL-1.1", "LGPL-2.1"],
|
||||
"name": "cairo",
|
||||
"release": "version 1.6.4",
|
||||
"revision": "AA001122334455",
|
||||
"url": "https://www.cairographics.org/",
|
||||
},
|
||||
"bugzilla": {
|
||||
"component": "Graphics",
|
||||
"product": "Core",
|
||||
},
|
||||
"updatebot": {
|
||||
"maintainer-phab": "tjr",
|
||||
"maintainer-bz": "a@example.com",
|
||||
"tasks": [
|
||||
{"type": "commit-alert"},
|
||||
{
|
||||
"type": "vendoring",
|
||||
"branch": "foo",
|
||||
"enabled": False,
|
||||
"cc": ["b@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: AA001122334455
|
||||
bugzilla:
|
||||
product: Core
|
||||
component: Graphics
|
||||
updatebot:
|
||||
maintainer-phab: tjr
|
||||
maintainer-bz: a@example.com
|
||||
tasks:
|
||||
- type: commit-alert
|
||||
- type: vendoring
|
||||
enabled: False
|
||||
branch: foo
|
||||
cc: ["b@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": "AA001122334455",
|
||||
"url": "https://www.cairographics.org/",
|
||||
},
|
||||
"bugzilla": {
|
||||
"component": "Graphics",
|
||||
"product": "Core",
|
||||
},
|
||||
"updatebot": {
|
||||
"maintainer-phab": "tjr",
|
||||
"maintainer-bz": "a@example.com",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "vendoring",
|
||||
"branch": "foo",
|
||||
"enabled": False,
|
||||
"cc": ["b@example.com", "c@example.com"],
|
||||
},
|
||||
{
|
||||
"type": "commit-alert",
|
||||
"filter": "none",
|
||||
"source-extensions": [".c", ".cpp"],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
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
|
||||
bugzilla:
|
||||
product: Core
|
||||
component: Graphics
|
||||
updatebot:
|
||||
maintainer-phab: tjr
|
||||
maintainer-bz: a@example.com
|
||||
tasks:
|
||||
- type: vendoring
|
||||
enabled: False
|
||||
branch: foo
|
||||
cc:
|
||||
- b@example.com
|
||||
- c@example.com
|
||||
- type: commit-alert
|
||||
filter: none
|
||||
source-extensions:
|
||||
- .c
|
||||
- .cpp
|
||||
""".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
|
||||
bugzilla:
|
||||
product: Core
|
||||
component: Graphics
|
||||
updatebot:
|
||||
maintainer-phab: tjr
|
||||
maintainer-bz: a@example.com
|
||||
tasks:
|
||||
- type: vendoring
|
||||
filter: none
|
||||
""".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
|
||||
bugzilla:
|
||||
product: Core
|
||||
component: Graphics
|
||||
updatebot:
|
||||
maintainer-phab: tjr
|
||||
maintainer-bz: a@example.com
|
||||
tasks:
|
||||
- type: foo
|
||||
""".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
|
||||
bugzilla:
|
||||
product: Core
|
||||
component: Graphics
|
||||
updatebot:
|
||||
maintainer-phab: tjr
|
||||
maintainer-bz: a@example.com
|
||||
tasks:
|
||||
- type: vendoring
|
||||
source-extensions:
|
||||
- .c
|
||||
- .cpp
|
||||
""".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
|
||||
bugzilla:
|
||||
product: Core
|
||||
component: Graphics
|
||||
updatebot:
|
||||
maintainer-phab: tjr
|
||||
maintainer-bz: a@example.com
|
||||
tasks:
|
||||
- type: commit-alert
|
||||
filter: hogwash
|
||||
""".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
|
||||
bugzilla:
|
||||
product: Core
|
||||
component: Graphics
|
||||
updatebot:
|
||||
maintainer-phab: tjr
|
||||
maintainer-bz: a@example.com
|
||||
tasks:
|
||||
- type: vendoring
|
||||
enabled: False
|
||||
branch: foo
|
||||
cc:
|
||||
- b@example.com
|
||||
- c@example.com
|
||||
- type: commit-alert
|
||||
- type: commit-alert
|
||||
filter: none
|
||||
source-extensions:
|
||||
- .c
|
||||
- .cpp""".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
|
||||
bugzilla:
|
||||
product: Core
|
||||
component: Graphics
|
||||
updatebot:
|
||||
maintainer-phab: tjr
|
||||
maintainer-bz: a@example.com
|
||||
tasks:
|
||||
- type: vendoring
|
||||
enabled: False
|
||||
branch: foo
|
||||
cc:
|
||||
- b@example.com
|
||||
- c@example.com
|
||||
- type: vendoring
|
||||
- type: commit-alert
|
||||
filter: none
|
||||
source-extensions:
|
||||
- .c
|
||||
- .cpp""".strip(),
|
||||
),
|
||||
]
|
||||
|
||||
indx = 0
|
||||
for vector in test_vectors:
|
||||
print("Testing index", indx)
|
||||
expected, yaml = vector
|
||||
with mozfile.NamedTemporaryFile() as tf:
|
||||
tf.write(yaml)
|
||||
tf.flush()
|
||||
if expected == "exception":
|
||||
with self.assertRaises(MozYamlVerifyError):
|
||||
load_moz_yaml(tf.name, require_license_file=False)
|
||||
else:
|
||||
self.assertDictEqual(
|
||||
load_moz_yaml(tf.name, require_license_file=False), expected
|
||||
)
|
||||
indx += 1
|
||||
|
||||
# ===========================================================================================
|
||||
def test_malformed(self):
|
||||
with mozfile.NamedTemporaryFile() as tf:
|
||||
tf.write(b"blah")
|
||||
|
|
|
@ -113,17 +113,25 @@ origin:
|
|||
# optional
|
||||
updatebot:
|
||||
|
||||
# Whether or not updating this library is enabled
|
||||
# Valid values are 'true', 'false'
|
||||
enabled: false
|
||||
|
||||
# TODO: allow multiple users to be specified
|
||||
# Phabricator username for a maintainer of the library, used for assigning
|
||||
# reviewers
|
||||
maintainer_phab: tjr
|
||||
maintainer-phab: tjr
|
||||
|
||||
# Bugzilla email address for a maintainer of the library, used for needinfos
|
||||
maintainer_bz: tom@mozilla.com
|
||||
maintainer-bz: tom@mozilla.com
|
||||
|
||||
# The tasks that Updatebot can run. Only one of each task is currently permitted
|
||||
# optional
|
||||
tasks:
|
||||
- type: commit-alert
|
||||
branch: upstream-branch-name
|
||||
cc: ["bugzilla@email.address", "another@example.com"]
|
||||
enabled: True
|
||||
filter: security
|
||||
- type: vendoring
|
||||
branch: master
|
||||
enabled: False
|
||||
|
||||
# Configuration for the automated vendoring system.
|
||||
# optional
|
||||
|
@ -343,9 +351,34 @@ def _schema_1():
|
|||
Required("revision"): Match(r"^[a-fA-F0-9]{12,40}$"),
|
||||
},
|
||||
"updatebot": {
|
||||
Required("enabled"): Boolean(),
|
||||
Required("maintainer-phab"): All(str, Length(min=1)),
|
||||
Required("maintainer-bz"): All(str, Length(min=1)),
|
||||
"tasks": All(
|
||||
UpdatebotTasks(),
|
||||
[
|
||||
{
|
||||
Required("type"): In(
|
||||
[
|
||||
"vendoring",
|
||||
"commit-alert",
|
||||
],
|
||||
msg="Invalid type specified in tasks",
|
||||
),
|
||||
"branch": All(str, Length(min=1)),
|
||||
"enabled": Boolean(),
|
||||
"cc": Unique([str]),
|
||||
"filter": In(
|
||||
[
|
||||
"none",
|
||||
"security",
|
||||
"source-extensions",
|
||||
],
|
||||
msg="Invalid filter value specified in tasks",
|
||||
),
|
||||
"source-extensions": Unique([str]),
|
||||
}
|
||||
],
|
||||
),
|
||||
},
|
||||
"vendoring": {
|
||||
Required("url"): FqdnUrl(),
|
||||
|
@ -477,6 +510,36 @@ class UpdateActions(object):
|
|||
return "UpdateActions"
|
||||
|
||||
|
||||
class UpdatebotTasks(object):
|
||||
"""Voluptuous validator which verifies the updatebot task(s) are valid."""
|
||||
|
||||
def __call__(self, values):
|
||||
seenTaskTypes = set()
|
||||
for v in values:
|
||||
if "type" not in v:
|
||||
raise Invalid("All updatebot tasks must specify a valid type")
|
||||
|
||||
if v["type"] in seenTaskTypes:
|
||||
raise Invalid("Only one type of each task is currently supported")
|
||||
seenTaskTypes.add(v["type"])
|
||||
|
||||
if v["type"] == "vendoring":
|
||||
if "filter" in v or "source-extensions" in v:
|
||||
raise Invalid(
|
||||
"'filter' and 'source-extensions' only valid for commit-alert task types"
|
||||
)
|
||||
elif v["type"] == "commit-alert":
|
||||
pass
|
||||
else:
|
||||
# This check occurs before the validator above, so the above is
|
||||
# redundant but we leave it to be verbose.
|
||||
raise Invalid("Supplied type " + v["type"] + " is invalid.")
|
||||
return values
|
||||
|
||||
def __repr__(self):
|
||||
return "UpdatebotTasks"
|
||||
|
||||
|
||||
class License(object):
|
||||
"""Voluptuous validator which verifies the license(s) are valid as per our
|
||||
allow list."""
|
||||
|
|
Загрузка…
Ссылка в новой задаче