CI: Check package dependencies aren’t broken for all modules (#2923)

* CI: Check package dependencies aren’t broken for all modules

* Support allowable pip dep. errors

* Add the reverse dep. error as well
This commit is contained in:
Derek Bekoe 2017-04-20 08:11:14 -07:00 коммит произвёл GitHub
Родитель 35ddb1d088
Коммит 830418680f
2 изменённых файлов: 39 добавлений и 1 удалений

Просмотреть файл

@ -0,0 +1,37 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
"""Verify package dependency compatibility (with support for allowed exceptions). """
from __future__ import print_function
import subprocess
import sys
ALLOWED_ERRORS = [
"has requirement azure-common[autorest]==1.1.4, but you have azure-common 1.1.5.",
"has requirement azure-common~=1.1.5, but you have azure-common 1.1.4."
]
def verify_dependencies():
try:
subprocess.check_output(['pip', 'check'], stderr=subprocess.STDOUT, universal_newlines=True)
except subprocess.CalledProcessError as err:
pip_messages = err.output.splitlines()
errors = []
for msg in pip_messages:
if not any(a in msg for a in ALLOWED_ERRORS):
errors.append(msg)
if errors:
print('Dependency compatibility errors found!', file=sys.stderr)
print('\n'.join(errors), file=sys.stderr)
sys.exit(1)
else:
print("'pip check' returned exit code {} but the errors are allowable.".format(err.returncode), file=sys.stderr)
print("Full output from pip follows:", file=sys.stderr)
print(err.output, file=sys.stderr)
if __name__ == '__main__':
verify_dependencies()

Просмотреть файл

@ -1,10 +1,11 @@
#!/bin/bash
set -e
set -ex
export PYTHONPATH=
virtualenv package-verify-env
. package-verify-env/bin/activate
pip install -e scripts
python -m automation.tests.verify_packages
python -m automation.tests.verify_dependencies
deactivate
# If we get here, all prev. commands returned 0 exit codes so we are done.
rm -rf package-verify-env