@@ -13,128 +13,31 @@ jobs:
1313 runs-on : ubuntu-latest
1414 steps :
1515 - uses : actions/checkout@v4
16+ - name : Install poetry
17+ run : pipx install poetry
1618 - name : Set up Python
1719 uses : actions/setup-python@v5
1820 with :
1921 python-version : ' 3.11'
22+ cache : ' poetry'
2023 - name : Install deps
2124 run : poetry install
2225 - name : Run lint check
2326 run : poetry run pre-commit run -a {{ '${{' }} matrix.cmd {{ '}}' }}
2427 pytest :
2528 runs-on : ubuntu-latest
26- {%- if ((cookiecutter.db_info.name != "none" and cookiecutter.db_info.name != "sqlite") or
27- (cookiecutter.enable_rmq == "True") or
28- (cookiecutter.enable_kafka == "True")) %}
29- services :
30- {%- if cookiecutter.db_info.name != "none" and cookiecutter.db_info.name != "sqlite" %}
31-
32- {{cookiecutter.project_name}}-db:
33- image : {{ cookiecutter.db_info.image }}
34- env :
35- {%- if cookiecutter.db_info.name == "postgresql" %}
36- POSTGRES_PASSWORD : {{ cookiecutter.project_name }}
37- POSTGRES_USER : {{ cookiecutter.project_name }}
38- POSTGRES_DB : {{ cookiecutter.project_name }}
39- {%- endif %}
40- {%- if cookiecutter.db_info.name == "mysql" %}
41- MYSQL_ROOT_PASSWORD : " {{ cookiecutter.project_name }}"
42- MYSQL_USER : " {{ cookiecutter.project_name }}"
43- MYSQL_DATABASE : " {{ cookiecutter.project_name }}"
44- {%- endif %}
45- {%- if cookiecutter.db_info.name == "mongodb" %}
46- MONGO_INITDB_ROOT_USERNAME : " {{ cookiecutter.project_name }}"
47- MONGO_INITDB_ROOT_PASSWORD : " {{ cookiecutter.project_name }}"
48- {%- endif %}
49- {%- if cookiecutter.db_info.name == "mysql" %}
50- options : >-
51- --health-cmd="mysqladmin ping --user={{ cookiecutter.project_name }} --password={{ cookiecutter.project_name }}"
52- --health-interval=15s
53- --health-timeout=5s
54- --health-retries=6
55- {%- endif %}
56- {%- if cookiecutter.db_info.name == "postgresql" %}
57- options : >-
58- --health-cmd="pg_isready"
59- --health-interval=10s
60- --health-timeout=5s
61- --health-retries=5
62- {%- endif %}
63- ports :
64- - {{ cookiecutter.db_info.port }}:{{ cookiecutter.db_info.port }}
65- {%- endif %}
66- {%- if cookiecutter.enable_rmq == "True" %}
67-
68- {{cookiecutter.project_name}}-rmq:
69- image : rabbitmq:3.9.16-alpine
70- env :
71- RABBITMQ_DEFAULT_USER : " guest"
72- RABBITMQ_DEFAULT_PASS : " guest"
73- RABBITMQ_DEFAULT_VHOST : " /"
74- options : >-
75- --health-cmd="rabbitmq-diagnostics check_running -q"
76- --health-interval=10s
77- --health-timeout=5s
78- --health-retries=8
79- ports :
80- - 5672:5672
81- {%- endif %}
82- {%- if cookiecutter.enable_kafka == "True" %}
83-
84- {{cookiecutter.project_name}}-zookeeper:
85- image : " bitnami/zookeeper:3.7.1"
86- env :
87- ALLOW_ANONYMOUS_LOGIN : " yes"
88- ZOO_LOG_LEVEL : " ERROR"
89- options : >-
90- --health-cmd="zkServer.sh status"
91- --health-interval=10s
92- --health-timeout=5s
93- --health-retries=8
94-
95- {{cookiecutter.project_name}}-kafka:
96- image : bitnami/kafka:3.2.0
97- env :
98- KAFKA_BROKER_ID : " 1"
99- ALLOW_PLAINTEXT_LISTENER : " yes"
100- KAFKA_CFG_LISTENERS : " PLAINTEXT://0.0.0.0:9092"
101- KAFKA_CFG_ADVERTISED_LISTENERS : " PLAINTEXT://localhost:9092"
102- KAFKA_CFG_ZOOKEEPER_CONNECT : " {{cookiecutter.project_name}}-zookeeper:2181"
103- options : >-
104- --health-cmd="kafka-topics.sh --list --bootstrap-server localhost:9092"
105- --health-interval=10s
106- --health-timeout=5s
107- --health-retries=8
108- ports :
109- - 9092:9092
110- {%- endif %}
111- {%- endif %}
11229 steps :
113- - uses : actions/checkout@v2
30+ - uses : actions/checkout@v4
31+ - name : Create .env
32+ run : touch .env
11433 - name : Set up Python
115- uses : actions/setup-python@v2
34+ uses : actions/setup-python@v5
11635 with :
117- python-version : ' 3.9'
118- - name : Install deps
119- uses : knowsuchagency/poetry-install@v1
120- env :
121- POETRY_VIRTUALENVS_CREATE : false
122- - name : Run pytest check
123- run : poetry run pytest -vv --cov="{{cookiecutter.project_name}}" .
124- env :
125- {{ cookiecutter.project_name | upper }}_HOST: "0.0.0.0"
126- {%- if cookiecutter.db_info.name != "none" %}
127- {%- if cookiecutter.db_info.name != "sqlite" %}
128- {{ cookiecutter.project_name | upper }}_DB_HOST: localhost
129- {%- endif %}
130- {%- if cookiecutter.db_info.name == "mongodb" %}
131- {{ cookiecutter.project_name | upper }}_DB_BASE: admin
132- {%- endif %}
133- {%- endif %}
134- {%- if cookiecutter.enable_rmq == "True" %}
135- {{ cookiecutter.project_name | upper }}_RABBIT_HOST: localhost
136- {%- endif %}
137- {%- if cookiecutter.enable_kafka == "True" %}
138- {{ cookiecutter.project_name | upper }}_KAFKA_BOOTSTRAP_SERVERS: '["localhost:9092"]'
139- {%- endif %}
36+ python-version : ' 3.11'
37+ - name : Update docker-compose
38+ uses : KengoTODA/actions-setup-docker-compose@v1
39+ with :
40+ version : " 2.28.0"
41+ - name : run tests
42+ run : docker-compose run --rm api pytest -vv
14043
0 commit comments