aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-09-08 13:53:34 +0000
committerGerrit Code Review <review@openstack.org>2016-09-08 13:53:34 +0000
commit207bef6abe93a572b90403218c5b2bcfec330383 (patch)
treef27b44fac40e4a1464dc3ae0bcf46187d9bb4cb5
parent052da60bebd9a707d78f3976b3469f88ed1e81a8 (diff)
parent4b69671a490940393e5fd7d6cbefb0e462de0cfa (diff)
downloadkolla-207bef6abe93a572b90403218c5b2bcfec330383.tar.gz
kolla-207bef6abe93a572b90403218c5b2bcfec330383.zip
Merge "Improve script to check used source versions"
-rw-r--r--requirements.txt1
-rw-r--r--test-requirements.txt2
-rwxr-xr-xtools/version-check.py (renamed from tools/version_check.py)75
3 files changed, 57 insertions, 21 deletions
diff --git a/requirements.txt b/requirements.txt
index c5a8637eb..853a69257 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -9,6 +9,5 @@ GitPython>=1.0.1 # BSD License (3 clause)
six>=1.9.0 # MIT
oslo.config>=3.14.0 # Apache-2.0
graphviz>=0.4.0 # MIT License
-beautifulsoup4 # MIT
setuptools!=24.0.0,>=16.0 # PSF/ZPL
pycrypto>=2.6 # Public Domain
diff --git a/test-requirements.txt b/test-requirements.txt
index 3a8d60e95..54be295da 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -3,12 +3,14 @@
# process, which may cause wedges in the gate later.
bandit>=1.1.0 # Apache-2.0
bashate>=0.2 # Apache-2.0
+beautifulsoup4 # MIT
doc8 # Apache-2.0
hacking>=0.10.0
oslo.log>=1.14.0 # Apache-2.0
oslotest>=1.10.0 # Apache-2.0
oslosphinx!=3.4.0,>=2.5.0 # Apache-2.0
reno>=1.8.0 # Apache2
+PrettyTable>=0.7,<0.8 # BSD
PyYAML>=3.1.0 # MIT
python-barbicanclient>=4.0.0 # Apache-2.0
python-ceilometerclient>=2.5.0 # Apache-2.0
diff --git a/tools/version_check.py b/tools/version-check.py
index 176845ca0..a20d14b79 100755
--- a/tools/version_check.py
+++ b/tools/version-check.py
@@ -13,6 +13,7 @@
# limitations under the License.
import collections
+import logging
import os
import re
import sys
@@ -20,6 +21,7 @@ import sys
from bs4 import BeautifulSoup as bs
from oslo_config import cfg
import pkg_resources
+from prettytable import PrettyTable
import requests
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
+logging.basicConfig(format="%(message)s")
+LOG = logging.getLogger('version-check')
+
# Filter list for non-projects
NOT_PROJECTS = [
'nova-novncproxy',
@@ -50,6 +55,8 @@ def retrieve_upstream_versions():
winner = None
series = VERSIONS['local'][project].split('.')[0]
base = '{}/{}'.format(TARBALLS_BASE_URL, project)
+ LOG.debug("Getting latest version for project %s from %s",
+ project, base)
r = requests.get(base)
s = bs(r.text, 'html.parser')
@@ -66,26 +73,38 @@ def retrieve_upstream_versions():
winner = candidate
if not winner:
- print('Could not find version for {}'.format(project))
+ LOG.warning("Could not find a version for %s", project)
continue
if '-' in winner:
winner = winner.split('-')[1]
upstream_versions[project] = winner
+ LOG.debug("Found latest version %s for project %s", winner, project)
VERSIONS['upstream'] = collections.OrderedDict(
sorted(upstream_versions.items()))
-def retrieve_local_versions():
+def retrieve_local_versions(conf):
for section in common_config.SOURCES:
- if section not in NOT_PROJECTS:
- project = section.split('-')[0]
- version = common_config.SOURCES[section]['location'].split(
- '/')[-1].split('.tar.gz')[0]
- if '-' in version:
- version = version.split('-')[1]
- VERSIONS['local'][project] = version
+ if section in NOT_PROJECTS:
+ continue
+
+ project = section.split('-')[0]
+
+ if section not in conf.list_all_sections():
+ 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):
@@ -100,24 +119,40 @@ def diff_link(project, old_ref, new_ref):
def compare_versions():
up_to_date = True
+ result = PrettyTable(["Project", "Current version",
+ "Latest version", "Comparing changes"])
+ result.align = "l"
+
for project in VERSIONS['upstream']:
- if project in VERSIONS['local']:
- upstream_version = VERSIONS['upstream'][project]
- local_version = VERSIONS['local'][project]
- if more_recent(upstream_version, local_version):
- print("{} has newer version {} > {}, see diff at {}".format(
- project, upstream_version, local_version,
- diff_link(project, local_version, upstream_version)))
- up_to_date = False
+ if project not in VERSIONS['local']:
+ continue
+
+ upstream_version = VERSIONS['upstream'][project]
+ local_version = VERSIONS['local'][project]
+
+ if more_recent(upstream_version, local_version):
+ 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:
- print("Everything is up to date")
+ result = "Everything is up to date"
+
+ print(result)
def main():
conf = cfg.ConfigOpts()
- common_config.parse(conf, sys.argv[1:], prog='kolla-build')
+ common_config.parse(conf, sys.argv[1:], prog='version-check')
+
+ if conf.debug:
+ LOG.setLevel(logging.DEBUG)
- retrieve_local_versions()
+ retrieve_local_versions(conf)
retrieve_upstream_versions()
compare_versions()