Add mysql to GitHub CI

This commit is contained in:
Klaas van Schelven
2025-03-05 10:36:54 +01:00
parent d400d98a02
commit d5a6f03a2e
3 changed files with 31 additions and 16 deletions

View File

@@ -34,12 +34,24 @@ jobs:
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
db: [sqlite, mysql]
include:
- db: mysql
db_user: root
db_password: root
env:
DB: ${{ matrix.db }}
DB_USER: ${{ matrix.db_user }}
DB_PASSWORD: ${{ matrix.db_password }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Start MySQL If Needed
if: matrix.db == 'mysql'
run: sudo systemctl start mysql.service
- name: Install build
run: |
python -m pip install --upgrade pip
@@ -53,6 +65,7 @@ jobs:
- name: Install development dependencies
run: |
pip install -r requirements.development.txt
pip install mysqlclient
- name: Check out event-samples
uses: actions/checkout@master
with:

View File

@@ -40,13 +40,25 @@ DEBUG_TOOLBAR_CONFIG = {
}
# In development, we just keep the databases inside the root directory of the source-code. In production this is "not
# recommended" (very foolish): this path maps to the virualenv's root directory, which is not a good place to store
# databases.
DATABASES["default"]["NAME"] = BASE_DIR / 'db.sqlite3'
DATABASES["default"]["TEST"]["NAME"] = BASE_DIR / 'test.sqlite3'
DATABASES["snappea"]["NAME"] = BASE_DIR / 'snappea.sqlite3'
# this way of configuring (DB, DB_USER, DB_PASSWORD) is specific to the development environment
if os.getenv("DB", "sqlite") == "mysql":
DATABASES['default'] = {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'bugsink',
'USER': os.environ["DB_USER"],
'PASSWORD': os.environ["DB_PASSWORD"],
}
elif os.getenv("DB", "sqlite") == "sqlite":
# In development, we just keep the databases inside the root directory of the source-code. In production this is
# "not recommended" (very foolish): this path maps to the virualenv's root directory, which is not a good place to
# store databases.
DATABASES["default"]["NAME"] = BASE_DIR / 'db.sqlite3'
DATABASES["default"]["TEST"]["NAME"] = BASE_DIR / 'test.sqlite3'
DATABASES["snappea"]["NAME"] = BASE_DIR / 'snappea.sqlite3'
else:
raise ValueError("Unknown DB", os.getenv("DB"))
# { postponed, for starters we'll do something like SNAPPEA_ALWAYS_EAGER
# DATABASES["snappea"]["TEST"]["NAME"] = BASE_DIR / 'test.snappea.sqlite3'

View File

@@ -1,10 +0,0 @@
from .development import * # noqa
from .development import DATABASES
DATABASES['default'] = {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'bugsink',
'USER': 'bugsink',
'PASSWORD': 'bugsink',
}