fix(ci): added skipif on mysql absence
Some checks failed
CI / Lint (ruff) (push) Successful in 12s
CI / SAST (bandit) (push) Successful in 15s
CI / Dependency audit (pip-audit) (push) Successful in 24s
CI / Test (Standard) (3.11) (push) Successful in 2m51s
CI / Test (Live) (3.11) (push) Failing after 1m2s
CI / Test (Fuzz) (3.11) (push) Has been skipped
CI / Merge dev → testing (push) Has been skipped
CI / Prepare Merge to Main (push) Has been skipped
CI / Finalize Merge to Main (push) Has been skipped

This commit is contained in:
2026-04-20 13:07:31 -04:00
parent 038596776a
commit 1b70d6db87
3 changed files with 18 additions and 3 deletions

View File

@@ -30,6 +30,13 @@ _PYTHON = str(_VENV_PYTHON) if _VENV_PYTHON.exists() else sys.executable
# Use search (not match) so lines prefixed by Twisted timestamps are handled. # Use search (not match) so lines prefixed by Twisted timestamps are handled.
_RFC5424_RE = re.compile(r"<\d+>1 \S+ \S+ \S+ - \S+ ") _RFC5424_RE = re.compile(r"<\d+>1 \S+ \S+ \S+ - \S+ ")
def _mysql_available() -> bool:
try:
s = socket.create_connection(("127.0.0.1", 3307), timeout=1)
s.close()
return True
except OSError:
return False
def _free_port() -> int: def _free_port() -> int:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:

View File

@@ -31,9 +31,9 @@ import pytest
from sqlalchemy import text from sqlalchemy import text
from sqlalchemy.ext.asyncio import create_async_engine from sqlalchemy.ext.asyncio import create_async_engine
from tests.live.conftest import _mysql_available
from decnet.web.db.mysql.repository import MySQLRepository from decnet.web.db.mysql.repository import MySQLRepository
LIVE_URL = "mysql+asyncmy://root:root@127.0.0.1:3307/decnet" LIVE_URL = "mysql+asyncmy://root:root@127.0.0.1:3307/decnet"
pytestmark = [ pytestmark = [
@@ -42,6 +42,10 @@ pytestmark = [
not (LIVE_URL and LIVE_URL.startswith("mysql")), not (LIVE_URL and LIVE_URL.startswith("mysql")),
reason="Set DECNET_DB_URL=mysql+aiomysql://... to run MySQL live tests", reason="Set DECNET_DB_URL=mysql+aiomysql://... to run MySQL live tests",
), ),
pytest.mark.skipif(
not _mysql_available(),
reason="MySQL not available on 127.0.0.1:3307"
)
] ]
@@ -63,7 +67,7 @@ def _url_with_db(server_url: str, db_name: str) -> str:
return urlunparse(parsed._replace(path=f"/{db_name}")) return urlunparse(parsed._replace(path=f"/{db_name}"))
@pytest.fixture(scope="session") @pytest.fixture(scope="module")
async def mysql_test_db_url(): async def mysql_test_db_url():
"""Create a per-worker throwaway database, yield its URL, drop it on teardown. """Create a per-worker throwaway database, yield its URL, drop it on teardown.

View File

@@ -1,8 +1,12 @@
import pytest import pytest
import pymysql import pymysql
from tests.live.conftest import assert_rfc5424 from tests.live.conftest import assert_rfc5424, _mysql_available
pytestmark = pytest.mark.skipif(
not _mysql_available(),
reason="MySQL not available on 127.0.0.1:3307"
)
@pytest.mark.live @pytest.mark.live
class TestMySQLLive: class TestMySQLLive: