Update ATC and approvers scripts for deliverables

In I2aa729d1b4278743a5e99b41178dc2d11b3e1348 the projects.yaml file
of the governance repo was reorganized to support a new
"deliverables" concept which provides a subgrouping of related repos
under each project team. This requires adjustments in the scripts
consuming that file, specifically email_stats.py and
who-approves.py.

Change-Id: I041a62fd86a776279536f003724cb8c289922080
This commit is contained in:
Jeremy Stanley 2015-08-06 15:16:48 +00:00
parent 20e710e3b4
commit ec26e2b988
2 changed files with 28 additions and 26 deletions

View File

@ -164,9 +164,10 @@ def repo_stats(repo, output, begin, end, keyfile, user):
def get_repos(url): def get_repos(url):
projects_yaml = yaml.load(requests.get(url).text) projects_yaml = yaml.load(requests.get(url).text)
repos = [] repos = []
for project in projects_yaml: for team in projects_yaml:
for repo in projects_yaml[project]['projects']: for deliver in projects_yaml[team]['deliverables']:
repos.append(repo['repo']) for repo in projects_yaml[team]['deliverables'][deliver]['repos']:
repos.append(repo)
return repos return repos

View File

@ -17,7 +17,7 @@
# Description: When run using OpenStack's Gerrit server, this builds # Description: When run using OpenStack's Gerrit server, this builds
# JSON and YAML representations of repos with information on the # JSON and YAML representations of repos with information on the
# official owning project if any, integration status, and groups # official owning project team if any, deliverable tags, and groups
# with approve rights listing the members of each along with their # with approve rights listing the members of each along with their
# Gerrit preferred E-mail addresses and usernames when available. # Gerrit preferred E-mail addresses and usernames when available.
@ -59,21 +59,22 @@
# ... # ...
# >>> p = yaml.load(open('approvers.yaml')) # >>> p = yaml.load(open('approvers.yaml'))
# >>> print('Total repos: %s' % len(p)) # >>> print('Total repos: %s' % len(p))
# Total repos: 659 # Total repos: 751
# >>> print('Total approvers: %s' % len(get_approvers(p))) # >>> print('Total approvers: %s' % len(get_approvers(p)))
# Total approvers: 756 # Total approvers: 849
# >>> # >>>
# >>> o = {k: v for k, v in p.iteritems() if 'project' in v} # >>> o = {k: v for k, v in p.iteritems() if 'team' in v}
# >>> print('Repos in official projects: %s' % len(o)) # >>> print('Repos for official teams: %s' % len(o))
# Repos in official projects: 275 # Repos for official teams: 380
# >>> print('OpenStack repo approvers: %s' % len(get_approvers(o))) # >>> print('OpenStack repo approvers: %s' % len(get_approvers(o)))
# OpenStack repo approvers: 339 # OpenStack repo approvers: 456
# >>> # >>>
# >>> i = {k: v for k, v in p.iteritems() if 'integrated' in v} # >>> i = {k: v for k, v in p.iteritems() if 'tags' in v
# >>> print('Repos in the integrated release: %s' % len(i)) # ... and 'release:managed' in v['tags']}
# Repos in the integrated release: 15 # >>> print('Repos under release management: %s' % len(i))
# >>> print('Integrated repo approvers: %s' % len(get_approvers(i))) # Repos under release management: 77
# Integrated repo approvers: 154 # >>> print('Managed release repo approvers: %s' % len(get_approvers(i)))
# Managed release repo approvers: 245
import getpass import getpass
import json import json
@ -111,17 +112,17 @@ for repo in repos_dump:
repos[repo]['approvers'][aprv_group] = [] repos[repo]['approvers'][aprv_group] = []
if aprv_group not in aprv_groups: if aprv_group not in aprv_groups:
aprv_groups[aprv_group] = [] aprv_groups[aprv_group] = []
for project in projects: for team in projects:
if 'projects' in projects[project]: if 'deliverables' in projects[team]:
for repo in projects[project]['projects']: for deli in projects[team]['deliverables']:
if repo['repo'] in repos: if 'repos' in projects[team]['deliverables'][deli]:
repos[repo['repo']]['project'] = project drepos = projects[team]['deliverables'][deli]['repos']
# TODO (fungi): This could be expanded for for repo in drepos:
# additional tags. if repo in repos:
if 'tags' in repo: repos[repo]['team'] = team
for tag in repo['tags']: if 'tags' in projects[team]['deliverables'][deli]:
if tag['name'] == 'integrated-release': repos[repo]['tags'] = \
repos[repo['repo']]['integrated'] = True projects[team]['deliverables'][deli]['tags']
for aprv_group in aprv_groups.keys(): for aprv_group in aprv_groups.keys():
aprv_groups[aprv_group] = json.loads(requests.get( aprv_groups[aprv_group] = json.loads(requests.get(
gerrit_url + group_path % all_groups[aprv_group]['id'], gerrit_url + group_path % all_groups[aprv_group]['id'],