diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b6061ee..4369eb6 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -32,6 +32,8 @@ jobs: run: tox - name: Upload coverage to Codecov + # We only generate the coverage report in Python 3.9 + if: "matrix.python-version == '3.9'" uses: codecov/codecov-action@v2 with: fail_ci_if_error: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c803c21..ccaddd0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,12 +8,28 @@ repos: - id: check-yaml - id: end-of-file-fixer - id: mixed-line-ending + - repo: https://github.com/psf/black rev: 22.3.0 hooks: - id: black + args: ["--check"] + - repo: https://github.com/PyCQA/isort rev: 5.10.1 hooks: - id: isort - args: ["--profile", "black"] + args: ["--check", "--profile", "black"] + + - repo: https://github.com/PyCQA/flake8 + rev: 4.0.1 + hooks: + - id: flake8 + additional_dependencies: [mccabe] + args: ["--max-line-length", "88", "--max-complexity", "10"] + + - repo: https://github.com/PyCQA/pylint/ + rev: v2.14.5 + hooks: + - id: pylint + exclude: tests/ # Prevent files in tests/ to be passed in to pylint. diff --git a/changelog.d/20220728_093451_5621605+RodrigoGiraoSerrao.md b/changelog.d/20220728_093451_5621605+RodrigoGiraoSerrao.md new file mode 100644 index 0000000..bc25a46 --- /dev/null +++ b/changelog.d/20220728_093451_5621605+RodrigoGiraoSerrao.md @@ -0,0 +1,40 @@ + + + + +### Changed + +- Change code layout to use a top-level directory `src`. + + + + diff --git a/changelog.d/20220728_094214_5621605+RodrigoGiraoSerrao.md b/changelog.d/20220728_094214_5621605+RodrigoGiraoSerrao.md new file mode 100644 index 0000000..8d03e4e --- /dev/null +++ b/changelog.d/20220728_094214_5621605+RodrigoGiraoSerrao.md @@ -0,0 +1,40 @@ + + + + +### Changed + +- tox now runs linting through pre-commit. + + + + diff --git a/changelog.d/20220728_095740_5621605+RodrigoGiraoSerrao.md b/changelog.d/20220728_095740_5621605+RodrigoGiraoSerrao.md new file mode 100644 index 0000000..31b3789 --- /dev/null +++ b/changelog.d/20220728_095740_5621605+RodrigoGiraoSerrao.md @@ -0,0 +1,39 @@ + + + + +### Changed + +- Only produce coverage report for Python 3.9. + + + diff --git a/pyproject.toml b/pyproject.toml index a3cf2a3..0c4f841 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ scriv = {extras = ["toml"], version = "^0.15.2"} [tool.scriv] format = "md" -version = "literal: extendedjson/__init__.py: __version__" +version = "literal: src/extendedjson/__init__.py: __version__" [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/extendedjson/__init__.py b/src/extendedjson/__init__.py similarity index 100% rename from extendedjson/__init__.py rename to src/extendedjson/__init__.py diff --git a/tox.ini b/tox.ini index 799991d..05ab8ae 100644 --- a/tox.ini +++ b/tox.ini @@ -1,29 +1,33 @@ [tox] isolated_build = True -envlist = py38,py39,py310 +envlist = + py38 + py39 + py310 + linting + coverage [testenv] deps = - black - coverage - flake8 - isort - mccabe - pylint pytest +changedir = {envtmpdir} # Move elsewhere to ensure pytest doesn't run from source root. +commands = pytest {toxinidir} + +[testenv:linting] +deps = pre-commit +commands = pre-commit run --all-files --show-diff-on-failure + +[testenv:coverage] +deps = + pytest + coverage commands = - black --check extendedjson - isort --check extendedjson - flake8 extendedjson --max-line-length 88 --max-complexity 10 - pylint extendedjson - pytest . - coverage run --source=extendedjson --branch -m pytest . + coverage run --source=extendedjson --branch -m pytest {toxinidir} coverage report -m --fail-under 100 - coverage xml - + coverage xml -o {toxinidir}/coverage.xml [gh-actions] python = 3.8: py38 - 3.9: py39 - 3.10: py310 + 3.9: py39, coverage + 3.10: py310, linting