From c5af2e5cc0b7bf03f4aeeccc1818468de5f6370d Mon Sep 17 00:00:00 2001 From: Stavros Ntentos <133706+stdedos@users.noreply.github.com> Date: Sat, 14 Oct 2023 10:18:23 +0300 Subject: [PATCH] MOAR Improvements: Cross-OS testing, `.gitignore` updates, supporting only `pylint<3`, coverage at Codecov, drop other CI Signed-off-by: Stavros Ntentos <133706+stdedos@users.noreply.github.com> --- .github/workflows/run-tests.yaml | 61 ++++++----- .gitignore | 171 ++++++++++++++++++++++++++++++- .travis.yml | 37 ------- README.md | 2 +- appveyor.yml | 36 ------- setup.cfg | 45 +++++++- setup.py | 4 +- tox.ini | 11 +- 8 files changed, 258 insertions(+), 109 deletions(-) delete mode 100644 .travis.yml delete mode 100644 appveyor.yml diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 2a416d0..3a1e534 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -1,49 +1,62 @@ -name: Python package +name: Testing on: push: - branches: - - master pull_request: - branches: - - master jobs: test: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + os: + - ubuntu-latest + - windows-latest + - macos-latest + python-version: + - '3.6' + - '3.7' + - '3.8' + - '3.9' + - '3.10' + - '3.11' + # - '3.12' # FixMe: https://github.com/pylint-dev/pylint-pytest/issues/3 + # Python 3.6 is not available in `ubuntu-latest`. + exclude: + - python-version: '3.6' + os: ubuntu-latest + include: + - python-version: '3.6' + os: ubuntu-20.04 + + defaults: + run: + shell: ${{ matrix.os == 'windows-latest' && 'pwsh' || '/bin/bash --noprofile --norc -Eeuxo pipefail {0}' }} steps: - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} cache: 'pip' cache-dependency-path: setup.py - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install tox tox-gh-actions - - name: Test with tox - run: tox - test-36: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.6 - uses: actions/setup-python@v4 - with: - python-version: 3.6 - cache: 'pip' - cache-dependency-path: setup.py - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install tox + - name: Test with tox - run: tox -e py36 + env: + FORCE_COLOR: 1 + run: tox ${{ matrix.python-version == '3.6' && '--skip-missing-interpreters=true' || '' }} + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: true + files: test_artifacts/cobertura.xml diff --git a/.gitignore b/.gitignore index e99db73..4012e01 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,169 @@ -*.pyc +sandbox/**/*.py +/test_artifacts/ + +## Mostly complete version from https://github.com/github/gitignore/blob/e5323759e387ba347a9d50f8b0ddd16502eb71d4/Python.gitignore + +# Byte-compiled / optimized / DLL files __pycache__/ -.tox/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python build/ -sandbox/**/*.py -Pipfile* +develop-eggs/ dist/ -Makefile +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ +cache/* + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +# VS code +.vscode/launch.json diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 26dac9c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,37 +0,0 @@ -language: python - -matrix: - include: - - python: 3.6 - env: TOX_ENV=py36 - - python: 3.7 - env: TOX_ENV=py37 - - python: 3.8 - env: TOX_ENV=py38 - - python: 3.9 - env: TOX_ENV=py39 - - python: 3.10 - env: TOX_ENV=py310 - - python: 3.11 - env: TOX_ENV=py311 - -install: - - pip install tox - -script: - - tox -e $TOX_ENV - -before_cache: - - rm -rf $HOME/.cache/pip/log - -cache: - directories: - - $HOME/.cache/pip - -deploy: - provider: pypi - user: __token__ - on: - tags: true - condition: "$TOX_ENV = py38" - distributions: bdist_wheel diff --git a/README.md b/README.md index 2799f88..47d0a2f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # pylint-pytest -[![Python package](https://github.com/stdedos/pylint-pytest/actions/workflows/run-tests.yaml/badge.svg)](https://github.com/stdedos/pylint-pytest/actions/workflows/run-tests.yaml) +[![Python package](https://github.com/pylint-dev/pylint-pytest/actions/workflows/run-tests.yaml/badge.svg)](https://github.com/pylint-dev/pylint-pytest/actions/workflows/run-tests.yaml) [![PyPI version fury.io](https://badge.fury.io/py/pylint-pytest.svg)](https://pypi.python.org/pypi/pylint-pytest/) [![Travis CI](https://travis-ci.org/reverbc/pylint-pytest.svg?branch=master)](https://travis-ci.org/reverbc/pylint-pytest) [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/reverbc/pylint-pytest?branch=master&svg=true)](https://ci.appveyor.com/project/reverbc/pylint-pytest) diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 7b1a8b3..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,36 +0,0 @@ -# What Python version is installed where: -# http://www.appveyor.com/docs/installed-software#python - -image: Visual Studio 2019 - -environment: - matrix: - - PYTHON: "C:\\Python36" - TOX_ENV: "py36" - - - PYTHON: "C:\\Python37" - TOX_ENV: "py37" - - - PYTHON: "C:\\Python38" - TOX_ENV: "py38" - - - PYTHON: "C:\\Python39" - TOX_ENV: "py39" - -init: - - "%PYTHON%/python -V" - - "%PYTHON%/python -c \"import struct;print( 8 * struct.calcsize(\'P\'))\"" - -install: - - "%PYTHON%/Scripts/easy_install -U pip" - - "%PYTHON%/Scripts/pip install tox" - - "%PYTHON%/Scripts/pip install wheel" - - "%PYTHON%/Scripts/pip install psutil" - -build: false # Not a C# project, build stuff at the test step instead. - -test_script: - - "%PYTHON%/Scripts/tox -e %TOX_ENV%" - -#on_success: -# - TODO: upload the content of dist/*.whl to a public wheelhouse diff --git a/setup.cfg b/setup.cfg index 2a2ef5b..ce0146f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,8 +2,51 @@ test = pytest [tool:pytest] -addopts = --verbose +addopts = --verbose --cov-report=xml --cov-report=html python_files = tests/test_*.py [bdist_wheel] universal = 1 + +[coverage:run] +branch = True + +[coverage:paths] +source = + pylint_pytest/ + +[coverage:report] +; Regexes for lines to exclude from consideration +exclude_also = + ; Have to re-enable the standard pragma + pragma: no cover + + ; Don't complain about missing debug-only code: + def __repr__ + if self\.debug + if settings.DEBUG + + ; Don't complain if tests don't hit defensive assertion code: + raise AssertionError + raise NotImplementedError + + ; Don't complain if non-runnable code isn't run: + if 0: + if __name__ == .__main__.: + + ; Don't complain about abstract methods, they aren't run: + @(abc\.)?abstractmethod + class .*\bProtocol\): + + ; Ignore type-checking blocks + if TYPE_CHECKING: + ; Defensive programming does not need to be covered + raise UnreachableCodeException + +ignore_errors = True + +[coverage:xml] +output = test_artifacts/cobertura.xml + +[coverage:html] +directory = test_artifacts/htmlcov diff --git a/setup.py b/setup.py index 847b1c9..03a8589 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ long_description_content_type='text/markdown', packages=find_packages(exclude=['tests', 'sandbox']), install_requires=[ - 'pylint', + 'pylint<3', 'pytest>=4.6', ], python_requires='>=3.6', @@ -45,6 +45,6 @@ 'Operating System :: OS Independent', 'License :: OSI Approved :: MIT License', ], - tests_require=['pytest', 'pylint'], + tests_require=['pytest', 'pytest-cov', 'pylint'], keywords=['pylint', 'pytest', 'plugin'], ) diff --git a/tox.ini b/tox.ini index 63013e5..deb1a2b 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,13 @@ [tox] -envlist = py36,py37,py38,py39,py310,py311 +envlist = py36,py37,py38,py39,py310,py311,py312 skipsdist = True +passenv = + FORCE_COLOR [testenv] +deps = + pytest + pytest-cov commands = - pip install ./ --upgrade - pytest {posargs:tests} + pip install --upgrade . + pytest --cov --cov-config=setup.cfg --cov-append --junitxml=test_artifacts/test_report.xml {tty:--color=yes} {posargs:tests}