Merge "Improve script to check used source versions"

This commit is contained in:
Jenkins 2016-09-08 13:53:34 +00:00 committed by Gerrit Code Review
commit 207bef6abe
3 changed files with 57 additions and 21 deletions

View File

@ -9,6 +9,5 @@ GitPython>=1.0.1 # BSD License (3 clause)
six>=1.9.0 # MIT six>=1.9.0 # MIT
oslo.config>=3.14.0 # Apache-2.0 oslo.config>=3.14.0 # Apache-2.0
graphviz>=0.4.0 # MIT License graphviz>=0.4.0 # MIT License
beautifulsoup4 # MIT
setuptools!=24.0.0,>=16.0 # PSF/ZPL setuptools!=24.0.0,>=16.0 # PSF/ZPL
pycrypto>=2.6 # Public Domain pycrypto>=2.6 # Public Domain

View File

@ -3,12 +3,14 @@
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
bandit>=1.1.0 # Apache-2.0 bandit>=1.1.0 # Apache-2.0
bashate>=0.2 # Apache-2.0 bashate>=0.2 # Apache-2.0
beautifulsoup4 # MIT
doc8 # Apache-2.0 doc8 # Apache-2.0
hacking>=0.10.0 hacking>=0.10.0
oslo.log>=1.14.0 # Apache-2.0 oslo.log>=1.14.0 # Apache-2.0
oslotest>=1.10.0 # Apache-2.0 oslotest>=1.10.0 # Apache-2.0
oslosphinx!=3.4.0,>=2.5.0 # Apache-2.0 oslosphinx!=3.4.0,>=2.5.0 # Apache-2.0
reno>=1.8.0 # Apache2 reno>=1.8.0 # Apache2
PrettyTable>=0.7,<0.8 # BSD
PyYAML>=3.1.0 # MIT PyYAML>=3.1.0 # MIT
python-barbicanclient>=4.0.0 # Apache-2.0 python-barbicanclient>=4.0.0 # Apache-2.0
python-ceilometerclient>=2.5.0 # Apache-2.0 python-ceilometerclient>=2.5.0 # Apache-2.0

View File

@ -13,6 +13,7 @@
# limitations under the License. # limitations under the License.
import collections import collections
import logging
import os import os
import re import re
import sys import sys
@ -20,6 +21,7 @@ import sys
from bs4 import BeautifulSoup as bs from bs4 import BeautifulSoup as bs
from oslo_config import cfg from oslo_config import cfg
import pkg_resources import pkg_resources
from prettytable import PrettyTable
import requests import requests
PROJECT_ROOT = os.path.abspath(os.path.join( PROJECT_ROOT = os.path.abspath(os.path.join(
@ -33,6 +35,9 @@ if PROJECT_ROOT not in sys.path:
from kolla.common import config as common_config from kolla.common import config as common_config
logging.basicConfig(format="%(message)s")
LOG = logging.getLogger('version-check')
# Filter list for non-projects # Filter list for non-projects
NOT_PROJECTS = [ NOT_PROJECTS = [
'nova-novncproxy', 'nova-novncproxy',
@ -50,6 +55,8 @@ def retrieve_upstream_versions():
winner = None winner = None
series = VERSIONS['local'][project].split('.')[0] series = VERSIONS['local'][project].split('.')[0]
base = '{}/{}'.format(TARBALLS_BASE_URL, project) base = '{}/{}'.format(TARBALLS_BASE_URL, project)
LOG.debug("Getting latest version for project %s from %s",
project, base)
r = requests.get(base) r = requests.get(base)
s = bs(r.text, 'html.parser') s = bs(r.text, 'html.parser')
@ -66,26 +73,38 @@ def retrieve_upstream_versions():
winner = candidate winner = candidate
if not winner: if not winner:
print('Could not find version for {}'.format(project)) LOG.warning("Could not find a version for %s", project)
continue continue
if '-' in winner: if '-' in winner:
winner = winner.split('-')[1] winner = winner.split('-')[1]
upstream_versions[project] = winner upstream_versions[project] = winner
LOG.debug("Found latest version %s for project %s", winner, project)
VERSIONS['upstream'] = collections.OrderedDict( VERSIONS['upstream'] = collections.OrderedDict(
sorted(upstream_versions.items())) sorted(upstream_versions.items()))
def retrieve_local_versions(): def retrieve_local_versions(conf):
for section in common_config.SOURCES: for section in common_config.SOURCES:
if section not in NOT_PROJECTS: if section in NOT_PROJECTS:
project = section.split('-')[0] continue
version = common_config.SOURCES[section]['location'].split(
'/')[-1].split('.tar.gz')[0] project = section.split('-')[0]
if '-' in version:
version = version.split('-')[1] if section not in conf.list_all_sections():
VERSIONS['local'][project] = version LOG.debug("Project %s not found in configuration file, using "
"default from kolla.common.config", project)
raw_version = common_config.SOURCES[section]['location']
else:
raw_version = getattr(conf, section).location
version = raw_version.split('/')[-1].split('.tar.gz')[0]
if '-' in version:
version = version.split('-')[1]
LOG.debug("Use local version %s for project %s", version, project)
VERSIONS['local'][project] = version
def more_recent(candidate, reference): def more_recent(candidate, reference):
@ -100,24 +119,40 @@ def diff_link(project, old_ref, new_ref):
def compare_versions(): def compare_versions():
up_to_date = True up_to_date = True
result = PrettyTable(["Project", "Current version",
"Latest version", "Comparing changes"])
result.align = "l"
for project in VERSIONS['upstream']: for project in VERSIONS['upstream']:
if project in VERSIONS['local']: if project not in VERSIONS['local']:
upstream_version = VERSIONS['upstream'][project] continue
local_version = VERSIONS['local'][project]
if more_recent(upstream_version, local_version): upstream_version = VERSIONS['upstream'][project]
print("{} has newer version {} > {}, see diff at {}".format( local_version = VERSIONS['local'][project]
project, upstream_version, local_version,
diff_link(project, local_version, upstream_version))) if more_recent(upstream_version, local_version):
up_to_date = False result.add_row([
project,
VERSIONS['local'][project],
VERSIONS['upstream'][project],
diff_link(project, local_version, upstream_version)
])
up_to_date = False
if up_to_date: if up_to_date:
print("Everything is up to date") result = "Everything is up to date"
print(result)
def main(): def main():
conf = cfg.ConfigOpts() conf = cfg.ConfigOpts()
common_config.parse(conf, sys.argv[1:], prog='kolla-build') common_config.parse(conf, sys.argv[1:], prog='version-check')
retrieve_local_versions() if conf.debug:
LOG.setLevel(logging.DEBUG)
retrieve_local_versions(conf)
retrieve_upstream_versions() retrieve_upstream_versions()
compare_versions() compare_versions()