|
| 1 | +# Python CircleCI 2.0 configuration file |
| 2 | +# |
| 3 | +# Check https://circleci.com/docs/2.0/language-python/ for more details |
| 4 | +# Initially made by copying homeassistant circleci config. |
| 5 | +version: 2.1 |
| 6 | + |
| 7 | +executors: |
| 8 | + |
| 9 | + python: |
| 10 | + parameters: |
| 11 | + tag: |
| 12 | + type: string |
| 13 | + default: latest |
| 14 | + docker: |
| 15 | + - image: circleci/python:<< parameters.tag >> |
| 16 | + - image: circleci/buildpack-deps:stretch |
| 17 | + working_directory: ~/repo |
| 18 | + |
| 19 | +commands: |
| 20 | + |
| 21 | + docker-prereqs: |
| 22 | + description: Set up docker prerequisite requirement |
| 23 | + steps: |
| 24 | + - run: sudo apt-get update && sudo apt-get install -y --no-install-recommends |
| 25 | + libudev-dev libavformat-dev libavcodec-dev libavdevice-dev libavutil-dev |
| 26 | + libswscale-dev libswresample-dev libavfilter-dev |
| 27 | + |
| 28 | + install-requirements: |
| 29 | + description: Set up venv and install requirements python packages with cache support |
| 30 | + parameters: |
| 31 | + python: |
| 32 | + type: string |
| 33 | + default: latest |
| 34 | + all: |
| 35 | + description: pip install -r requirements.txt |
| 36 | + type: boolean |
| 37 | + default: false |
| 38 | + test: |
| 39 | + description: pip install -r requirements_test_all.txt |
| 40 | + type: boolean |
| 41 | + default: false |
| 42 | + steps: |
| 43 | + - restore_cache: |
| 44 | + keys: |
| 45 | + - v1-<< parameters.python >>-{{ checksum "homeassistant_cli/package_constraints.txt" }}-<<# parameters.all >>{{ checksum "requirements.txt" }}<</ parameters.all>>-<<# parameters.test >>{{ checksum "requirements_test_all.txt" }}<</ parameters.test>> |
| 46 | + - run: |
| 47 | + name: install dependencies |
| 48 | + command: | |
| 49 | + python3 -m venv venv |
| 50 | + . venv/bin/activate |
| 51 | + pip install -q -U pip |
| 52 | + pip install -q -U setuptools |
| 53 | + <<# parameters.all >>pip install -q --progress-bar off -r requirements.txt -c homeassistant_cli/package_constraints.txt<</ parameters.all>> |
| 54 | + <<# parameters.test >>pip install -q --progress-bar off -r requirements_test_all.txt -c homeassistant_cli/package_constraints.txt<</ parameters.test>> |
| 55 | + no_output_timeout: 15m |
| 56 | + - save_cache: |
| 57 | + paths: |
| 58 | + - ./venv |
| 59 | + key: v1-<< parameters.python >>-{{ checksum "homeassistant_cli/package_constraints.txt" }}-<<# parameters.all >>{{ checksum "requirements.txt" }}<</ parameters.all>>-<<# parameters.test >>{{ checksum "requirements_test_all.txt" }}<</ parameters.test>> |
| 60 | + |
| 61 | + install: |
| 62 | + description: Install Home Assistant CLI |
| 63 | + steps: |
| 64 | + - run: |
| 65 | + name: install |
| 66 | + command: | |
| 67 | + . venv/bin/activate |
| 68 | + pip install -q --progress-bar off -e . |
| 69 | +
|
| 70 | +jobs: |
| 71 | + |
| 72 | + static-check: |
| 73 | + executor: |
| 74 | + name: python |
| 75 | + tag: 3.5.5-stretch |
| 76 | + |
| 77 | + steps: |
| 78 | + - checkout |
| 79 | + - docker-prereqs |
| 80 | + - install-requirements: |
| 81 | + python: 3.5.5-stretch |
| 82 | + test: true |
| 83 | + |
| 84 | + - run: |
| 85 | + name: run static check |
| 86 | + command: | |
| 87 | + . venv/bin/activate |
| 88 | + flake8 homeassistant_cli tests script |
| 89 | +
|
| 90 | + - run: |
| 91 | + name: run static type check |
| 92 | + command: | |
| 93 | + . venv/bin/activate |
| 94 | + TYPING_FILES=$(cat mypyrc) |
| 95 | + mypy $TYPING_FILES |
| 96 | +
|
| 97 | + - install |
| 98 | + |
| 99 | + pre-install-all-requirements: |
| 100 | + executor: |
| 101 | + name: python |
| 102 | + tag: 3.5.5-stretch |
| 103 | + |
| 104 | + steps: |
| 105 | + - checkout |
| 106 | + - docker-prereqs |
| 107 | + - install-requirements: |
| 108 | + python: 3.5.5-stretch |
| 109 | + all: true |
| 110 | + test: true |
| 111 | + |
| 112 | + pylint: |
| 113 | + executor: |
| 114 | + name: python |
| 115 | + tag: 3.5.5-stretch |
| 116 | + parallelism: 2 |
| 117 | + |
| 118 | + steps: |
| 119 | + - checkout |
| 120 | + - docker-prereqs |
| 121 | + - install-requirements: |
| 122 | + python: 3.5.5-stretch |
| 123 | + all: true |
| 124 | + test: true |
| 125 | + - install |
| 126 | + |
| 127 | + - run: |
| 128 | + name: run pylint |
| 129 | + command: | |
| 130 | + . venv/bin/activate |
| 131 | + PYFILES=$(circleci tests glob "homeassistant_cli/**/*.py" | circleci tests split) |
| 132 | + pylint ${PYFILES} |
| 133 | + no_output_timeout: 15m |
| 134 | + |
| 135 | + pre-test: |
| 136 | + parameters: |
| 137 | + python: |
| 138 | + type: string |
| 139 | + executor: |
| 140 | + name: python |
| 141 | + tag: << parameters.python >> |
| 142 | + |
| 143 | + steps: |
| 144 | + - checkout |
| 145 | + - docker-prereqs |
| 146 | + - install-requirements: |
| 147 | + python: << parameters.python >> |
| 148 | + test: true |
| 149 | + |
| 150 | + test: |
| 151 | + parameters: |
| 152 | + python: |
| 153 | + type: string |
| 154 | + executor: |
| 155 | + name: python |
| 156 | + tag: << parameters.python >> |
| 157 | + parallelism: 2 |
| 158 | + |
| 159 | + steps: |
| 160 | + - checkout |
| 161 | + - docker-prereqs |
| 162 | + - install-requirements: |
| 163 | + python: << parameters.python >> |
| 164 | + test: true |
| 165 | + - install |
| 166 | + |
| 167 | + - run: |
| 168 | + name: run tests with code coverage |
| 169 | + command: | |
| 170 | + . venv/bin/activate |
| 171 | + CC_SWITCH="--cov --cov-report=" |
| 172 | + TESTFILES=$(circleci tests glob "tests/**/test_*.py" | circleci tests split --split-by=timings) |
| 173 | + pytest --timeout=9 --durations=10 --junitxml=test-reports/homeassistant_cli/results.xml -qq -o junit_family=xunit2 -o junit_suite_name=homeassistant-cli -o console_output_style=count -p no:sugar $CC_SWITCH -- ${TESTFILES} |
| 174 | + script/check_dirty |
| 175 | + codecov |
| 176 | +
|
| 177 | + - store_test_results: |
| 178 | + path: test-reports |
| 179 | + |
| 180 | + - store_artifacts: |
| 181 | + path: htmlcov |
| 182 | + destination: cov-reports |
| 183 | + |
| 184 | + - store_artifacts: |
| 185 | + path: test-reports |
| 186 | + destination: test-reports |
| 187 | + |
| 188 | +workflows: |
| 189 | + version: 2 |
| 190 | + build: |
| 191 | + jobs: |
| 192 | + - static-check |
| 193 | + - pre-install-all-requirements: |
| 194 | + requires: |
| 195 | + - static-check |
| 196 | + - pylint: |
| 197 | + requires: |
| 198 | + - pre-install-all-requirements |
| 199 | + - pre-test: |
| 200 | + name: pre-test 3.5.5 |
| 201 | + requires: |
| 202 | + - static-check |
| 203 | + python: 3.5.5-stretch |
| 204 | + - pre-test: |
| 205 | + name: pre-test 3.6 |
| 206 | + requires: |
| 207 | + - static-check |
| 208 | + python: 3.6-stretch |
| 209 | + - pre-test: |
| 210 | + name: pre-test 3.7 |
| 211 | + requires: |
| 212 | + - static-check |
| 213 | + python: 3.7-stretch |
| 214 | + - test: |
| 215 | + name: test 3.5.5 |
| 216 | + requires: |
| 217 | + - pre-test 3.5.5 |
| 218 | + python: 3.5.5-stretch |
| 219 | + - test: |
| 220 | + name: test 3.6 |
| 221 | + requires: |
| 222 | + - pre-test 3.6 |
| 223 | + python: 3.6-stretch |
| 224 | + - test: |
| 225 | + name: test 3.7 |
| 226 | + requires: |
| 227 | + - pre-test 3.7 |
| 228 | + python: 3.7-stretch |
| 229 | + # CircleCI does not allow failure yet |
| 230 | + # - test: |
| 231 | + # name: test 3.8 |
| 232 | + # python: 3.8-rc-stretch |
0 commit comments