diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 535fe782..2135b8d9 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -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/upload-artifact@v2.2.4" + with: + name: coverage-data + path: "coverage.xml" + + coverage: + runs-on: ubuntu-latest + needs: build + steps: + - name: Check out the repository + uses: actions/checkout@v2.3.4 + with: + fetch-depth: 2 + - name: Download coverage data + uses: actions/download-artifact@v2.0.10 + with: + name: coverage-data + - name: Upload coverage report + uses: codecov/codecov-action@v2.0.2 \ No newline at end of file diff --git a/.gitignore b/.gitignore index f615c475..dffca95a 100644 --- a/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/pylintrc b/pylintrc index 55d8a9d7..ca5c1e2c 100644 --- a/pylintrc +++ b/pylintrc @@ -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 @@ -36,4 +40,4 @@ score=no ignored-classes=_CountingAttr [FORMAT] -expected-line-ending-format=CRLF +expected-line-ending-format=LF diff --git a/requirements_format.txt b/requirements_format.txt index ff1c4dc6..1e6db1fb 100644 --- a/requirements_format.txt +++ b/requirements_format.txt @@ -2,4 +2,5 @@ black isort flake8 pydocstyle -pylint \ No newline at end of file +pylint +mypy \ No newline at end of file diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..ec7c6c38 --- /dev/null +++ b/tox.ini @@ -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 \ No newline at end of file