From 84e03b2ae97de409be560bed7750a74c35a0aa9d Mon Sep 17 00:00:00 2001 From: boris Date: Mon, 22 Sep 2025 20:08:12 +0100 Subject: [PATCH] Fixed alembic errors in CI (maybe) --- .github/workflows/ci.yml | 6 ++++ alembic/env.py | 12 ++++---- pyproject.toml | 60 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 107abd9..27f0711 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,15 +71,21 @@ jobs: key: pip-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('**/requirements.txt') }} restore-keys: | pip-${{ runner.os }}-${{ env.PYTHON_VERSION }}- + - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt + - name: Create .env for tests run: | printf "KEYWARDEN_POSTGRES_DSN=%s\nKEYWARDEN_SECRET_KEY=%s\nKEYWARDEN_ACCESS_TOKEN_EXPIRE_MINUTES=60\n" \ "${{ env.TEST_POSTGRES_DSN }}" "testsecret" > .env echo "Wrote .env with DSN=${{ env.TEST_POSTGRES_DSN }}" + + - name: Set PYTHONPATH + run: echo "PYTHONPATH=${GITHUB_WORKSPACE}" >> $GITHUB_ENV + - name: Run Alembic migrations env: KEYWARDEN_POSTGRES_DSN: ${{ env.TEST_POSTGRES_DSN }} diff --git a/alembic/env.py b/alembic/env.py index 43cef03..19860d1 100644 --- a/alembic/env.py +++ b/alembic/env.py @@ -1,9 +1,11 @@ -import asyncio +import sys, pathlib + +# Add project root (parent of the "alembic" dir) to sys.path +PROJECT_ROOT = pathlib.Path(__file__).resolve().parents[1] +if str(PROJECT_ROOT) not in sys.path: + sys.path.insert(0, str(PROJECT_ROOT)) + from logging.config import fileConfig - -from sqlalchemy import pool -from sqlalchemy.ext.asyncio import AsyncEngine, create_async_engine - from alembic import context # Import your app's config & models diff --git a/pyproject.toml b/pyproject.toml index e69de29..110e11d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -0,0 +1,60 @@ +[build-system] +requires = ["setuptools>=61.0", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "keywarden" +version = "0.1.0" +description = "A lightweight, self-hosted SSH key management and access auditing platform." +readme = "README.md" +requires-python = ">=3.11" +license = {text = "MIT"} +authors = [ + { name="George Wilkinson", email="admin@ntbx.io" } +] +dependencies = [ + "fastapi>=0.114", + "uvicorn[standard]>=0.30", + "SQLAlchemy[asyncio]>=2.0", + "asyncpg>=0.29", + "alembic>=1.13", + "python-jose[cryptography]>=3.3", + "passlib[argon2]>=1.7", + "pydantic-settings>=2.4", + "cryptography>=43", + "structlog>=24", + "prometheus-fastapi-instrumentator>=6.1" +] + +[project.optional-dependencies] +dev = [ + "pytest>=8.3", + "httpx>=0.27", + "ruff>=0.6", + "black>=24.8", + "mypy>=1.11" +] + +[tool.setuptools.packages.find] +where = ["."] +include = ["app*"] + +[tool.black] +line-length = 88 +target-version = ["py311"] + +[tool.ruff] +line-length = 88 +target-version = "py311" +select = ["E", "F", "I"] +ignore = ["E501"] # handled by black + +[tool.pytest.ini_options] +minversion = "8.0" +addopts = "-q" +testpaths = ["tests"] + +[tool.mypy] +python_version = "3.11" +strict = true +ignore_missing_imports = true \ No newline at end of file