Skip to content

Commit

Permalink
A very basic Circleci setup (home-assistant#22503)
Browse files Browse the repository at this point in the history
* Add circleci support

* Add buildpack-deps

* Install libudev-dev

* sudo

* always run test

* Add test report

* no sugar

* quite pytest

* better junit test result

* Add $CODE_COVERAGE env var
  • Loading branch information
awarecan authored and balloob committed Mar 28, 2019
1 parent 8d86722 commit 59476ab
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
79 changes: 79 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Python CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-python/ for more details
#
version: 2.1
jobs:
build:
docker:
# specify the version you desire here
# use `-browsers` prefix for selenium tests, e.g. `3.6.1-browsers`
- image: circleci/python:3.7.2

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/postgres:9.4
- image: circleci/buildpack-deps:stretch

working_directory: ~/repo

steps:
- checkout

- run:
name: setup docker prereqs
command: sudo apt-get update && sudo apt-get install -y --no-install-recommends libudev-dev

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "requirements_all.txt" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run:
name: install dependencies
command: |
python3 -m venv venv
. venv/bin/activate
pip install --progress-bar off -r requirements_all.txt -r requirements_test.txt -c homeassistant/package_constraints.txt
- save_cache:
paths:
- ./venv
key: v1-dependencies-{{ checksum "requirements_all.txt" }}

- run:
name: install
command: |
. venv/bin/activate
pip install --progress-bar off -e .
- run:
name: run lint
command: |
. venv/bin/activate
python script/gen_requirements_all.py validate
flake8
pylint homeassistant
- run:
name: run tests
command: |
. venv/bin/activate
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
script/check_dirty
when: always

- store_test_results:
path: test-reports

- store_artifacts:
path: htmlcov
destination: cov-reports

- store_artifacts:
path: test-reports
destination: test-reports
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pip-log.txt
.tox
nosetests.xml
htmlcov/
test-reports/

# Translations
*.mo
Expand Down

0 comments on commit 59476ab

Please sign in to comment.