From 22de6ed56758cb7e894f091493ba17da810da548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Gir=C3=A3o=20Serr=C3=A3o?= <5621605+RodrigoGiraoSerrao@users.noreply.github.com> Date: Thu, 28 Jul 2022 09:32:32 +0100 Subject: [PATCH 1/6] Change layout to use 'src'. --- ...20728_093451_5621605+RodrigoGiraoSerrao.md | 40 +++++++++++++++++++ pyproject.toml | 2 +- .../extendedjson}/__init__.py | 0 tox.ini | 5 ++- 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 changelog.d/20220728_093451_5621605+RodrigoGiraoSerrao.md rename {extendedjson => src/extendedjson}/__init__.py (100%) 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/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..b6a9ce0 100644 --- a/tox.ini +++ b/tox.ini @@ -11,13 +11,14 @@ deps = mccabe pylint pytest +changedir = {envtmpdir} 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 . + pytest {toxinidir} + coverage run --source=extendedjson --branch -m pytest {toxinidir} coverage report -m --fail-under 100 coverage xml From de3e3e3bc97244d7a27e6b7feaf06732a8cb84fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Gir=C3=A3o=20Serr=C3=A3o?= <5621605+RodrigoGiraoSerrao@users.noreply.github.com> Date: Thu, 28 Jul 2022 09:43:12 +0100 Subject: [PATCH 2/6] Run tox linting through pre-commit. --- .pre-commit-config.yaml | 18 ++++++++- ...20728_094214_5621605+RodrigoGiraoSerrao.md | 40 +++++++++++++++++++ tox.ini | 20 +++++----- 3 files changed, 66 insertions(+), 12 deletions(-) create mode 100644 changelog.d/20220728_094214_5621605+RodrigoGiraoSerrao.md 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_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/tox.ini b/tox.ini index b6a9ce0..66ff252 100644 --- a/tox.ini +++ b/tox.ini @@ -1,30 +1,28 @@ [tox] isolated_build = True -envlist = py38,py39,py310 +envlist = + py38, + py39, + py310, + linting, [testenv] deps = - black coverage - flake8 - isort - mccabe - pylint pytest changedir = {envtmpdir} commands = - black --check extendedjson - isort --check extendedjson - flake8 extendedjson --max-line-length 88 --max-complexity 10 - pylint extendedjson pytest {toxinidir} coverage run --source=extendedjson --branch -m pytest {toxinidir} coverage report -m --fail-under 100 coverage xml +[testenv:linting] +deps = pre-commit +commands = pre-commit run --all-files --show-diff-on-failure [gh-actions] python = 3.8: py38 3.9: py39 - 3.10: py310 + 3.10: py310, linting From d0fd6b4c8a8630c4fd809c3df1a85791b088574b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Gir=C3=A3o=20Serr=C3=A3o?= <5621605+RodrigoGiraoSerrao@users.noreply.github.com> Date: Thu, 28 Jul 2022 09:58:08 +0100 Subject: [PATCH 3/6] Produce coverage report for 3.9 only. --- .github/workflows/build.yaml | 2 + ...20728_095740_5621605+RodrigoGiraoSerrao.md | 39 +++++++++++++++++++ tox.ini | 27 +++++++------ 3 files changed, 57 insertions(+), 11 deletions(-) create mode 100644 changelog.d/20220728_095740_5621605+RodrigoGiraoSerrao.md 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/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/tox.ini b/tox.ini index 66ff252..2b63060 100644 --- a/tox.ini +++ b/tox.ini @@ -1,28 +1,33 @@ [tox] isolated_build = True envlist = - py38, - py39, - py310, - linting, + py38 + py39 + py310 + linting + coverage [testenv] deps = - coverage pytest changedir = {envtmpdir} -commands = - pytest {toxinidir} - coverage run --source=extendedjson --branch -m pytest {toxinidir} - coverage report -m --fail-under 100 - coverage xml +commands = pytest {toxinidir} [testenv:linting] deps = pre-commit commands = pre-commit run --all-files --show-diff-on-failure +[testenv:coverage] +deps = + pytest + coverage +commands = + coverage run --source=extendedjson --branch -m pytest {toxinidir} + coverage report -m --fail-under 100 + coverage xml + [gh-actions] python = 3.8: py38 - 3.9: py39 + 3.9: py39, coverage 3.10: py310, linting From a65a1d28a7b8e463beae27e5b6efe58b175de1fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Gir=C3=A3o=20Serr=C3=A3o?= <5621605+RodrigoGiraoSerrao@users.noreply.github.com> Date: Thu, 28 Jul 2022 10:13:34 +0100 Subject: [PATCH 4/6] Fix tox config. --- tox.ini | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 2b63060..c16f061 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,7 @@ envlist = [testenv] deps = pytest -changedir = {envtmpdir} +changedir = {envtmpdir} # Move elsewhere to ensure pytest doesn't run from source root. commands = pytest {toxinidir} [testenv:linting] @@ -21,8 +21,9 @@ commands = pre-commit run --all-files --show-diff-on-failure deps = pytest coverage +changedir = {toxinidir} # Go back to original dir to make it easier to upload coverage report. commands = - coverage run --source=extendedjson --branch -m pytest {toxinidir} + coverage run --source=extendedjson --branch -m pytest coverage report -m --fail-under 100 coverage xml From 92f96bb1b31985a7a14f09faa9fcfc2ffa69d4c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Gir=C3=A3o=20Serr=C3=A3o?= <5621605+RodrigoGiraoSerrao@users.noreply.github.com> Date: Thu, 28 Jul 2022 10:13:34 +0100 Subject: [PATCH 5/6] Fix tox config. --- tox.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 2b63060..3d3ace0 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,7 @@ envlist = [testenv] deps = pytest -changedir = {envtmpdir} +changedir = {envtmpdir} # Move elsewhere to ensure pytest doesn't run from source root. commands = pytest {toxinidir} [testenv:linting] @@ -21,6 +21,7 @@ commands = pre-commit run --all-files --show-diff-on-failure deps = pytest coverage +changedir = {toxinidir} # Go back to original dir to make it easier to upload coverage report. commands = coverage run --source=extendedjson --branch -m pytest {toxinidir} coverage report -m --fail-under 100 From d8da23e38c2cb5e2d72cab62cb72b932795ebcae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Gir=C3=A3o=20Serr=C3=A3o?= <5621605+RodrigoGiraoSerrao@users.noreply.github.com> Date: Thu, 28 Jul 2022 10:19:50 +0100 Subject: [PATCH 6/6] Fix tox config. --- tox.ini | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index c16f061..05ab8ae 100644 --- a/tox.ini +++ b/tox.ini @@ -21,11 +21,10 @@ commands = pre-commit run --all-files --show-diff-on-failure deps = pytest coverage -changedir = {toxinidir} # Go back to original dir to make it easier to upload coverage report. commands = - 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 =