Skip to content

Commit 7c729fd

Browse files
committed
add mysql job to CI #33
1 parent c2b712f commit 7c729fd

File tree

3 files changed

+82
-3
lines changed

3 files changed

+82
-3
lines changed

.github/workflows/test.yml

+66-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ jobs:
128128
file: ./coverage.xml
129129

130130
sqlite:
131-
132131
runs-on: ubuntu-latest
133132
env:
134133
DATABASE: sqlite
@@ -166,3 +165,69 @@ jobs:
166165
- name: Run Full Unit Tests
167166
run: |
168167
poetry run pytest --cov-fail-under=95
168+
169+
mysql:
170+
runs-on: ubuntu-latest
171+
env:
172+
DATABASE: mysql
173+
MYSQL_PASSWORD: password
174+
MYSQL_USER: root
175+
MYSQL_HOST: localhost
176+
MYSQL_PORT: 3306
177+
strategy:
178+
matrix:
179+
python-version: [ '3.7', '3.11']
180+
mysql-version: ['5.7', 'latest']
181+
django-version:
182+
- 'Django~=3.2.0' # LTS April 2024
183+
- 'Django~=4.2.0' # LTS April 2026
184+
exclude:
185+
- python-version: '3.7'
186+
django-version: 'Django~=4.2.0'
187+
- python-version: '3.11'
188+
django-version: 'Django~=3.2.0'
189+
- python-version: '3.7'
190+
mysql-version: 'latest'
191+
- python-version: '3.11'
192+
mysql-version: '5.7'
193+
194+
services:
195+
mysql:
196+
# Docker Hub image
197+
image: mysql:${{ matrix.mysql-version }}
198+
# Provide the password for mysql
199+
env:
200+
MYSQL_ROOT_PASSWORD: password
201+
MYSQL_DATABASE: test
202+
# Set health checks to wait until mysql has started
203+
options: >-
204+
--health-cmd mysqladmin ping
205+
--health-interval 10s
206+
--health-timeout 5s
207+
--health-retries 5
208+
ports:
209+
# Maps tcp port 3306 on service container to the host
210+
- 3306:3306
211+
212+
steps:
213+
- uses: actions/checkout@v2
214+
- uses: actions/setup-node@v2
215+
- name: Set up Python ${{ matrix.python-version }}
216+
uses: actions/setup-python@v2
217+
with:
218+
python-version: ${{ matrix.python-version }}
219+
220+
- name: Install Poetry
221+
uses: snok/install-poetry@v1
222+
with:
223+
virtualenvs-create: true
224+
virtualenvs-in-project: true
225+
- name: Install Dependencies
226+
run: |
227+
poetry config virtualenvs.in-project true
228+
poetry run pip install --upgrade pip
229+
poetry install -E all --with mysql
230+
poetry run pip install -U "${{ matrix.django-version }}"
231+
- name: Run Full Unit Tests
232+
run: |
233+
poetry run pytest --cov-fail-under=95

django_enum/tests/settings.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,19 @@
2929
'PORT': os.environ.get('POSTGRES_PORT', ''),
3030
}
3131
}
32-
# elif database == 'mysql': # pragma: no cover
33-
# pass
32+
elif database == 'mysql': # pragma: no cover
33+
import pymysql
34+
pymysql.install_as_MySQLdb()
35+
DATABASES = {
36+
"default": {
37+
"ENGINE": "django.db.backends.mysql",
38+
'NAME': os.environ.get('MYSQL_DB', 'test'),
39+
'USER': os.environ.get('MYSQL_USER', 'root'),
40+
'PASSWORD': os.environ.get('MYSQL_PASSWORD', ''),
41+
'HOST': os.environ.get('MYSQL_HOST', ''),
42+
'PORT': os.environ.get('MYSQL_PORT', ''),
43+
}
44+
}
3445
# elif database == 'mariadb': # pragma: no cover
3546
# pass
3647
# elif database == 'oracle': # pragma: no cover

pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ psycopg2 = "^2.5.4"
8181
[tool.poetry.group.psycopg3.dependencies]
8282
psycopg = "^3.1.8"
8383

84+
[tool.poetry.group.mysql.dependencies]
85+
mysqlclient = "^1.4.0"
86+
PyMySQL = "^1.0.0"
8487

8588
[build-system]
8689
requires = ["poetry-core>=1.0.0"]

0 commit comments

Comments
 (0)