Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ebf69976d4 | |||
| 84c143c4e7 |
@@ -175,90 +175,3 @@ jobs:
|
|||||||
git tag "v${{ steps.calver.outputs.version }}"
|
git tag "v${{ steps.calver.outputs.version }}"
|
||||||
git push origin "v${{ steps.calver.outputs.version }}"
|
git push origin "v${{ steps.calver.outputs.version }}"
|
||||||
|
|
||||||
deploy-dev:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: [build-and-push]
|
|
||||||
if: always() && !cancelled() && github.event_name == 'push' && (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main')
|
|
||||||
steps:
|
|
||||||
- name: Checkout infra repo
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
repository: cartsnitch/infra
|
|
||||||
token: ${{ secrets.GITEA_TOKEN }}
|
|
||||||
ref: main
|
|
||||||
path: infra
|
|
||||||
|
|
||||||
- name: Install kubectl
|
|
||||||
uses: azure/setup-kubectl@v4
|
|
||||||
|
|
||||||
- name: Install kustomize
|
|
||||||
uses: imranismail/setup-kustomize@v2
|
|
||||||
|
|
||||||
- name: Determine image tag
|
|
||||||
id: api_tag
|
|
||||||
run: |
|
|
||||||
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
|
|
||||||
echo "tag=${{ needs.build-and-push.outputs.calver_tag }}" >> "$GITHUB_OUTPUT"
|
|
||||||
else
|
|
||||||
echo "tag=${{ needs.build-and-push.outputs.sha_tag }}" >> "$GITHUB_OUTPUT"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Update api image tag
|
|
||||||
if: needs.build-and-push.result == 'success'
|
|
||||||
run: |
|
|
||||||
cd infra/apps/overlays/dev
|
|
||||||
kustomize edit set image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.api_tag.outputs.tag }}
|
|
||||||
|
|
||||||
- name: Commit and push to infra
|
|
||||||
run: |
|
|
||||||
cd infra
|
|
||||||
git config user.name "cartsnitch-ci[bot]"
|
|
||||||
git config user.email "cartsnitch-ci[bot]@users.noreply.github.com"
|
|
||||||
git add apps/overlays/dev/kustomization.yaml
|
|
||||||
git commit -m "ci(dev): update api image"
|
|
||||||
git pull --rebase origin main
|
|
||||||
git push origin main
|
|
||||||
|
|
||||||
deploy-uat:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: [build-and-push]
|
|
||||||
if: always() && !cancelled() && github.event_name == 'push' && (github.ref == 'refs/heads/uat' || github.ref == 'refs/heads/main')
|
|
||||||
steps:
|
|
||||||
- name: Checkout infra repo
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
repository: cartsnitch/infra
|
|
||||||
token: ${{ secrets.GITEA_TOKEN }}
|
|
||||||
ref: main
|
|
||||||
path: infra
|
|
||||||
|
|
||||||
- name: Install kubectl
|
|
||||||
uses: azure/setup-kubectl@v4
|
|
||||||
|
|
||||||
- name: Install kustomize
|
|
||||||
uses: imranismail/setup-kustomize@v2
|
|
||||||
|
|
||||||
- name: Determine image tag
|
|
||||||
id: api_tag
|
|
||||||
run: |
|
|
||||||
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
|
|
||||||
echo "tag=${{ needs.build-and-push.outputs.calver_tag }}" >> "$GITHUB_OUTPUT"
|
|
||||||
else
|
|
||||||
echo "tag=${{ needs.build-and-push.outputs.sha_tag }}" >> "$GITHUB_OUTPUT"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Update api image tag
|
|
||||||
if: needs.build-and-push.result == 'success'
|
|
||||||
run: |
|
|
||||||
cd infra/apps/overlays/uat
|
|
||||||
kustomize edit set image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.api_tag.outputs.tag }}
|
|
||||||
|
|
||||||
- name: Commit and push to infra
|
|
||||||
run: |
|
|
||||||
cd infra
|
|
||||||
git config user.name "cartsnitch-ci[bot]"
|
|
||||||
git config user.email "cartsnitch-ci[bot]@users.noreply.github.com"
|
|
||||||
git add apps/overlays/uat/kustomization.yaml
|
|
||||||
git commit -m "ci(uat): update api image"
|
|
||||||
git pull --rebase origin main
|
|
||||||
git push origin main
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"gitea": {
|
||||||
|
"type": "http",
|
||||||
|
"url": "https://git-mcp.farh.net/mcp",
|
||||||
|
"headers": {
|
||||||
|
"Authorization": "Bearer ${GITEA_TOKEN}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,14 +6,21 @@ from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_asyn
|
|||||||
|
|
||||||
from cartsnitch_api.config import settings
|
from cartsnitch_api.config import settings
|
||||||
|
|
||||||
engine = create_async_engine(
|
|
||||||
settings.database_url,
|
def _build_engine_kwargs() -> dict:
|
||||||
echo=False,
|
url = settings.database_url
|
||||||
pool_size=10,
|
kwargs: dict = {"echo": False}
|
||||||
max_overflow=20,
|
if not url.startswith("sqlite"):
|
||||||
pool_pre_ping=True,
|
kwargs.update(
|
||||||
pool_recycle=3600,
|
pool_size=10,
|
||||||
)
|
max_overflow=20,
|
||||||
|
pool_pre_ping=True,
|
||||||
|
pool_recycle=3600,
|
||||||
|
)
|
||||||
|
return kwargs
|
||||||
|
|
||||||
|
|
||||||
|
engine = create_async_engine(settings.database_url, **_build_engine_kwargs())
|
||||||
async_session_factory = async_sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
|
async_session_factory = async_sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+7
-1
@@ -53,7 +53,7 @@ def disable_rate_limiting():
|
|||||||
def engine():
|
def engine():
|
||||||
"""Sync in-memory SQLite engine for model unit tests.
|
"""Sync in-memory SQLite engine for model unit tests.
|
||||||
|
|
||||||
Strips PostgreSQL-specific server_default expressions so SQLite can
|
Strips ALL PostgreSQL-specific server_default expressions so SQLite can
|
||||||
handle all column inserts without missing-function errors.
|
handle all column inserts without missing-function errors.
|
||||||
"""
|
"""
|
||||||
eng = create_engine("sqlite:///:memory:")
|
eng = create_engine("sqlite:///:memory:")
|
||||||
@@ -62,6 +62,9 @@ def engine():
|
|||||||
for col in table.columns.values():
|
for col in table.columns.values():
|
||||||
sd = col.server_default
|
sd = col.server_default
|
||||||
if sd is not None:
|
if sd is not None:
|
||||||
|
if not hasattr(sd, "expression"):
|
||||||
|
col.server_default = None
|
||||||
|
continue
|
||||||
expr_str = str(sd.expression).lower()
|
expr_str = str(sd.expression).lower()
|
||||||
if "gen_random_uuid" in expr_str or "gen_random_bytes" in expr_str:
|
if "gen_random_uuid" in expr_str or "gen_random_bytes" in expr_str:
|
||||||
col.server_default = None
|
col.server_default = None
|
||||||
@@ -93,6 +96,9 @@ async def db_engine():
|
|||||||
for col in table.columns.values():
|
for col in table.columns.values():
|
||||||
sd = col.server_default
|
sd = col.server_default
|
||||||
if sd is not None:
|
if sd is not None:
|
||||||
|
if not hasattr(sd, "expression"):
|
||||||
|
col.server_default = None
|
||||||
|
continue
|
||||||
expr_str = str(sd.expression).lower()
|
expr_str = str(sd.expression).lower()
|
||||||
if "gen_random_uuid" in expr_str or "gen_random_bytes" in expr_str:
|
if "gen_random_uuid" in expr_str or "gen_random_bytes" in expr_str:
|
||||||
col.server_default = None
|
col.server_default = None
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ def engine():
|
|||||||
for col in table.columns.values():
|
for col in table.columns.values():
|
||||||
sd = col.server_default
|
sd = col.server_default
|
||||||
if sd is not None:
|
if sd is not None:
|
||||||
|
if not hasattr(sd, "expression"):
|
||||||
|
col.server_default = None
|
||||||
|
continue
|
||||||
expr_str = str(sd.expression).lower()
|
expr_str = str(sd.expression).lower()
|
||||||
if "gen_random_uuid" in expr_str or "gen_random_bytes" in expr_str:
|
if "gen_random_uuid" in expr_str or "gen_random_bytes" in expr_str:
|
||||||
col.server_default = None
|
col.server_default = None
|
||||||
|
|||||||
Reference in New Issue
Block a user