9f49dbbc2e
The release:has-stable-branch is useless and should be retired: - The git repository is the true source of information whether a given repo has stable branches or not. The tag is therefore redundant, and often inaccurate (since it's not necessarily updated when a project creates stable branches). - Having "stable" branches does not mean that the repository applies the common stable branch maintenance policy. This tag therefore does not convey any useful information for our downstream users. Whether a project follows stable policy or not is now described using the stable:follows-policy tag. Change-Id: I7d7d24db0de4728977218f9b7fadc060f69c2e55
101 lines
3.1 KiB
Python
Executable File
101 lines
3.1 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
""" validate tag applications in projects.yaml
|
|
|
|
Validate the application of tags that can be pragmatically applied.
|
|
|
|
Note: Does not automatically update projects.yaml since doing so can reformat
|
|
and reorder projects.yaml
|
|
|
|
"""
|
|
|
|
import teamstats
|
|
|
|
import requests
|
|
import yaml
|
|
|
|
import os
|
|
import sys
|
|
|
|
from six.moves.urllib import parse
|
|
# List of modules to validate team based tags
|
|
team_validators = [
|
|
teamstats.ValidateDiversity,
|
|
teamstats.ValidateSingleVendor,
|
|
]
|
|
|
|
# List of modules to validate repository based tags
|
|
repo_validators = [ ]
|
|
|
|
|
|
def main():
|
|
script_path = os.path.abspath(os.path.dirname(__file__))
|
|
filename = os.path.abspath(os.path.join(script_path,
|
|
'../reference/projects.yaml'))
|
|
if not os.path.isfile(filename):
|
|
sys.exit("Projects.yaml was not found at %s" % (filename))
|
|
with open(filename, 'r') as f:
|
|
teams = yaml.load(f.read())
|
|
for team in teams:
|
|
# Check team based tags
|
|
for validator in team_validators:
|
|
validate(team, teams[team], validator)
|
|
# Check deliverable based tags
|
|
for name, deliverable in teams[team]['deliverables'].items():
|
|
for repo in deliverable['repos']:
|
|
if not repo_exists(repo):
|
|
continue
|
|
for validator in repo_validators:
|
|
validate(repo, deliverable, validator)
|
|
|
|
|
|
def validate(name, data, validator):
|
|
tag_name = validator.get_tag_name()
|
|
contains_tag = any([tag_name == tag for tag in
|
|
data.get('tags', [])])
|
|
if validator.validate(name):
|
|
# should contain tag
|
|
if not contains_tag:
|
|
print_tag_missing(name, tag_name)
|
|
else:
|
|
# should not contain tag
|
|
if contains_tag:
|
|
print_bad_tag(name, tag_name)
|
|
|
|
|
|
def repo_exists(repo):
|
|
"""Sometimes the governance docs can get out of sync with repo names."""
|
|
response = requests.get(
|
|
'https://review.openstack.org:443/projects/%s/' %
|
|
parse.quote_plus(repo))
|
|
# strip off first few chars because 'the JSON response body starts with
|
|
# a magic prefix line that must be stripped before feeding the rest of
|
|
# the response body to a JSON parser'
|
|
# https://review.openstack.org/Documentation/rest-api.html
|
|
if response.status_code == 404:
|
|
return False
|
|
return True
|
|
|
|
|
|
def print_tag_missing(name, tag):
|
|
print ("* %s should have the tag '%s'" % (name, tag))
|
|
|
|
|
|
def print_bad_tag(name, tag):
|
|
print ("* %s should not have the tag '%s'" % (name, tag))
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main())
|