diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 148f130..9831025 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -55,11 +55,7 @@ repos: - id: pydocstyle additional_dependencies: ["tomli==2.0.1"] files: "^src/" - - repo: https://github.com/econchick/interrogate - rev: "1.5.0" - hooks: - - id: interrogate - files: "^src/" + - repo: https://github.com/pre-commit/mirrors-mypy rev: 'v1.1.1' hooks: diff --git a/codemeta.json b/codemeta.json index d2e0722..97518ae 100644 --- a/codemeta.json +++ b/codemeta.json @@ -10,11 +10,11 @@ "audience": [ { "@type": "Audience", - "audienceType": "Science/Research" + "audienceType": "Developers" }, { "@type": "Audience", - "audienceType": "Developers" + "audienceType": "Science/Research" } ], "author": [ @@ -44,7 +44,7 @@ "identifier": "cookiecutter", "name": "cookiecutter", "runtimePlatform": "Python 3", - "version": "^2.1.1" + "version": "^2.1.2" }, { "@type": "SoftwareApplication", @@ -55,4 +55,4 @@ } ], "version": "0.1.0" -} \ No newline at end of file +} diff --git a/hooks/post_gen_project.sh b/hooks/post_gen_project.sh index 8584801..47d22fe 100755 --- a/hooks/post_gen_project.sh +++ b/hooks/post_gen_project.sh @@ -26,7 +26,7 @@ rm tests/test_api.py # finalize repo setup git init -poetry install +poetry install --with docs poetry run poe init-dev # init git repo + register pre-commit poetry run pip install pipx # install pipx into venv without adding it as dep poetry run pipx run reuse download --all # get license files for REUSE compliance diff --git a/tests/test_template.py b/tests/test_template.py index 8f1247c..f2de65b 100644 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -1,15 +1,31 @@ import subprocess +import sys import pytest +from cookiecutter.exceptions import CookiecutterException from cookiecutter.main import cookiecutter def sanity_check_project(proj_path): """Sanity-check a generated project (linters, tests, doc generation).""" - subprocess.check_call("poetry install --with docs".split(), cwd=proj_path) - subprocess.check_call("poetry run poe lint --all-files".split(), cwd=proj_path) - subprocess.check_call("poetry run poe test".split(), cwd=proj_path) - subprocess.check_call("poetry run poe docs".split(), cwd=proj_path) + try: + subprocess.check_output( + "poetry install --with docs".split(), cwd=proj_path, stderr=subprocess.PIPE + ) + subprocess.check_output( + "poetry run poe lint --all-files".split(), + cwd=proj_path, + stderr=subprocess.PIPE, + ) + subprocess.check_output( + "poetry run poe test".split(), cwd=proj_path, stderr=subprocess.PIPE + ) + subprocess.check_output( + "poetry run poe docs".split(), cwd=proj_path, stderr=subprocess.PIPE + ) + except subprocess.CalledProcessError as e: + print("exit code: {}".format(e.returncode)) + print("stderr: {}".format(e.stderr.decode(sys.getfilesystemencoding()))) @pytest.fixture @@ -23,9 +39,25 @@ def gen(tmp_path_factory): def gen_project(**cc_args): out_dir = tmp_path_factory.mktemp("gen_proj") + out_dir_raw = tmp_path_factory.mktemp("gen_proj_raw") - # actual project generation - cookiecutter(template="./", no_input=True, output_dir=out_dir, **cc_args) + # NOTE: once 2.1.2 is out with keep_project_on_failure, + # this can be simplified + # instantiate without hooks (for debugging) + cookiecutter( + template="./", + no_input=True, + output_dir=out_dir_raw, + accept_hooks=False, + **cc_args, + ) + + # actual project generation (with hooks) + try: + cookiecutter(template="./", no_input=True, output_dir=out_dir, **cc_args) + except CookiecutterException as e: + print(f"DEBUG DIR (without hook evaluation): {out_dir_raw}") + raise e # should be unique directory paths = list(out_dir.iterdir()) diff --git a/{{ cookiecutter.__project_slug }}/.pre-commit-config.yaml b/{{ cookiecutter.__project_slug }}/.pre-commit-config.yaml index 78cd9e0..b77dec7 100644 --- a/{{ cookiecutter.__project_slug }}/.pre-commit-config.yaml +++ b/{{ cookiecutter.__project_slug }}/.pre-commit-config.yaml @@ -53,11 +53,6 @@ repos: - id: pydocstyle additional_dependencies: ["tomli==2.0.1"] files: "^src/" - - repo: https://github.com/econchick/interrogate - rev: "1.5.0" - hooks: - - id: interrogate - files: "^src/" - repo: https://github.com/pre-commit/mirrors-mypy rev: 'v1.1.1' hooks: diff --git a/{{ cookiecutter.__project_slug }}/README.md b/{{ cookiecutter.__project_slug }}/README.md index 89b933e..ff3e2b7 100644 --- a/{{ cookiecutter.__project_slug }}/README.md +++ b/{{ cookiecutter.__project_slug }}/README.md @@ -1,4 +1,3 @@ -![Project status](https://img.shields.io/badge/project%20status-alpha-%23ff8000) [ ![Docs](https://img.shields.io/badge/read-docs-success) ]({{ cookiecutter.__project_gh_pages }}) @@ -8,9 +7,6 @@ [ ![Test Coverage]({{ cookiecutter.__project_gh_pages }}/main/coverage_badge.svg) ]({{ cookiecutter.__project_gh_pages }}/main/coverage) -[ -![Docs Coverage]({{ cookiecutter.__project_gh_pages }}/main/interrogate_badge.svg) -]({{ cookiecutter.__project_gh_pages }}) # {{ cookiecutter.project_name.strip() }} diff --git a/{{ cookiecutter.__project_slug }}/docs/scripts/coverage_status.py b/{{ cookiecutter.__project_slug }}/docs/scripts/coverage_status.py index bcd2ea2..9a01cee 100644 --- a/{{ cookiecutter.__project_slug }}/docs/scripts/coverage_status.py +++ b/{{ cookiecutter.__project_slug }}/docs/scripts/coverage_status.py @@ -6,23 +6,21 @@ import anybadge import pytest from coverage import Coverage -from interrogate import badge_gen -from interrogate.coverage import InterrogateCoverage log = logging.getLogger("mkdocs") badge_colors = { - 20: "red", - 40: "orange", - 60: "yellow", - 80: "greenyellow", - 90: "green", + 20.0: "red", + 40.0: "orange", + 60.0: "yellow", + 80.0: "greenyellow", + 90.0: "green", } """Colors for overall coverage percentage (0-100).""" -def on_pre_build(config): +def on_pre_build(_config): """Generate coverage report if it is missing and create a badge.""" if not Path("htmlcov").is_dir() or not Path(".coverage").is_file(): log.info("Missing htmlcov or .coverage, running pytest to collect.") @@ -47,8 +45,3 @@ def on_pre_build(config): if badge_svg.is_file(): badge_svg.unlink() badge.write_badge(badge_svg) - - # generates a docs coverage badge in docs/interrogate_badge.svg - doc_cov = InterrogateCoverage(paths=["src"]).get_coverage() - log.info(f"Docs Coverage: {doc_cov.perc_covered}%, generating badge.") - badge_gen.create("docs", doc_cov) diff --git a/{{ cookiecutter.__project_slug }}/pyproject.toml b/{{ cookiecutter.__project_slug }}/pyproject.toml index c963719..ea389de 100644 --- a/{{ cookiecutter.__project_slug }}/pyproject.toml +++ b/{{ cookiecutter.__project_slug }}/pyproject.toml @@ -15,7 +15,6 @@ classifiers = [ # TODO: update the classifier strings # (see https://pypi.org/classifiers/) "Operating System :: POSIX :: Linux", - "Development Status :: 3 - Alpha", "Intended Audience :: Science/Research", "Intended Audience :: Developers", ] @@ -27,10 +26,9 @@ packages = [{include = "{{ cookiecutter.__project_package }}", from = "src"}] # include files related to test and documentation only in sdist: include = [ "*.md", "LICENSE", "LICENSES", ".reuse/dep5", "CITATION.cff", "codemeta.json", - "mkdocs.yml", "docs", "tests", # NOTE: temporary workaround (codemetapy bug) - # { path = "mkdocs.yml", format = "sdist" }, - # { path = "docs", format = "sdist" }, - # { path = "tests", format = "sdist" }, + { path = "mkdocs.yml", format = "sdist" }, + { path = "docs", format = "sdist" }, + { path = "tests", format = "sdist" }, ] [tool.poetry.dependencies] @@ -71,7 +69,6 @@ markdown-exec = {extras = ["ansi"], version = "^1.6.0"} mkdocs-coverage = "^0.2.7" mike = "^1.1.2" anybadge = "^1.14.0" -interrogate = "^1.5.0" black = "^23.3.0" [tool.poetry.scripts] @@ -129,9 +126,6 @@ max-line-length = 88 [tool.pydocstyle] convention = "google" -[tool.interrogate] -fail-under = 95 - [tool.bandit] exclude_dirs = ["tests", "scripts"]