ci: fix mariaDB host and wait before alembic
This commit is contained in:
@@ -20,10 +20,10 @@ jobs:
|
|||||||
ports:
|
ports:
|
||||||
- 3306:3306
|
- 3306:3306
|
||||||
options: >-
|
options: >-
|
||||||
--health-cmd "mariadb-admin ping -h localhost -uroot -prootpass"
|
--health-cmd "mariadb-admin ping -h 127.0.0.1 -uroot -prootpass"
|
||||||
--health-interval 10s
|
--health-interval 5s
|
||||||
--health-timeout 5s
|
--health-timeout 5s
|
||||||
--health-retries 10
|
--health-retries 20
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GITEA_BASE_URL: https://gitea.reversed.dev
|
GITEA_BASE_URL: https://gitea.reversed.dev
|
||||||
@@ -34,12 +34,12 @@ jobs:
|
|||||||
ALLOWED_REPOS: org/repo
|
ALLOWED_REPOS: org/repo
|
||||||
COOLDOWN_SECONDS: 60
|
COOLDOWN_SECONDS: 60
|
||||||
WEBHOOK_MODE: repo
|
WEBHOOK_MODE: repo
|
||||||
DB_HOST: 127.0.0.1
|
DB_HOST: mariadb
|
||||||
DB_PORT: 3306
|
DB_PORT: 3306
|
||||||
DB_NAME: gitea_codex
|
DB_NAME: gitea_codex
|
||||||
DB_USER: gitea_codex
|
DB_USER: gitea_codex
|
||||||
DB_PASSWORD: gitea_codex
|
DB_PASSWORD: gitea_codex
|
||||||
TEST_DATABASE_URL: mysql+pymysql://gitea_codex:gitea_codex@127.0.0.1:3306/gitea_codex?charset=utf8mb4
|
TEST_DATABASE_URL: mysql+pymysql://gitea_codex:gitea_codex@mariadb:3306/gitea_codex?charset=utf8mb4
|
||||||
WORKDIR: /tmp/work
|
WORKDIR: /tmp/work
|
||||||
MAX_DIFF_BYTES: 200000
|
MAX_DIFF_BYTES: 200000
|
||||||
MAX_REVIEW_MINUTES: 10
|
MAX_REVIEW_MINUTES: 10
|
||||||
@@ -53,6 +53,41 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install -e .[dev]
|
pip install -e .[dev]
|
||||||
|
- name: Wait for MariaDB
|
||||||
|
run: |
|
||||||
|
python - <<'PY'
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import pymysql
|
||||||
|
|
||||||
|
host = os.environ["DB_HOST"]
|
||||||
|
port = int(os.environ["DB_PORT"])
|
||||||
|
user = os.environ["DB_USER"]
|
||||||
|
password = os.environ["DB_PASSWORD"]
|
||||||
|
database = os.environ["DB_NAME"]
|
||||||
|
|
||||||
|
for _ in range(60):
|
||||||
|
try:
|
||||||
|
conn = pymysql.connect(
|
||||||
|
host=host,
|
||||||
|
port=port,
|
||||||
|
user=user,
|
||||||
|
password=password,
|
||||||
|
database=database,
|
||||||
|
connect_timeout=2,
|
||||||
|
read_timeout=2,
|
||||||
|
write_timeout=2,
|
||||||
|
)
|
||||||
|
conn.close()
|
||||||
|
print("MariaDB is ready")
|
||||||
|
raise SystemExit(0)
|
||||||
|
except Exception as exc:
|
||||||
|
print(f"Waiting for MariaDB: {exc}")
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
print("MariaDB did not become ready in time")
|
||||||
|
raise SystemExit(1)
|
||||||
|
PY
|
||||||
- name: Run Alembic migrations
|
- name: Run Alembic migrations
|
||||||
run: alembic upgrade head
|
run: alembic upgrade head
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
|
|||||||
Reference in New Issue
Block a user