From d80734bd51927465ee5dbefe794fb0e2d9526789 Mon Sep 17 00:00:00 2001 From: Space-Banane Date: Fri, 22 May 2026 19:32:56 +0200 Subject: [PATCH] ci: fix mariaDB host and wait before alembic --- .gitea/workflows/ci.yml | 45 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 22ebe82..0aac3db 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -20,10 +20,10 @@ jobs: ports: - 3306:3306 options: >- - --health-cmd "mariadb-admin ping -h localhost -uroot -prootpass" - --health-interval 10s + --health-cmd "mariadb-admin ping -h 127.0.0.1 -uroot -prootpass" + --health-interval 5s --health-timeout 5s - --health-retries 10 + --health-retries 20 env: GITEA_BASE_URL: https://gitea.reversed.dev @@ -34,12 +34,12 @@ jobs: ALLOWED_REPOS: org/repo COOLDOWN_SECONDS: 60 WEBHOOK_MODE: repo - DB_HOST: 127.0.0.1 + DB_HOST: mariadb DB_PORT: 3306 DB_NAME: gitea_codex DB_USER: 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 MAX_DIFF_BYTES: 200000 MAX_REVIEW_MINUTES: 10 @@ -53,6 +53,41 @@ jobs: run: | python -m pip install --upgrade pip 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 run: alembic upgrade head - name: Run tests