Skip to content

Commit 48a8b3f

Browse files
committed
fix: repair CI pipeline — Rust 1.85, SQLite test isolation, missing model imports
### Problems Fixed **1. Contracts Check (Anchor) — edition2024 error** `clap_lex-1.1.0` requires Cargo feature `edition2024`, which is not available in Rust 1.76. Updated to Rust 1.85 in both `ci.yml` and `contracts/rust-toolchain.toml`. **2. Backend Tests (pytest) — 204 failures, 125 errors** Root causes: - CI injected `DATABASE_URL=postgresql://...` as step-level env, conflicting with conftest.py's SQLite override. Removed the Postgres env vars and service — tests use in-memory SQLite as conftest intends. - Three model files with DB tables (`contributor_webhook`, `wallet_session`, `webhook_log`) were not imported in `init_db()`, so their tables were never created by `create_all()`. - `init_db()` silently swallowed all exceptions, causing missing-table errors to cascade as hundreds of unrelated test failures. Now re-raises in CI/test environments for immediate, clear failure. ### Changes - `.github/workflows/ci.yml`: Rust 1.76 → 1.85, remove Postgres service and DATABASE_URL override - `backend/app/database.py`: Add missing model imports, fail-fast in CI - `contracts/rust-toolchain.toml`: Channel 1.76 → 1.85
1 parent 72d63b0 commit 48a8b3f

File tree

3 files changed

+11
-18
lines changed

3 files changed

+11
-18
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ concurrency:
1515
env:
1616
PYTHON_VERSION: '3.11'
1717
NODE_VERSION: '20'
18-
RUST_VERSION: '1.76'
18+
RUST_VERSION: '1.85'
1919

2020
jobs:
2121
# ==================== BACKEND (Python/FastAPI) ====================
@@ -45,20 +45,6 @@ jobs:
4545
backend-tests:
4646
name: Backend Tests (pytest)
4747
runs-on: ubuntu-latest
48-
services:
49-
postgres:
50-
image: postgres:15
51-
env:
52-
POSTGRES_USER: test
53-
POSTGRES_PASSWORD: test
54-
POSTGRES_DB: test
55-
ports:
56-
- 5432:5432
57-
options: >-
58-
--health-cmd pg_isready
59-
--health-interval 10s
60-
--health-timeout 5s
61-
--health-retries 5
6248
steps:
6349
- name: Checkout
6450
uses: actions/checkout@v4
@@ -82,8 +68,6 @@ jobs:
8268
run: pytest tests/ -v --tb=short --cov=app --cov-report=xml --cov-report=term-missing
8369
env:
8470
PYTHONPATH: .
85-
DATABASE_URL: postgresql://test:test@localhost:5432/test
86-
TEST_DATABASE_URL: postgresql+asyncpg://test:test@localhost:5432/test
8771
SECRET_KEY: test-secret-key-for-ci
8872

8973
# ==================== FRONTEND (React/TypeScript) ====================

backend/app/database.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""
77

88
import os
9+
import sys
910
import uuid
1011
import logging
1112
from typing import AsyncGenerator
@@ -176,13 +177,21 @@ async def init_db() -> None:
176177
from app.models.lifecycle import BountyLifecycleLogDB # noqa: F401
177178
from app.models.escrow import EscrowTable, EscrowLedgerTable # noqa: F401
178179
from app.models.boost import BountyBoostTable # noqa: F401
180+
from app.models.contributor_webhook import ContributorWebhookDB # noqa: F401
181+
from app.models.wallet_session import WalletSession, SiwsNonce # noqa: F401
182+
from app.models.webhook_log import WebhookEventLogDB # noqa: F401
179183

180184
# NOTE: create_all is idempotent (skips existing tables). For
181185
# production schema changes use ``alembic upgrade head`` instead.
182186
await conn.run_sync(Base.metadata.create_all)
183187

184188
logger.info("Database schema initialized successfully")
185189
except Exception as e:
190+
# In test/CI environments, schema failures should be fatal so that
191+
# missing-table errors surface immediately instead of cascading
192+
# as hundreds of confusing test failures.
193+
if os.getenv("CI") or "pytest" in sys.modules:
194+
raise
186195
logger.warning(f"Database init warning (non-fatal): {e}")
187196
# Non-fatal -- tables may already exist. In-memory services work without DB.
188197

contracts/rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "1.76"
2+
channel = "1.85"
33
components = ["rustfmt", "clippy"]

0 commit comments

Comments
 (0)