Skip to content

Commit

Permalink
tests: use tox for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
firstof9 committed Feb 7, 2022
1 parent 565b17a commit cfe7aed
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 23 deletions.
37 changes: 27 additions & 10 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,40 @@ jobs:
python-version:
- "3.8"
- "3.9"
# - "3.10"
- "3.10"

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2.2.2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install --use-deprecated legacy-resolver -r requirements_test.txt
sudo apt-get update
sudo apt-get -y install language-pack-it
- name: Generate coverage report
run: |
python -m pytest
pip install pytest-cov
pytest ./tests/ --cov=custom_components/mail_and_packages/ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
pip install tox tox-gh-actions
- name: Test with tox
run: tox
- name: Upload coverage data
uses: "actions/[email protected]"
with:
name: coverage-data
path: "coverage.xml"

coverage:
runs-on: ubuntu-latest
needs: build
steps:
- name: Check out the repository
uses: actions/[email protected]
with:
fetch-depth: 2
- name: Download coverage data
uses: actions/[email protected]
with:
name: coverage-data
- name: Upload coverage report
uses: codecov/[email protected]
79 changes: 69 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,78 @@
custom_components/.DS_Store
custom_components/mail_and_packages/.DS_Store
custom_components/mail_and_packages/__pycache__/.DS_Store
includes/.DS_Store
includes/packages/.DS_Store
www/.DS_Store
www/mail_and_packages/.DS_Store
# Hide some OS X stuff
.DS_Store
.AppleDouble
.LSOverride
Icon

# Thumbnails
._*

custom_components/mail_and_packages/camera.py.old
custom_components/mail_and_packages/.backup/__init__.py
custom_components/mail_and_packages/.backup/camera.py
custom_components/mail_and_packages/.backup/manifest.json
custom_components/mail_and_packages/.backup/sensor.py
notes.txt
.vscode/settings.json
*.pyc
.coverage

# Test files
ra_0_mailerProvidedImage0
mailerProvidedImage0

# pytest
.pytest_cache
.cache

# Unit test / coverage reports
.coverage
.tox
coverage.xml
nosetests.xml
htmlcov/
test-reports/
test-results.xml
test-output.xml

# Translations
*.mo

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

.python-version

# emacs auto backups
*~
*#
*.orig

# venv stuff
pyvenv.cfg
pip-selfcheck.json
venv
.venv
Pipfile*
share/*
Scripts/

# vimmy stuff
*.swp
*.swo
tags
ctags.tmp

# vagrant stuff
virtualization/vagrant/setup_done
virtualization/vagrant/.vagrant
virtualization/vagrant/config

# Visual Studio Code
.vscode/*
!.vscode/cSpell.json
!.vscode/extensions.json
!.vscode/tasks.json

# Typing
.mypy_cache
*.pyc
8 changes: 6 additions & 2 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ disable=
too-many-public-methods,
too-many-instance-attributes,
too-many-branches,
no-self-use
no-self-use,
too-many-statements,
broad-except,
too-many-lines,
too-many-locals

[REPORTS]
score=no
Expand All @@ -36,4 +40,4 @@ score=no
ignored-classes=_CountingAttr

[FORMAT]
expected-line-ending-format=CRLF
expected-line-ending-format=LF
3 changes: 2 additions & 1 deletion requirements_format.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ black
isort
flake8
pydocstyle
pylint
pylint
mypy
39 changes: 39 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[tox]
skipsdist = true
envlist = py38, py39, py310, lint, mypy
skip_missing_interpreters = True
ignore_basepython_conflict = True

[gh-actions]
python =
3.8: py38, lint, mypy
3.9: py39
3.10: py310

[testenv]
pip_version = pip>=21.0,<22.1
install_command = python -m pip install --use-deprecated legacy-resolver {opts} {packages}
commands =
pytest --timeout=30 --cov=custom_components/mail_and_packages/ --cov-report=xml {posargs}
deps =
-rrequirements_test.txt

[testenv:lint]
basepython = python3
ignore_errors = True
commands =
black --check custom_components/mail_and_packages/
flake8 custom_components/mail_and_packages/
pylint custom_components/mail_and_packages/
pydocstyle custom_components/mail_and_packages/ tests/
deps =
-rrequirements_format.txt
-rrequirements_test.txt

[testenv:mypy]
basepython = python3
ignore_errors = True
commands =
mypy custom_components/mail_and_packages/
deps =
-rrequirements_format.txt

0 comments on commit cfe7aed

Please sign in to comment.