mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Test only dependencies (#7472)
* Generate requirements file for tests * Update tox * Update validate * Lint * Tweak order in travis.yml to run longest job first
This commit is contained in:
parent
305309a59e
commit
aa6339818e
@ -6,12 +6,10 @@ addons:
|
|||||||
matrix:
|
matrix:
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
include:
|
include:
|
||||||
- python: "3.4.2"
|
|
||||||
env: TOXENV=py34
|
|
||||||
- python: "3.4.2"
|
|
||||||
env: TOXENV=requirements
|
|
||||||
- python: "3.4.2"
|
- python: "3.4.2"
|
||||||
env: TOXENV=lint
|
env: TOXENV=lint
|
||||||
|
- python: "3.4.2"
|
||||||
|
env: TOXENV=py34
|
||||||
# - python: "3.5"
|
# - python: "3.5"
|
||||||
# env: TOXENV=typing
|
# env: TOXENV=typing
|
||||||
- python: "3.5"
|
- python: "3.5"
|
||||||
@ -20,6 +18,8 @@ matrix:
|
|||||||
env: TOXENV=py36
|
env: TOXENV=py36
|
||||||
- python: "3.6-dev"
|
- python: "3.6-dev"
|
||||||
env: TOXENV=py36
|
env: TOXENV=py36
|
||||||
|
- python: "3.4.2"
|
||||||
|
env: TOXENV=requirements
|
||||||
# allow_failures:
|
# allow_failures:
|
||||||
# - python: "3.5"
|
# - python: "3.5"
|
||||||
# env: TOXENV=typing
|
# env: TOXENV=typing
|
||||||
|
161
requirements_test_all.txt
Normal file
161
requirements_test_all.txt
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
# Home Assistant test
|
||||||
|
# linters such as flake8 and pylint should be pinned, as new releases
|
||||||
|
# make new things fail. Manually update these pins when pulling in a
|
||||||
|
# new version
|
||||||
|
flake8==3.3
|
||||||
|
pylint==1.6.5
|
||||||
|
mypy==0.501
|
||||||
|
pydocstyle==1.1.1
|
||||||
|
coveralls>=1.1
|
||||||
|
pytest>=2.9.2
|
||||||
|
pytest-aiohttp>=0.1.3
|
||||||
|
pytest-asyncio>=0.5.0
|
||||||
|
pytest-cov>=2.3.1
|
||||||
|
pytest-timeout>=1.2.0
|
||||||
|
pytest-catchlog>=1.2.2
|
||||||
|
pytest-sugar>=0.7.1
|
||||||
|
requests_mock>=1.0
|
||||||
|
mock-open>=1.3.1
|
||||||
|
flake8-docstrings==1.0.2
|
||||||
|
asynctest>=0.8.0
|
||||||
|
freezegun>=0.3.8
|
||||||
|
|
||||||
|
|
||||||
|
# homeassistant.components.notify.html5
|
||||||
|
PyJWT==1.4.2
|
||||||
|
|
||||||
|
# homeassistant.components.media_player.sonos
|
||||||
|
SoCo==0.12
|
||||||
|
|
||||||
|
# homeassistant.components.device_tracker.automatic
|
||||||
|
aioautomatic==0.3.1
|
||||||
|
|
||||||
|
# homeassistant.components.emulated_hue
|
||||||
|
# homeassistant.components.http
|
||||||
|
aiohttp_cors==0.5.3
|
||||||
|
|
||||||
|
# homeassistant.components.notify.apns
|
||||||
|
apns2==0.1.1
|
||||||
|
|
||||||
|
# homeassistant.components.sun
|
||||||
|
# homeassistant.components.sensor.moon
|
||||||
|
astral==1.4
|
||||||
|
|
||||||
|
# homeassistant.components.datadog
|
||||||
|
datadog==0.15.0
|
||||||
|
|
||||||
|
# homeassistant.components.sensor.dsmr
|
||||||
|
dsmr_parser==0.8
|
||||||
|
|
||||||
|
# homeassistant.components.climate.honeywell
|
||||||
|
evohomeclient==0.2.5
|
||||||
|
|
||||||
|
# homeassistant.components.media_player.frontier_silicon
|
||||||
|
fsapi==0.0.7
|
||||||
|
|
||||||
|
# homeassistant.components.conversation
|
||||||
|
fuzzywuzzy==0.15.0
|
||||||
|
|
||||||
|
# homeassistant.components.tts.google
|
||||||
|
gTTS-token==1.1.1
|
||||||
|
|
||||||
|
# homeassistant.components.ffmpeg
|
||||||
|
ha-ffmpeg==1.5
|
||||||
|
|
||||||
|
# homeassistant.components.mqtt.server
|
||||||
|
hbmqtt==0.8
|
||||||
|
|
||||||
|
# homeassistant.components.binary_sensor.workday
|
||||||
|
holidays==0.8.1
|
||||||
|
|
||||||
|
# homeassistant.components.influxdb
|
||||||
|
# homeassistant.components.sensor.influxdb
|
||||||
|
influxdb==3.0.0
|
||||||
|
|
||||||
|
# homeassistant.components.media_player.soundtouch
|
||||||
|
libsoundtouch==0.3.0
|
||||||
|
|
||||||
|
# homeassistant.components.sensor.mfi
|
||||||
|
# homeassistant.components.switch.mfi
|
||||||
|
mficlient==0.3.0
|
||||||
|
|
||||||
|
# homeassistant.components.tts
|
||||||
|
mutagen==1.37.0
|
||||||
|
|
||||||
|
# homeassistant.components.discovery
|
||||||
|
netdisco==1.0.0rc3
|
||||||
|
|
||||||
|
# homeassistant.components.mqtt
|
||||||
|
paho-mqtt==1.2.3
|
||||||
|
|
||||||
|
# homeassistant.components.device_tracker.aruba
|
||||||
|
# homeassistant.components.device_tracker.asuswrt
|
||||||
|
# homeassistant.components.device_tracker.cisco_ios
|
||||||
|
# homeassistant.components.media_player.pandora
|
||||||
|
pexpect==4.0.1
|
||||||
|
|
||||||
|
# homeassistant.components.pilight
|
||||||
|
pilight==0.1.1
|
||||||
|
|
||||||
|
# homeassistant.components.sensor.mhz19
|
||||||
|
# homeassistant.components.sensor.serial_pm
|
||||||
|
pmsensor==0.4
|
||||||
|
|
||||||
|
# homeassistant.components.media_player.cast
|
||||||
|
pychromecast==0.8.1
|
||||||
|
|
||||||
|
# homeassistant.components.media_player.cmus
|
||||||
|
pycmus==0.1.0
|
||||||
|
|
||||||
|
# homeassistant.components.zwave
|
||||||
|
pydispatcher==2.0.5
|
||||||
|
|
||||||
|
# homeassistant.components.notify.html5
|
||||||
|
pyelliptic==1.5.7
|
||||||
|
|
||||||
|
# homeassistant.components.litejet
|
||||||
|
pylitejet==0.1
|
||||||
|
|
||||||
|
# homeassistant.components.mochad
|
||||||
|
pymochad==0.1.1
|
||||||
|
|
||||||
|
# homeassistant.components.alarm_control_panel.nx584
|
||||||
|
# homeassistant.components.binary_sensor.nx584
|
||||||
|
pynx584==0.4
|
||||||
|
|
||||||
|
# homeassistant.components.sensor.darksky
|
||||||
|
python-forecastio==1.3.5
|
||||||
|
|
||||||
|
# homeassistant.components.device_tracker.unifi
|
||||||
|
pyunifi==2.0
|
||||||
|
|
||||||
|
# homeassistant.components.notify.html5
|
||||||
|
pywebpush==0.6.1
|
||||||
|
|
||||||
|
# homeassistant.components.rflink
|
||||||
|
rflink==0.0.31
|
||||||
|
|
||||||
|
# homeassistant.components.ring
|
||||||
|
ring_doorbell==0.1.4
|
||||||
|
|
||||||
|
# homeassistant.components.media_player.yamaha
|
||||||
|
rxv==0.4.0
|
||||||
|
|
||||||
|
# homeassistant.components.sleepiq
|
||||||
|
sleepyq==0.6
|
||||||
|
|
||||||
|
# homeassistant.components.climate.honeywell
|
||||||
|
somecomfort==0.4.1
|
||||||
|
|
||||||
|
# homeassistant.components.recorder
|
||||||
|
# homeassistant.scripts.db_migrator
|
||||||
|
sqlalchemy==1.1.9
|
||||||
|
|
||||||
|
# homeassistant.components.statsd
|
||||||
|
statsd==3.2.1
|
||||||
|
|
||||||
|
# homeassistant.components.camera.uvc
|
||||||
|
uvcclient==0.10.0
|
||||||
|
|
||||||
|
# homeassistant.components.sensor.yahoo_finance
|
||||||
|
yahoo-finance==1.4.0
|
@ -28,6 +28,53 @@ COMMENT_REQUIREMENTS = (
|
|||||||
'face_recognition'
|
'face_recognition'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
TEST_REQUIREMENTS = (
|
||||||
|
'pydispatch',
|
||||||
|
'influxdb',
|
||||||
|
'nx584',
|
||||||
|
'uvcclient',
|
||||||
|
'somecomfort',
|
||||||
|
'aioautomatic',
|
||||||
|
'pyunifi',
|
||||||
|
'SoCo',
|
||||||
|
'libsoundtouch',
|
||||||
|
'rxv',
|
||||||
|
'apns2',
|
||||||
|
'sqlalchemy',
|
||||||
|
'forecastio',
|
||||||
|
'astral',
|
||||||
|
'aiohttp_cors',
|
||||||
|
'pilight',
|
||||||
|
'fuzzywuzzy',
|
||||||
|
'datadog',
|
||||||
|
'netdisco',
|
||||||
|
'rflink',
|
||||||
|
'ring_doorbell',
|
||||||
|
'sleepyq',
|
||||||
|
'statsd',
|
||||||
|
'pylitejet',
|
||||||
|
'holidays',
|
||||||
|
'evohomeclient',
|
||||||
|
'pexpect',
|
||||||
|
'hbmqtt',
|
||||||
|
'pychromecast',
|
||||||
|
'pycmus',
|
||||||
|
'fsapi',
|
||||||
|
'paho',
|
||||||
|
'jwt',
|
||||||
|
'dsmr_parser',
|
||||||
|
'mficlient',
|
||||||
|
'pmsensor',
|
||||||
|
'yahoo-finance',
|
||||||
|
'pymochad',
|
||||||
|
'mutagen',
|
||||||
|
'ha-ffmpeg',
|
||||||
|
'gTTS-token',
|
||||||
|
'pywebpush',
|
||||||
|
'pyelliptic',
|
||||||
|
'PyJWT',
|
||||||
|
)
|
||||||
|
|
||||||
IGNORE_PACKAGES = (
|
IGNORE_PACKAGES = (
|
||||||
'homeassistant.components.recorder.models',
|
'homeassistant.components.recorder.models',
|
||||||
)
|
)
|
||||||
@ -78,11 +125,10 @@ def comment_requirement(req):
|
|||||||
|
|
||||||
|
|
||||||
def gather_modules():
|
def gather_modules():
|
||||||
"""Collect the information and construct the output."""
|
"""Collect the information."""
|
||||||
reqs = {}
|
reqs = {}
|
||||||
|
|
||||||
errors = []
|
errors = []
|
||||||
output = []
|
|
||||||
|
|
||||||
for package in sorted(explore_module('homeassistant.components', True) +
|
for package in sorted(explore_module('homeassistant.components', True) +
|
||||||
explore_module('homeassistant.scripts', True)):
|
explore_module('homeassistant.scripts', True)):
|
||||||
@ -115,10 +161,12 @@ def gather_modules():
|
|||||||
print("Make sure you import 3rd party libraries inside methods.")
|
print("Make sure you import 3rd party libraries inside methods.")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
output.append('# Home Assistant core')
|
return reqs
|
||||||
output.append('\n')
|
|
||||||
output.append('\n'.join(core_requirements()))
|
|
||||||
output.append('\n')
|
def generate_requirements_list(reqs):
|
||||||
|
"""Generate a pip file based on requirements."""
|
||||||
|
output = []
|
||||||
for pkg, requirements in sorted(reqs.items(), key=lambda item: item[0]):
|
for pkg, requirements in sorted(reqs.items(), key=lambda item: item[0]):
|
||||||
for req in sorted(requirements,
|
for req in sorted(requirements,
|
||||||
key=lambda name: (len(name.split('.')), name)):
|
key=lambda name: (len(name.split('.')), name)):
|
||||||
@ -128,6 +176,32 @@ def gather_modules():
|
|||||||
output.append('\n# {}\n'.format(pkg))
|
output.append('\n# {}\n'.format(pkg))
|
||||||
else:
|
else:
|
||||||
output.append('\n{}\n'.format(pkg))
|
output.append('\n{}\n'.format(pkg))
|
||||||
|
return ''.join(output)
|
||||||
|
|
||||||
|
|
||||||
|
def requirements_all_output(reqs):
|
||||||
|
"""Generate output for requirements_all."""
|
||||||
|
output = []
|
||||||
|
output.append('# Home Assistant core')
|
||||||
|
output.append('\n')
|
||||||
|
output.append('\n'.join(core_requirements()))
|
||||||
|
output.append('\n')
|
||||||
|
output.append(generate_requirements_list(reqs))
|
||||||
|
|
||||||
|
return ''.join(output)
|
||||||
|
|
||||||
|
|
||||||
|
def requirements_test_output(reqs):
|
||||||
|
"""Generate output for test_requirements."""
|
||||||
|
output = []
|
||||||
|
output.append('# Home Assistant test')
|
||||||
|
output.append('\n')
|
||||||
|
with open('requirements_test.txt') as fp:
|
||||||
|
output.append(fp.read())
|
||||||
|
output.append('\n')
|
||||||
|
filtered = {key: value for key, value in reqs.items()
|
||||||
|
if any(ign in key for ign in TEST_REQUIREMENTS)}
|
||||||
|
output.append(generate_requirements_list(filtered))
|
||||||
|
|
||||||
return ''.join(output)
|
return ''.join(output)
|
||||||
|
|
||||||
@ -143,6 +217,12 @@ def write_requirements_file(data):
|
|||||||
req_file.write(data)
|
req_file.write(data)
|
||||||
|
|
||||||
|
|
||||||
|
def write_test_requirements_file(data):
|
||||||
|
"""Write the modules to the requirements_all.txt."""
|
||||||
|
with open('requirements_test_all.txt', 'w+', newline="\n") as req_file:
|
||||||
|
req_file.write(data)
|
||||||
|
|
||||||
|
|
||||||
def write_constraints_file(data):
|
def write_constraints_file(data):
|
||||||
"""Write constraints to a file."""
|
"""Write constraints to a file."""
|
||||||
with open(CONSTRAINT_PATH, 'w+', newline="\n") as req_file:
|
with open(CONSTRAINT_PATH, 'w+', newline="\n") as req_file:
|
||||||
@ -155,6 +235,12 @@ def validate_requirements_file(data):
|
|||||||
return data == ''.join(req_file)
|
return data == ''.join(req_file)
|
||||||
|
|
||||||
|
|
||||||
|
def validate_requirements_test_file(data):
|
||||||
|
"""Validate if requirements_all.txt is up to date."""
|
||||||
|
with open('requirements_test_all.txt', 'r') as req_file:
|
||||||
|
return data == ''.join(req_file)
|
||||||
|
|
||||||
|
|
||||||
def validate_constraints_file(data):
|
def validate_constraints_file(data):
|
||||||
"""Validate if constraints is up to date."""
|
"""Validate if constraints is up to date."""
|
||||||
with open(CONSTRAINT_PATH, 'r') as req_file:
|
with open(CONSTRAINT_PATH, 'r') as req_file:
|
||||||
@ -174,22 +260,31 @@ def main():
|
|||||||
|
|
||||||
constraints = gather_constraints()
|
constraints = gather_constraints()
|
||||||
|
|
||||||
|
reqs_file = requirements_all_output(data)
|
||||||
|
reqs_test_file = requirements_test_output(data)
|
||||||
|
|
||||||
if sys.argv[-1] == 'validate':
|
if sys.argv[-1] == 'validate':
|
||||||
if not validate_requirements_file(data):
|
errors = []
|
||||||
print("******* ERROR")
|
if not validate_requirements_file(reqs_file):
|
||||||
print("requirements_all.txt is not up to date")
|
errors.append("requirements_all.txt is not up to date")
|
||||||
print("Please run script/gen_requirements_all.py")
|
|
||||||
sys.exit(1)
|
if not validate_requirements_test_file(reqs_test_file):
|
||||||
|
errors.append("requirements_test_all.txt is not up to date")
|
||||||
|
|
||||||
if not validate_constraints_file(constraints):
|
if not validate_constraints_file(constraints):
|
||||||
|
errors.append(
|
||||||
|
"home-assistant/package_constraints.txt is not up to date")
|
||||||
|
|
||||||
|
if errors:
|
||||||
print("******* ERROR")
|
print("******* ERROR")
|
||||||
print("home-assistant/package_constraints.txt is not up to date")
|
print('\n'.join(errors))
|
||||||
print("Please run script/gen_requirements_all.py")
|
print("Please run script/gen_requirements_all.py")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
write_requirements_file(data)
|
write_requirements_file(reqs_file)
|
||||||
|
write_test_requirements_file(reqs_test_file)
|
||||||
write_constraints_file(constraints)
|
write_constraints_file(constraints)
|
||||||
|
|
||||||
|
|
||||||
|
6
tox.ini
6
tox.ini
@ -14,12 +14,14 @@ install_command = /usr/bin/env LANG=C.UTF-8 pip install {opts} {packages}
|
|||||||
commands =
|
commands =
|
||||||
py.test --timeout=30 --duration=10 --cov --cov-report= {posargs}
|
py.test --timeout=30 --duration=10 --cov --cov-report= {posargs}
|
||||||
deps =
|
deps =
|
||||||
-r{toxinidir}/requirements_all.txt
|
-r{toxinidir}/requirements_test_all.txt
|
||||||
-r{toxinidir}/requirements_test.txt
|
|
||||||
|
|
||||||
[testenv:lint]
|
[testenv:lint]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
ignore_errors = True
|
ignore_errors = True
|
||||||
|
deps =
|
||||||
|
-r{toxinidir}/requirements_all.txt
|
||||||
|
-r{toxinidir}/requirements_test.txt
|
||||||
commands =
|
commands =
|
||||||
flake8
|
flake8
|
||||||
pylint homeassistant
|
pylint homeassistant
|
||||||
|
Loading…
x
Reference in New Issue
Block a user