Skip to content

Commit 9aef9a5

Browse files
committed
Merge branch 'release/3.3.4'
2 parents 739a07d + 689cb0e commit 9aef9a5

4 files changed

Lines changed: 47 additions & 12 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{cookiecutter.project_name | upper}}_RELOAD=True
22
{%- if cookiecutter.db_info.name == "sqlite" %}
33
{{cookiecutter.project_name | upper}}_DB_FILE=db.sqlite3
4-
{%- else %}
4+
{%- elif cookiecutter.db_info.name != 'none' %}
55
{{cookiecutter.project_name | upper}}_DB_HOST=localhost
66
{%- endif %}

fastapi_template/template/{{cookiecutter.project_name}}/.github/workflows/tests.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ jobs:
4747
run: poetry run mypy .
4848
pytest:
4949
runs-on: ubuntu-latest
50-
{%- if cookiecutter.db_info.name != "none" %}
51-
{%- if cookiecutter.db_info.name != "sqlite" %}
50+
{%- if ((cookiecutter.db_info.name != "none" and cookiecutter.db_info.name != "sqlite") or
51+
(cookiecutter.enable_rmq == "True")) %}
5252
services:
53+
{%- if cookiecutter.db_info.name != "none" and cookiecutter.db_info.name != "sqlite" %}
5354
{{cookiecutter.project_name}}-db:
5455
image: {{ cookiecutter.db_info.image }}
5556
env:
@@ -72,7 +73,18 @@ jobs:
7273
{%- endif %}
7374
ports:
7475
- {{ cookiecutter.db_info.port }}
75-
{%- endif %}
76+
{%- endif %}
77+
{%- if cookiecutter.enable_rmq == "True" %}
78+
{{cookiecutter.project_name}}-rmq:
79+
image: rabbitmq:3.9.16-alpine
80+
env:
81+
RABBITMQ_DEFAULT_USER: "guest"
82+
RABBITMQ_DEFAULT_PASS: "guest"
83+
RABBITMQ_DEFAULT_VHOST: "/"
84+
options: --health-cmd="rabbitmq-diagnostics check_running -q" --health-interval=10s --health-timeout=5s --health-retries=8
85+
ports:
86+
- 5672
87+
{%- endif %}
7688
{%- endif %}
7789
steps:
7890
- uses: actions/checkout@v2
@@ -86,10 +98,15 @@ jobs:
8698
POETRY_VIRTUALENVS_CREATE: false
8799
- name: Run pytest check
88100
run: poetry run pytest -vv --cov="{{cookiecutter.project_name}}" .
101+
env:
102+
{{ cookiecutter.project_name | upper }}_HOST: "0.0.0.0"
89103
{%- if cookiecutter.db_info.name != "none" %}
90104
{%- if cookiecutter.db_info.name != "sqlite" %}
91-
env:
92105
{{ cookiecutter.project_name | upper }}_DB_HOST: localhost
93106
{{ cookiecutter.project_name | upper }}_DB_PORT: {{'${{'}}job.services.{{cookiecutter.project_name}}-db.ports['{{cookiecutter.db_info.port}}']{{'}}'}}
94107
{%- endif %}
95108
{%- endif %}
109+
{%- if cookiecutter.enable_rmq == "True" %}
110+
{{ cookiecutter.project_name | upper }}_RABBIT_HOST: localhost
111+
{{ cookiecutter.project_name | upper }}_RABBIT_PORT: {{'${{'}}job.services.{{cookiecutter.project_name}}-rmq.ports['5672']{{'}}'}}
112+
{%- endif %}

fastapi_template/template/{{cookiecutter.project_name}}/.gitlab-ci.yml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,37 @@ mypy:
3535
pytest:
3636
extends:
3737
- .test-template
38-
{%- if cookiecutter.db_info.name != "none" %}
39-
{%- if cookiecutter.db_info.name != "sqlite" %}
38+
{%- if ((cookiecutter.db_info.name != "none" and cookiecutter.db_info.name != "sqlite") or
39+
(cookiecutter.enable_rmq == "True")) %}
4040
services:
41+
{%- if cookiecutter.db_info.name != "none" and cookiecutter.db_info.name != "sqlite" %}
4142
- name: {{ cookiecutter.db_info.image }}
43+
alias: database
44+
{%- endif %}
45+
{%- if cookiecutter.enable_rmq == "True" %}
46+
- name: rabbitmq:3.9.16-alpine
47+
alias: rmq
48+
{%- endif %}
4249
variables:
4350
{%- if cookiecutter.db_info.name == "postgresql" %}
44-
{{ cookiecutter.project_name | upper }}_DB_HOST: localhost
51+
{{ cookiecutter.project_name | upper }}_DB_HOST: database
4552
POSTGRES_PASSWORD: {{ cookiecutter.project_name }}
4653
POSTGRES_USER: {{ cookiecutter.project_name }}
4754
POSTGRES_DB: {{ cookiecutter.project_name }}
4855
{%- endif %}
4956
{%- if cookiecutter.db_info.name == "mysql" %}
50-
{{ cookiecutter.project_name | upper }}_DB_HOST: localhost
57+
{{ cookiecutter.project_name | upper }}_DB_HOST: database
5158
MYSQL_PASSWORD: {{ cookiecutter.project_name }}
5259
MYSQL_USER: {{ cookiecutter.project_name }}
5360
MYSQL_DATABASE: {{ cookiecutter.project_name }}
5461
ALLOW_EMPTY_PASSWORD: yes
5562
{%- endif %}
56-
{%- endif %}
63+
{%- if cookiecutter.enable_rmq == "True" %}
64+
RABBITMQ_DEFAULT_USER: "guest"
65+
RABBITMQ_DEFAULT_PASS: "guest"
66+
RABBITMQ_DEFAULT_VHOST: "/"
67+
{{ cookiecutter.project_name | upper }}_RABBIT_HOST: rmq
68+
{%- endif %}
5769
{%- endif %}
5870
script:
5971
{%- if cookiecutter.db_info.name != "none" %}
@@ -63,4 +75,10 @@ pytest:
6375
- wait-for-it -t 180 ${{ cookiecutter.project_name | upper }}_DB_HOST:{{cookiecutter.db_info.port}}
6476
{%- endif %}
6577
{%- endif %}
66-
- pytest -vv --cov="{{cookiecutter.project_name}}" .
78+
- pytest -vv --junitxml=report.xml --cov="{{cookiecutter.project_name}}" .
79+
- coverage xml
80+
artifacts:
81+
when: always
82+
reports:
83+
cobertura: coverage.xml
84+
junit: report.xml

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "fastapi_template"
3-
version = "3.3.3"
3+
version = "3.3.4"
44
description = "Feature-rich robust FastAPI template"
55
authors = ["Pavel Kirilin <win10@list.ru>"]
66
packages = [{ include = "fastapi_template" }]

0 commit comments

Comments
 (0)