From 420e3739c5593c3cf1577d8db87cf154265a2f6b Mon Sep 17 00:00:00 2001 From: eol Date: Tue, 15 Apr 2025 09:58:07 +0700 Subject: [PATCH 1/5] Removing taskipy as required installation (it is installed with [dev]) --- {{cookiecutter.project_slug}}/README.md | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md index b88a1e5..cd993e7 100644 --- a/{{cookiecutter.project_slug}}/README.md +++ b/{{cookiecutter.project_slug}}/README.md @@ -76,16 +76,11 @@ To run this project locally, you will need to install the prerequisites and foll ### Prerequisites This Project depends on the following projects. -* UV +* uv ```sh pip install --user --upgrade uv ``` -* Taskipy - ```sh - pip install --user --upgrade taskipy - ``` - ### Installation 1. Clone the repo @@ -93,9 +88,9 @@ This Project depends on the following projects. git clone https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}} cd {{cookiecutter.project_slug}} ``` -2. Install UV and taskipy +2. Install uv ```sh - pip install --user --upgrade uv taskipy + pip install --user --upgrade uv ``` 3. Install requirements for development ```sh From 527d1c74c3cab62b5505167bc3f45ea054674ed2 Mon Sep 17 00:00:00 2001 From: eol Date: Sat, 19 Apr 2025 16:05:44 +0700 Subject: [PATCH 2/5] Update README.md --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 84215fb..e1e755a 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ Python template with some awesome tools to quickstart a Python project with the industry best practices. It includes automatic generation of API documentation, tests using PyTest, code coverage, -ruff linting to enforce standardized Python coding and formatting, virtual environments using UV, workflow automation using Taskipy and a space optimized Dockerfile to kickstart your project and run tests using the power of Docker containers. +ruff linting to enforce standardized Python coding and formatting, virtual environments using uv, workflow automation using Taskipy and a space optimized Dockerfile to kickstart your project and run tests using the power of Docker containers. You only need to install [Cookiecutter](https://cookiecutter.readthedocs.io/en/1.7.2/usage.html)! @@ -90,12 +90,13 @@ This Project depends on the following projects. cookiecutter https://github.com/nullhack/python-project-template # move into your newly created project folder ``` -2. Install UV and Taskipy +2. Install uv and Taskipy ```sh - pip install --user --upgrade uv taskipy + pip install --user --upgrade uv ``` 3. Let Taskipy do it's magic ```sh + uv venv uv pip install .[dev] uv task test uv task run From 7d02397711e110df702c15fa9880c3f8a6bcca8e Mon Sep 17 00:00:00 2001 From: eol Date: Sat, 19 Apr 2025 16:08:48 +0700 Subject: [PATCH 3/5] Update README.md --- {{cookiecutter.project_slug}}/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md index cd993e7..d0a6952 100644 --- a/{{cookiecutter.project_slug}}/README.md +++ b/{{cookiecutter.project_slug}}/README.md @@ -113,6 +113,8 @@ Some useful examples of how this project can be used: * Install requirements ```sh + pip install --user --upgrade uv + uv venv uv run task '.[dev]' ``` @@ -123,7 +125,7 @@ Some useful examples of how this project can be used: * Run the project ```sh - uv run main.py + uv run task run ``` * Generate API documentation From 36bc79471b9d4326a4bada52014fd2c8f9fa0ed6 Mon Sep 17 00:00:00 2001 From: eol Date: Sat, 19 Apr 2025 16:11:02 +0700 Subject: [PATCH 4/5] Update README.md --- {{cookiecutter.project_slug}}/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md index d0a6952..36bfc4f 100644 --- a/{{cookiecutter.project_slug}}/README.md +++ b/{{cookiecutter.project_slug}}/README.md @@ -113,9 +113,8 @@ Some useful examples of how this project can be used: * Install requirements ```sh - pip install --user --upgrade uv uv venv - uv run task '.[dev]' + uv pip install '.[dev]' ``` * Run tests From 9eb6ba5d125a861a632db4ba7a713c0570e79068 Mon Sep 17 00:00:00 2001 From: eol Date: Fri, 25 Apr 2025 22:20:29 +0700 Subject: [PATCH 5/5] Improving pytest with markers and run smoke and unit tests before others --- {{cookiecutter.project_slug}}/pyproject.toml | 39 +++++++++++++++----- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 5af9d23..d36a6a2 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -76,17 +76,23 @@ pydocstyle.convention = "google" [tool.pytest.ini_options] minversion = "6.0" +markers = [ + "slow: marks tests as slow (deselect with '-m \"not slow\"')", + "unit", + "integration", + "system", + "acceptance", + "regression", + "smoke", + "sanity", + "performance", + "security", + "performance", +] addopts = """ --maxfail=1 \ --color=yes \ ---cov={{cookiecutter.package_name}} \ ---html=docs/pytest_report.html \ ---self-contained-html \ ---cov-fail-under={{cookiecutter.minimum_coverage}} \ ---cov-report term-missing \ ---cov-report html:docs/cov-report \ ---doctest-modules \ ---cov-config=pyproject.toml""" +""" testpaths = [ "tests", "{{cookiecutter.package_name}}" @@ -110,7 +116,22 @@ exclude_lines = [ [tool.taskipy.tasks] run = "python -m {{cookiecutter.package_name}}.{{cookiecutter.module_name}}" -test = "pytest" +test-report = """\ +pytest \ + --cov-config=pyproject.toml \ + --doctest-modules \ + --cov-fail-under=90 \ + --cov-report=term-missing \ + --cov-report=html:docs/cov-report \ + --html=docs/pytest_report.html \ + --self-contained-html\ +""" +test = """\ +python -c "import subprocess, sys; print('Running Smoke Tests...'); sys.exit(0 if subprocess.run(['pytest', '-m', 'smoke']).returncode in (0,5) else 1)" && \ +python -c "import subprocess, sys; print('Running Unit Tests...'); sys.exit(0 if subprocess.run(['pytest', '-m', 'unit']).returncode in (0,5) else 1)" && \ +python -c "print('Running Tests...');" && \ +task test-report\ +""" ruff-check = "ruff check **/*.py --fix" ruff-format = "ruff format **/*.py" lint = "task ruff-check && task ruff-format"