Coverage for backend / app / main.py: 100%
19 statements
« prev ^ index » next coverage.py v7.14.0, created at 2026-06-19 09:10 +0000
« prev ^ index » next coverage.py v7.14.0, created at 2026-06-19 09:10 +0000
1from fastapi import FastAPI
2from redis.asyncio import Redis
4from app.config import get_settings
5from app.utils.github_client import GithubClient
6from app.utils.aws_storage import AWSStorage
7from app.routers.coverage import router as cov_upload_router
8from app.routers.badge import router as badge_router
11async def lifespan(_: FastAPI):
12 settings = get_settings()
13 redis_connection = None
14 if settings.redis_url is not None:
15 redis_connection = Redis.from_url(str(settings.redis_url))
16 async with (
17 AWSStorage(
18 access_key_id=settings.aws_access_key_id,
19 secret_access_key=settings.aws_secret_access_key,
20 bucket=settings.aws_bucket,
21 region=settings.aws_region,
22 upload_role_arn=settings.aws_upload_role_arn,
23 ) as aws_storage_client,
24 GithubClient(
25 token=settings.github_token,
26 ) as gh_client,
27 ):
28 yield {
29 "aws_storage_client": aws_storage_client,
30 "gh_client": gh_client,
31 "redis_connection": redis_connection,
32 }
33 if redis_connection is not None:
34 await redis_connection.aclose()
37app = FastAPI(lifespan=lifespan, openapi_url=None)
40app.include_router(cov_upload_router, prefix="/coverage")
42app.include_router(badge_router, prefix="/badge")