From de4d1f2c19de6a6eb2375aaf708b45f0c7133e25 Mon Sep 17 00:00:00 2001 From: Jason Hu Date: Mon, 1 Apr 2019 07:12:59 -0700 Subject: [PATCH] Config CircleCI workflow (#22590) * Add mypyrc to control typing check, add mypy to circle * Add translation upload circlci job --- .circleci/config.yml | 47 ++++++++++++++++++++++++++++++-------- README.rst | 6 +++-- mypyrc | 21 +++++++++++++++++ script/translations_upload | 3 ++- tox.ini | 2 +- 5 files changed, 66 insertions(+), 13 deletions(-) create mode 100644 mypyrc diff --git a/.circleci/config.yml b/.circleci/config.yml index f9eb28bdf4a..b4f22601bb5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -52,7 +52,7 @@ commands: command: | python3 -m venv venv . venv/bin/activate - pip install -U pip + pip install -q -U pip <<# parameters.all >>pip install -q --progress-bar off -r requirements_all.txt -c homeassistant/package_constraints.txt<> <<# parameters.test >>pip install -q --progress-bar off -r requirements_test.txt -c homeassistant/package_constraints.txt<> <<# parameters.test_all >>pip install -q --progress-bar off -r requirements_test_all.txt -c homeassistant/package_constraints.txt<> @@ -68,28 +68,35 @@ commands: name: install command: | . venv/bin/activate - pip install --progress-bar off -e . + pip install -q --progress-bar off -e . jobs: static-check: executor: name: python - tag: 3.7-stretch + tag: 3.5.5-stretch steps: - checkout - docker-prereqs + - install-requirements: + python: 3.5.5-stretch + test: true - run: name: run static check command: | - python3 -m venv venv . venv/bin/activate - pip install -U pip - pip install --progress-bar off flake8 flake8 + - run: + name: run static type check + command: | + . venv/bin/activate + TYPING_FILES=$(cat mypyrc) + mypy $TYPING_FILES + - install - run: name: run gen_requirements_all @@ -114,7 +121,7 @@ jobs: executor: name: python tag: 3.7-stretch - parallelism: 3 + parallelism: 2 steps: - checkout @@ -154,7 +161,7 @@ jobs: executor: name: python tag: << parameters.python >> - parallelism: 3 + parallelism: 2 steps: - checkout @@ -172,7 +179,6 @@ jobs: if [ -z "$CODE_COVERAGE" ]; then CC_SWITCH=""; else CC_SWITCH="--cov --cov-report html:htmlcov"; fi pytest --timeout=9 --duration=10 --junitxml=test-reports/homeassistant/results.xml -qq -o junit_family=xunit2 -o junit_suite_name=homeassistant -o console_output_style=count -p no:sugar $CC_SWITCH -- ${TESTFILES} script/check_dirty - when: always - store_test_results: path: test-reports @@ -185,6 +191,23 @@ jobs: path: test-reports destination: test-reports + # This job use machine executor, e.g. classic CircleCI VM because we need both lokalise-cli and a Python runtime. + # Classic CircleCI included python 2.7.12 and python 3.5.2 managed by pyenv, the Python version may need change if + # CircleCI changed its VM in future. + upload-translations: + machine: true + + steps: + - checkout + + - run: + name: upload english translations + command: | + pyenv versions + pyenv global 3.5.2 + docker pull lokalise/lokalise-cli@sha256:2198814ebddfda56ee041a4b427521757dd57f75415ea9693696a64c550cef21 + script/translations_upload + workflows: version: 2 build: @@ -222,3 +245,9 @@ workflows: # - test: # name: test 3.8 # python: 3.8-rc-stretch + - upload-translations: + requires: + - static-check + filters: + branches: + only: dev diff --git a/README.rst b/README.rst index f231d6c5514..941a463fb37 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,4 @@ -Home Assistant |Build Status| |Coverage Status| |Chat Status| +Home Assistant |Build Status| |CI Status| |Coverage Status| |Chat Status| ================================================================================= Home Assistant is a home automation platform running on Python 3. It is able to track and control all devices at home and offer a platform for automating control. @@ -27,8 +27,10 @@ components `__ of our website for further help and information. -.. |Build Status| image:: https://travis-ci.org/home-assistant/home-assistant.svg?branch=master +.. |Build Status| image:: https://travis-ci.org/home-assistant/home-assistant.svg?branch=dev :target: https://travis-ci.org/home-assistant/home-assistant +.. |CI Status| image:: https://circleci.com/gh/home-assistant/home-assistant.svg?style=shield + :target: https://circleci.com/gh/home-assistant/home-assistant .. |Coverage Status| image:: https://img.shields.io/coveralls/home-assistant/home-assistant.svg :target: https://coveralls.io/r/home-assistant/home-assistant?branch=master .. |Chat Status| image:: https://img.shields.io/discord/330944238910963714.svg diff --git a/mypyrc b/mypyrc new file mode 100644 index 00000000000..7c73d12e381 --- /dev/null +++ b/mypyrc @@ -0,0 +1,21 @@ +homeassistant/*.py +homeassistant/auth/ +homeassistant/util/ +homeassistant/helpers/__init__.py +homeassistant/helpers/aiohttp_client.py +homeassistant/helpers/area_registry.py +homeassistant/helpers/condition.py +homeassistant/helpers/deprecation.py +homeassistant/helpers/dispatcher.py +homeassistant/helpers/entity_values.py +homeassistant/helpers/entityfilter.py +homeassistant/helpers/icon.py +homeassistant/helpers/intent.py +homeassistant/helpers/json.py +homeassistant/helpers/location.py +homeassistant/helpers/signal.py +homeassistant/helpers/state.py +homeassistant/helpers/sun.py +homeassistant/helpers/temperature.py +homeassistant/helpers/translation.py +homeassistant/helpers/typing.py diff --git a/script/translations_upload b/script/translations_upload index 5bf9fe1e121..52045e41d60 100755 --- a/script/translations_upload +++ b/script/translations_upload @@ -26,7 +26,8 @@ LANG_ISO=en CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) -if [ "${CURRENT_BRANCH-}" != "dev" ] && [ "${TRAVIS_BRANCH-}" != "dev" ] ; then +# Check Travis and CircleCI environment as well +if [ "${CURRENT_BRANCH-}" != "dev" ] && [ "${TRAVIS_BRANCH-}" != "dev" ] && [ "${CIRCLE_BRANCH-}" != "dev" ]; then echo "Please only run the translations upload script from a clean checkout of dev." exit 1 fi diff --git a/tox.ini b/tox.ini index 8423141df60..b8995d9e877 100644 --- a/tox.ini +++ b/tox.ini @@ -42,4 +42,4 @@ deps = -r{toxinidir}/requirements_test.txt -c{toxinidir}/homeassistant/package_constraints.txt commands = - /bin/bash -c 'mypy homeassistant/*.py homeassistant/{auth,util}/ homeassistant/helpers/{__init__,aiohttp_client,area_registry,condition,deprecation,dispatcher,entity_values,entityfilter,icon,intent,json,location,signal,state,sun,temperature,translation,typing}.py' + /bin/bash -c 'TYPING_FILES=$(cat mypyrc); mypy $TYPING_FILES'