From b5fc7f5e718e66f52e57c4d5128722047563c12e Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 17 Dec 2015 23:51:34 -0800 Subject: [PATCH 1/4] Verify requirements_all in Travis --- .travis.yml | 2 ++ script/bootstrap_frontend | 1 + script/bootstrap_server | 7 ++----- script/gen_requirements_all.py | 23 ++++++++++++++++++++--- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index e6097966c9e..66d002f9a40 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,8 @@ python: - 3.4 - 3.5 install: + - python3 setup.py -q develop + - script/gen_requirements_all.py validate - script/bootstrap_server script: - script/cibuild diff --git a/script/bootstrap_frontend b/script/bootstrap_frontend index 5bc3baf38c9..346dee31f62 100755 --- a/script/bootstrap_frontend +++ b/script/bootstrap_frontend @@ -1,4 +1,5 @@ echo "Bootstrapping frontend..." +git submodule update cd homeassistant/components/frontend/www_static/home-assistant-polymer npm install bower install diff --git a/script/bootstrap_server b/script/bootstrap_server index ff7ada2ff91..6a872dad151 100755 --- a/script/bootstrap_server +++ b/script/bootstrap_server @@ -1,15 +1,12 @@ cd "$(dirname "$0")/.." -echo "Update the submodule to latest version..." -git submodule update - echo "Installing dependencies..." -python3 -m pip install --upgrade -r requirements_all.txt +python3 -m pip install -q -r requirements_all.txt REQ_STATUS=$? 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=$? diff --git a/script/gen_requirements_all.py b/script/gen_requirements_all.py index 59bffeee756..c897bf19aa7 100755 --- a/script/gen_requirements_all.py +++ b/script/gen_requirements_all.py @@ -8,6 +8,7 @@ import importlib import os import pkgutil import re +import sys COMMENT_REQUIREMENTS = [ 'RPi.GPIO', @@ -68,8 +69,9 @@ def gather_modules(): reqs.setdefault(req, []).append(package) if errors: - print("Found errors") - print('\n'.join(errors)) + print("******* ERROR") + print("Errors while importing: ", ', '.join(errors)) + print("Make sure you import 3rd party libraries inside methods.") return None output.append('# Home Assistant core') @@ -95,6 +97,12 @@ def write_file(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(): """ Main """ if not os.path.isfile('requirements_all.txt'): @@ -104,7 +112,16 @@ def main(): data = gather_modules() 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) From 9dca22aa278f2979f2cf9503c3f5a9ebbbbe3f19 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 18 Dec 2015 00:09:33 -0800 Subject: [PATCH 2/4] Only lint on Python 3.4 --- script/cibuild | 6 ++++++ script/test | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/script/cibuild b/script/cibuild index bd8ac963429..778cbe0db52 100755 --- a/script/cibuild +++ b/script/cibuild @@ -5,6 +5,12 @@ cd "$(dirname "$0")/.." +if [ "$TRAVIS_PYTHON_VERSION" != "3.4" ]; then + NO_LINT=1 +fi + +export NO_LINT + script/test coverage STATUS=$? diff --git a/script/test b/script/test index d407f57a338..25873492001 100755 --- a/script/test +++ b/script/test @@ -5,9 +5,12 @@ cd "$(dirname "$0")/.." -script/lint - -LINT_STATUS=$? +if [ "$NO_LINT" = "1" ]; then + LINT_STATUS=0 +else + script/lint + LINT_STATUS=$? +fi echo "Running tests..." From dd60cc020efac553e7f5636039dd7fe7558e694e Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 18 Dec 2015 00:19:14 -0800 Subject: [PATCH 3/4] Only validate requirements_all.txt on Python 3.5 --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 66d002f9a40..208084bf95b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,8 @@ python: - 3.4 - 3.5 install: - - python3 setup.py -q develop - - script/gen_requirements_all.py validate + # Validate requirements_all.txt on Python 3.5 + - if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then python3 setup.py -q develop; script/gen_requirements_all.py validate; fi - script/bootstrap_server script: - script/cibuild From 2e75f0b314d172784e0b1e64f615b8f116f28511 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 18 Dec 2015 00:35:53 -0800 Subject: [PATCH 4/4] Remove quiet pip installs on travis --- .travis.yml | 2 +- script/bootstrap_server | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 208084bf95b..c4f482d757f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ python: - 3.5 install: # Validate requirements_all.txt on Python 3.5 - - if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then python3 setup.py -q develop; script/gen_requirements_all.py validate; fi + - if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then python3 setup.py develop; script/gen_requirements_all.py validate; fi - script/bootstrap_server script: - script/cibuild diff --git a/script/bootstrap_server b/script/bootstrap_server index 6a872dad151..a5533b0596d 100755 --- a/script/bootstrap_server +++ b/script/bootstrap_server @@ -1,12 +1,12 @@ cd "$(dirname "$0")/.." echo "Installing dependencies..." -python3 -m pip install -q -r requirements_all.txt +python3 -m pip install -r requirements_all.txt REQ_STATUS=$? echo "Installing development dependencies.." -python3 -m pip install -q flake8 pylint coveralls pytest pytest-cov +python3 -m pip install flake8 pylint coveralls pytest pytest-cov REQ_DEV_STATUS=$?