@@ -13,128 +13,31 @@ jobs:
13
13
runs-on : ubuntu-latest
14
14
steps :
15
15
- uses : actions/checkout@v4
16
+ - name : Install poetry
17
+ run : pipx install poetry
16
18
- name : Set up Python
17
19
uses : actions/setup-python@v5
18
20
with :
19
21
python-version : ' 3.11'
22
+ cache : ' poetry'
20
23
- name : Install deps
21
24
run : poetry install
22
25
- name : Run lint check
23
26
run : poetry run pre-commit run -a {{ '${{' }} matrix.cmd {{ '}}' }}
24
27
pytest :
25
28
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 %}
112
29
steps :
113
- - uses : actions/checkout@v2
30
+ - uses : actions/checkout@v4
31
+ - name : Create .env
32
+ run : touch .env
114
33
- name : Set up Python
115
- uses : actions/setup-python@v2
34
+ uses : actions/setup-python@v5
116
35
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
140
43
0 commit comments