From f9ec1be7104aa624166753ff60b53766aba9de7c Mon Sep 17 00:00:00 2001 From: Jens Diemer Date: Fri, 2 Aug 2024 19:56:45 +0200 Subject: [PATCH] Add "coverage" command --- doc/ADMIN.md | 1 + for_runners_ynh/cli/dev.py | 21 ++++++++++++++++----- manifest.toml | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/doc/ADMIN.md b/doc/ADMIN.md index 312e727..449e3de 100644 --- a/doc/ADMIN.md +++ b/doc/ADMIN.md @@ -39,6 +39,7 @@ Usage: ./dev-cli.py [OPTIONS] COMMAND [ARGS]... ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─ Commands ───────────────────────────────────────────────────────────────────────────────────────╮ │ check-code-style Check code style by calling darker + flake8 │ +│ coverage Run tests and show coverage report. │ │ diffsettings Run "diffsettings" manage command against a "local_test" YunoHost │ │ installation. │ │ fix-code-style Fix code style of all your_cool_package source code files via darker │ diff --git a/for_runners_ynh/cli/dev.py b/for_runners_ynh/cli/dev.py index 6aadd6b..36ed7a9 100644 --- a/for_runners_ynh/cli/dev.py +++ b/for_runners_ynh/cli/dev.py @@ -1,24 +1,21 @@ """ CLI for development """ + import logging import shlex import sys from pathlib import Path -import for_runners_ynh import rich_click as click from cli_base.cli_tools import code_style -from cli_base.cli_tools.dev_tools import run_tox +from cli_base.cli_tools.dev_tools import run_coverage, run_tox from cli_base.cli_tools.subprocess_utils import verbose_check_call from cli_base.cli_tools.test_utils.snapshot import UpdateTestSnapshotFiles from cli_base.cli_tools.verbosity import OPTION_KWARGS_VERBOSE from cli_base.cli_tools.version_info import print_version from cli_base.run_pip_audit import run_pip_audit from django.core.management.commands.test import Command as DjangoTestCommand -from for_runners_ynh import constants -from for_runners_ynh.constants import PACKAGE_ROOT -from for_runners_ynh.tests import setup_ynh_tests from django_yunohost_integration.local_test import create_local_test from manageprojects.utilities.publish import publish_package from rich import print @@ -26,6 +23,11 @@ from rich.console import Console from rich.traceback import install as rich_traceback_install from rich_click import RichGroup +import for_runners_ynh +from for_runners_ynh import constants +from for_runners_ynh.constants import PACKAGE_ROOT +from for_runners_ynh.tests import setup_ynh_tests + logger = logging.getLogger(__name__) @@ -211,6 +213,14 @@ def test(): _run_django_test_cli(argv=sys.argv, exit_after_run=True) +@cli.command() # Dummy command +def coverage(): + """ + Run tests and show coverage report. + """ + run_coverage() + + @cli.command() # Dummy "tox" command def tox(): """ @@ -273,6 +283,7 @@ def main(): command_map = { 'test': _run_django_test_cli, 'tox': run_tox, + 'coverage': run_coverage, } if real_func := command_map.get(command): real_func(argv=sys.argv, exit_after_run=True) diff --git a/manifest.toml b/manifest.toml index ee61b37..0fdb898 100644 --- a/manifest.toml +++ b/manifest.toml @@ -19,7 +19,7 @@ code = "https://github.com/jedie/django-for-runners" [integration] # https://yunohost.org/en/packaging_manifest#integration-section -yunohost = ">=11" +yunohost = ">=11.2" architectures = "all" multi_instance = true ldap = true