diff --git a/fastapi_template/template/{{cookiecutter.project_name}}/.gitignore b/fastapi_template/template/{{cookiecutter.project_name}}/.gitignore index ded1f6c..5919923 100644 --- a/fastapi_template/template/{{cookiecutter.project_name}}/.gitignore +++ b/fastapi_template/template/{{cookiecutter.project_name}}/.gitignore @@ -62,8 +62,8 @@ cover/ # Django stuff: *.log local_settings.py -db.sqlite3 -db.sqlite3-journal +*.sqlite3 +*.sqlite3-journal # Flask stuff: instance/ diff --git a/fastapi_template/template/{{cookiecutter.project_name}}/.gitlab-ci.yml b/fastapi_template/template/{{cookiecutter.project_name}}/.gitlab-ci.yml index 049673b..40b17b8 100644 --- a/fastapi_template/template/{{cookiecutter.project_name}}/.gitlab-ci.yml +++ b/fastapi_template/template/{{cookiecutter.project_name}}/.gitlab-ci.yml @@ -104,5 +104,8 @@ pytest: artifacts: when: always reports: - cobertura: coverage.xml junit: report.xml + coverage_report: + coverage_format: cobertura + path: coverage.xml + diff --git a/fastapi_template/template/{{cookiecutter.project_name}}/conditional_files.json b/fastapi_template/template/{{cookiecutter.project_name}}/conditional_files.json index 16fcd6b..3fa66f1 100644 --- a/fastapi_template/template/{{cookiecutter.project_name}}/conditional_files.json +++ b/fastapi_template/template/{{cookiecutter.project_name}}/conditional_files.json @@ -213,7 +213,7 @@ "Taskiq support":{ "enabled": "{{cookiecutter.enable_taskiq}}", "resources": [ - "{{cookiecutter.project_name}}/taskiq.py" + "{{cookiecutter.project_name}}/tkq.py" ] } } diff --git a/fastapi_template/template/{{cookiecutter.project_name}}/deploy/docker-compose.yml b/fastapi_template/template/{{cookiecutter.project_name}}/deploy/docker-compose.yml index 8df7be3..534c4ce 100644 --- a/fastapi_template/template/{{cookiecutter.project_name}}/deploy/docker-compose.yml +++ b/fastapi_template/template/{{cookiecutter.project_name}}/deploy/docker-compose.yml @@ -80,7 +80,7 @@ services: command: - taskiq - worker - - {{cookiecutter.project_name}}.taskiq:broker + - {{cookiecutter.project_name}}.tkq:broker {%- endif %} {%- if cookiecutter.db_info.name == "postgresql" %} diff --git a/fastapi_template/template/{{cookiecutter.project_name}}/pyproject.toml b/fastapi_template/template/{{cookiecutter.project_name}}/pyproject.toml index 87a0ac2..c64de9c 100644 --- a/fastapi_template/template/{{cookiecutter.project_name}}/pyproject.toml +++ b/fastapi_template/template/{{cookiecutter.project_name}}/pyproject.toml @@ -119,6 +119,24 @@ loguru = "^0.6.0" {%- if cookiecutter.enable_kafka == "True" %} aiokafka = "^0.8.0" {%- endif %} +{%- if cookiecutter.enable_taskiq == "True" %} +taskiq = "^0" +taskiq-fastapi = "^0" + + {%- if cookiecutter.enable_redis == "True" %} +taskiq-redis = "^0" + {%- endif %} + + {%- if cookiecutter.enable_rmq == "True" %} +taskiq-aio-pika = "^0" + {%- endif %} + + {%- if (cookiecutter.enable_rmq or cookiecutter.enable_rmq) != "True" %} +pyzmq = "^25.0.2" + {%- endif %} + +{%- endif %} + [tool.poetry.dev-dependencies] pytest = "^7.2.1" @@ -140,23 +158,7 @@ asynctest = "^0.13.0" nest-asyncio = "^1.5.6" {%- endif %} httpx = "^0.23.3" -{%- if cookiecutter.enable_taskiq == "True" %} -taskiq = "^0" -taskiq-fastapi = "^0" - - {%- if cookiecutter.enable_redis == "True" %} -taskiq-redis = "^0" - {%- endif %} - - {%- if cookiecutter.enable_rmq == "True" %} -taskiq-aio-pika = "^0" - {%- endif %} - - {%- if (cookiecutter.enable_rmq or cookiecutter.enable_rmq) != "True" %} -pyzmq = "^25.0.2" - {%- endif %} - -{%- endif %} +taskiq = { version = "^0", extras = ["reload"] } [tool.isort] profile = "black" diff --git a/fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/taskiq.py b/fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/tkq.py similarity index 64% rename from fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/taskiq.py rename to fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/tkq.py index 1694a8f..4ed1cdb 100644 --- a/fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/taskiq.py +++ b/fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/tkq.py @@ -11,11 +11,6 @@ from taskiq_aio_pika import AioPikaBroker {%- endif %} -{%- if cookiecutter.enable_loguru %} -from {{cookiecutter.project_name}}.logging import configure_logging -{%- endif %} - - {%- if cookiecutter.enable_redis == "True" %} result_backend = RedisAsyncResultBackend( redis_url=str(settings.redis_url.with_path("/1")), @@ -24,9 +19,15 @@ {%- if cookiecutter.enable_rmq == "True" %} -broker = AioPikaBroker(str(settings.rabbit_url), {%- if cookiecutter.enable_redis == "True" %}result_backend=result_backend, {%- endif %}) +broker = AioPikaBroker( + str(settings.rabbit_url), + {%- if cookiecutter.enable_redis == "True" %}result_backend=result_backend, {%- endif %} +) {%- elif cookiecutter.enable_redis == "True" %} -broker = ListQueueBroker(str(settings.redis_url.with_path("/1")), result_backend=result_backend,) +broker = ListQueueBroker( + str(settings.redis_url.with_path("/1")), + result_backend=result_backend, +) {%- else %} broker = ZeroMQBroker() {%- endif %} @@ -34,4 +35,7 @@ if settings.environment.lower() == "pytest": broker = InMemoryBroker() -taskiq_fastapi.init(broker, "tkiqtest.web.application:get_app") +taskiq_fastapi.init( + broker, + "{{cookiecutter.project_name}}.web.application:get_app", +) diff --git a/fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/web/lifetime.py b/fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/web/lifetime.py index 5da0422..9d083fd 100644 --- a/fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/web/lifetime.py +++ b/fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/web/lifetime.py @@ -21,7 +21,7 @@ {%- endif %} {%- if cookiecutter.enable_taskiq == "True" %} -from {{cookiecutter.project_name}}.taskiq import broker +from {{cookiecutter.project_name}}.tkq import broker {%- endif %} diff --git a/fastapi_template/tests/utils.py b/fastapi_template/tests/utils.py index 9752be0..4572342 100644 --- a/fastapi_template/tests/utils.py +++ b/fastapi_template/tests/utils.py @@ -1,4 +1,5 @@ import os +import shlex import subprocess from typing import Optional from fastapi_template.input_model import BuilderContext @@ -26,7 +27,7 @@ def run_docker_compose_command( ".", ] if command: - docker_command.extend(command.split()) + docker_command.extend(shlex.split(command)) else: docker_command.extend( [ diff --git a/pyproject.toml b/pyproject.toml index 9b862df..ca87cdc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "fastapi_template" -version = "4.1.1" +version = "4.1.2" description = "Feature-rich robust FastAPI template" authors = ["Pavel Kirilin "] packages = [{ include = "fastapi_template" }]