Verify requirements_all in Travis

This commit is contained in:
Paulus Schoutsen 2015-12-17 23:51:34 -08:00
parent a0ff8819a9
commit b5fc7f5e71
4 changed files with 25 additions and 8 deletions

View File

@ -5,6 +5,8 @@ python:
- 3.4 - 3.4
- 3.5 - 3.5
install: install:
- python3 setup.py -q develop
- script/gen_requirements_all.py validate
- script/bootstrap_server - script/bootstrap_server
script: script:
- script/cibuild - script/cibuild

View File

@ -1,4 +1,5 @@
echo "Bootstrapping frontend..." echo "Bootstrapping frontend..."
git submodule update
cd homeassistant/components/frontend/www_static/home-assistant-polymer cd homeassistant/components/frontend/www_static/home-assistant-polymer
npm install npm install
bower install bower install

View File

@ -1,15 +1,12 @@
cd "$(dirname "$0")/.." cd "$(dirname "$0")/.."
echo "Update the submodule to latest version..."
git submodule update
echo "Installing dependencies..." echo "Installing dependencies..."
python3 -m pip install --upgrade -r requirements_all.txt python3 -m pip install -q -r requirements_all.txt
REQ_STATUS=$? REQ_STATUS=$?
echo "Installing development dependencies.." echo "Installing development dependencies.."
python3 -m pip install --upgrade flake8 pylint coveralls pytest pytest-cov python3 -m pip install -q flake8 pylint coveralls pytest pytest-cov
REQ_DEV_STATUS=$? REQ_DEV_STATUS=$?

View File

@ -8,6 +8,7 @@ import importlib
import os import os
import pkgutil import pkgutil
import re import re
import sys
COMMENT_REQUIREMENTS = [ COMMENT_REQUIREMENTS = [
'RPi.GPIO', 'RPi.GPIO',
@ -68,8 +69,9 @@ def gather_modules():
reqs.setdefault(req, []).append(package) reqs.setdefault(req, []).append(package)
if errors: if errors:
print("Found errors") print("******* ERROR")
print('\n'.join(errors)) print("Errors while importing: ", ', '.join(errors))
print("Make sure you import 3rd party libraries inside methods.")
return None return None
output.append('# Home Assistant core') output.append('# Home Assistant core')
@ -95,6 +97,12 @@ def write_file(data):
req_file.write(data) req_file.write(data)
def validate_file(data):
""" Validates if requirements_all.txt is up to date. """
with open('requirements_all.txt', 'r') as req_file:
return data == ''.join(req_file)
def main(): def main():
""" Main """ """ Main """
if not os.path.isfile('requirements_all.txt'): if not os.path.isfile('requirements_all.txt'):
@ -104,7 +112,16 @@ def main():
data = gather_modules() data = gather_modules()
if data is None: if data is None:
return sys.exit(1)
if sys.argv[-1] == 'validate':
if validate_file(data):
print("requirements_all.txt is up to date.")
sys.exit(0)
print("******* ERROR")
print("requirements_all.txt is not up to date")
print("Please run script/gen_requirements_all.py")
sys.exit(1)
write_file(data) write_file(data)