allow configuring products for branches by regex
This is in order not to have to hard code EPEL. In the course, reorganize how products and their correspondent versions and component namespaces are configured. Signed-off-by: Nils Philippsen <nils@redhat.com>
This commit is contained in:
parent
12b90b22dd
commit
f2bea59f37
2 changed files with 69 additions and 38 deletions
|
@ -7,21 +7,19 @@ Reassigning to the new maintainer of this component.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
[products]
|
[products]
|
||||||
"Fedora" = "Fedora"
|
[products.Fedora]
|
||||||
"Fedora Container" = "Fedora Container Images"
|
namespace = "rpms"
|
||||||
"Fedora Modules" = "Fedora Modules"
|
versions = ["rawhide", "31", "30", "29"]
|
||||||
"Fedora EPEL" = "Fedora EPEL"
|
[products."Fedora Container"]
|
||||||
|
namespace = "container"
|
||||||
[products_versions]
|
versions = ["rawhide", "29"]
|
||||||
"Fedora" = ["rawhide", "31", "30", "29"]
|
bz_product_name = "Fedora Container Images"
|
||||||
"Fedora Container" = ["rawhide", "29"]
|
[products."Fedora Modules"]
|
||||||
"Fedora Modules" = []
|
namespace = "modules"
|
||||||
"Fedora EPEL" = ["epel8", "epel7", "el6"]
|
versions = []
|
||||||
|
[products."Fedora EPEL"]
|
||||||
[namespace_to_product]
|
branch_regex = '^epel\d+$'
|
||||||
"rpms" = "Fedora" # except EPEL...
|
versions = ["epel8", "epel7", "el6"]
|
||||||
"container" = "Fedora Container"
|
|
||||||
"modules" = "Fedora Modules"
|
|
||||||
|
|
||||||
[pdc_types]
|
[pdc_types]
|
||||||
"rpms" = "rpm"
|
"rpms" = "rpm"
|
||||||
|
|
|
@ -248,7 +248,7 @@ class BugzillaProxy:
|
||||||
'NEW', 'ASSIGNED', 'ON_DEV', 'ON_QA', 'MODIFIED', 'POST',
|
'NEW', 'ASSIGNED', 'ON_DEV', 'ON_QA', 'MODIFIED', 'POST',
|
||||||
'FAILS_QA', 'PASSES_QA', 'RELEASE_PENDING']
|
'FAILS_QA', 'PASSES_QA', 'RELEASE_PENDING']
|
||||||
# Update only maintained releases
|
# Update only maintained releases
|
||||||
bz_query['version'] = self.config["products_versions"][product]
|
bz_query['version'] = self.config["products"][product]["versions"]
|
||||||
|
|
||||||
query_results = self.server.query(bz_query)
|
query_results = self.server.query(bz_query)
|
||||||
|
|
||||||
|
@ -409,11 +409,14 @@ class BugzillaProxy:
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
if self.config.get("print-no-change"):
|
if self.config.get("print-no-change"):
|
||||||
print(f"[NOCHANGE] {package}/{self.config['products'][collection]}")
|
bz_product_name = self.config['products'][collection].get(
|
||||||
|
'bz_product_name', collection
|
||||||
|
)
|
||||||
|
print(f"[NOCHANGE] {package}/{bz_product_name}")
|
||||||
else:
|
else:
|
||||||
# Add component
|
# Add component
|
||||||
data = {
|
data = {
|
||||||
'product': self.config['products'][collection],
|
'product': self.config['products'][collection].get('bz_product_name', collection),
|
||||||
'component': package,
|
'component': package,
|
||||||
'description': description or 'NA',
|
'description': description or 'NA',
|
||||||
'initialowner': owner_email,
|
'initialowner': owner_email,
|
||||||
|
@ -473,22 +476,6 @@ def _get_pdc_branches(session, repo):
|
||||||
return [branch['name'] for branch in data['results']]
|
return [branch['name'] for branch in data['results']]
|
||||||
|
|
||||||
|
|
||||||
def _is_retired(product, project):
|
|
||||||
branches = project['branches']
|
|
||||||
if product == 'Fedora EPEL':
|
|
||||||
for branch, active in branches:
|
|
||||||
if re.match(r'^epel\d+$', branch):
|
|
||||||
if active:
|
|
||||||
return False
|
|
||||||
# No active branches means it is retired.
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
for branch, active in branches:
|
|
||||||
if active:
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class ScriptExecError(RuntimeError):
|
class ScriptExecError(RuntimeError):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
@ -498,6 +485,11 @@ class ScriptExecError(RuntimeError):
|
||||||
|
|
||||||
class DistgitBugzillaSync:
|
class DistgitBugzillaSync:
|
||||||
|
|
||||||
|
# cache placeholders for properties which are computed once
|
||||||
|
_namespace_to_product = None
|
||||||
|
_product_to_branch_regex = None
|
||||||
|
_branch_regex_to_product = None
|
||||||
|
|
||||||
def send_email(self, from_address, to_address, subject, message, cc_address=None):
|
def send_email(self, from_address, to_address, subject, message, cc_address=None):
|
||||||
'''Send an email if there's an error.
|
'''Send an email if there's an error.
|
||||||
|
|
||||||
|
@ -652,6 +644,45 @@ class DistgitBugzillaSync:
|
||||||
watchers=pagure_namespace_to_cc[namespace][name],
|
watchers=pagure_namespace_to_cc[namespace][name],
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def namespace_to_product(self):
|
||||||
|
if self._namespace_to_product is None:
|
||||||
|
self._namespace_to_product = {
|
||||||
|
p['namespace']: n
|
||||||
|
for n, p in self.env['products'].items() if 'namespace' in p
|
||||||
|
}
|
||||||
|
return self._namespace_to_product
|
||||||
|
|
||||||
|
@property
|
||||||
|
def product_to_branch_regex(self):
|
||||||
|
if self._product_to_branch_regex is None:
|
||||||
|
self._product_to_branch_regex = {
|
||||||
|
n: re.compile(p['branch_regex'])
|
||||||
|
for n, p in self.env['products'].items() if 'branch_regex' in p
|
||||||
|
}
|
||||||
|
return self._product_to_branch_regex
|
||||||
|
|
||||||
|
@property
|
||||||
|
def branch_regex_to_product(self):
|
||||||
|
if self._branch_regex_to_product is None:
|
||||||
|
self._branch_regex_to_product = {n: r for r, n in self.product_to_branch_regex.items()}
|
||||||
|
return self._branch_regex_to_product
|
||||||
|
|
||||||
|
def _is_retired(self, product, project):
|
||||||
|
branches = project['branches']
|
||||||
|
branch_regex = self.product_to_branch_regex.get(product)
|
||||||
|
if branch_regex:
|
||||||
|
for branch, active in branches:
|
||||||
|
if branch_regex.match(branch) and active:
|
||||||
|
return False
|
||||||
|
# No active branches means it is retired.
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
for branch, active in branches:
|
||||||
|
if active:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def add_branches_products_and_summaries(self):
|
def add_branches_products_and_summaries(self):
|
||||||
""" For each project retrieved, this method adds branches, products
|
""" For each project retrieved, this method adds branches, products
|
||||||
and summary information.
|
and summary information.
|
||||||
|
@ -699,17 +730,19 @@ class DistgitBugzillaSync:
|
||||||
# Products
|
# Products
|
||||||
products = set()
|
products = set()
|
||||||
for branch, active in project.get('branches'):
|
for branch, active in project.get('branches'):
|
||||||
if re.match(r'^epel\d+$', branch):
|
for regex, product in self.branch_regex_to_product.items():
|
||||||
products.add('Fedora EPEL')
|
if regex.match(branch):
|
||||||
|
products.add(product)
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
products.add(self.env['namespace_to_product'][project['namespace']])
|
products.add(self.namespace_to_product[project['namespace']])
|
||||||
project['products'] = list(products)
|
project['products'] = list(products)
|
||||||
|
|
||||||
products_poc = {}
|
products_poc = {}
|
||||||
for product in products:
|
for product in products:
|
||||||
owner = project["poc"]
|
owner = project["poc"]
|
||||||
# Check if the project is retired in PDC, and if so set assignee to orphan.
|
# Check if the project is retired in PDC, and if so set assignee to orphan.
|
||||||
if _is_retired(product, project):
|
if self._is_retired(product, project):
|
||||||
owner = 'orphan'
|
owner = 'orphan'
|
||||||
|
|
||||||
# Check if the Bugzilla ticket assignee has been manually overridden
|
# Check if the Bugzilla ticket assignee has been manually overridden
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue