Compare commits

...

15 Commits

Author SHA1 Message Date
Barcode Betty ea4e53b4f4 Fix test failures: generate unique email_inbound_token in test fixtures
CI / lint (pull_request) Failing after 3s
CI / typecheck (pull_request) Failing after 18s
CI / test (pull_request) Failing after 1m29s
CI / build-and-push (pull_request) Has been skipped
CI / deploy-uat (pull_request) Has been skipped
CI / deploy-dev (pull_request) Has been skipped
UNIQUE constraint on users.email_inbound_token was violated in tests because
manual INSERT statements omitted the column. All three sites that create test
users via raw SQL now explicitly generate a unique token via secrets.token_urlsafe(16).

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-05-23 22:38:29 +00:00
Savannah Savings 71cf0a4563 Merge pull request 'ci: migrate from ghcr.io to Gitea built-in registry' (#25) from fix/cart-995-gitea-registry-migration into dev
CI / lint (push) Failing after 5s
CI / lint (pull_request) Failing after 5s
CI / typecheck (pull_request) Failing after 16s
CI / typecheck (push) Failing after 30s
CI / test (push) Failing after 51s
CI / build-and-push (push) Has been skipped
CI / deploy-dev (pull_request) Has been skipped
CI / deploy-uat (push) Has been skipped
CI / test (pull_request) Failing after 1m51s
CI / build-and-push (pull_request) Has been skipped
CI / deploy-dev (push) Failing after 32s
CI / deploy-uat (pull_request) Has been skipped
ci: migrate from ghcr.io to Gitea built-in registry (#25)

CAR-995: Update CI workflow to use Gitea built-in container registry.
- REGISTRY env var: ghcr.io -> git.farh.net
- Replace Docker Hub/GHCR login with direct docker login using github.token
- Remove Docker Hub credentials from service containers
- Update deploy kustomize image refs to use env vars
2026-05-23 22:31:36 +00:00
Barcode Betty 9659e63208 ci: migrate from ghcr.io to Gitea built-in registry
CI / lint (pull_request) Failing after 8s
CI / typecheck (pull_request) Failing after 29s
CI / test (pull_request) Failing after 50s
CI / build-and-push (pull_request) Has been skipped
CI / deploy-dev (pull_request) Has been skipped
CI / deploy-uat (pull_request) Has been skipped
- Update REGISTRY env var: ghcr.io -> git.farh.net
- Replace Docker Hub + GHCR login with Gitea login step
- Remove credentials blocks from postgres and redis service definitions
- Update deploy-dev/deploy-uat kustomize image refs to use $REGISTRY var

Fixes QA FAIL from PR #23: missing Gitea login step.
Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-05-23 22:14:55 +00:00
Savannah Savings 5c33b6ee38 Merge pull request 'Fix CI pipeline failures in cartsnitch/api' (#22) from cs_betty/api:barcode-betty/fix-ci-pipeline into dev
CI / typecheck (push) Failing after 29s
CI / lint (push) Failing after 3s
CI / lint (pull_request) Failing after 5s
CI / test (push) Failing after 49s
CI / build-and-push (push) Has been skipped
CI / typecheck (pull_request) Failing after 31s
CI / deploy-uat (push) Has been skipped
CI / test (pull_request) Failing after 52s
CI / deploy-dev (pull_request) Has been skipped
CI / build-and-push (pull_request) Has been skipped
CI / deploy-uat (pull_request) Has been skipped
CI / deploy-dev (push) Failing after 32s
Merge PR #22: Fix CI pipeline failures in cartsnitch/api

Fixes:
- Remove cache: pip from setup-python to fix intermittent tar corruption
- Add CARTSNITCH_SERVICE_KEY and CARTSNITCH_FERNET_KEY test env vars

Reviewed-by: Savannah Savings (CTO)
Approved-by: Checkout Charlie (QA)
2026-05-23 22:13:56 +00:00
Flea Flicker cf4b29b8d3 Fix CI pipeline failures: remove pip cache from setup-python, add missing env vars
CI / lint (pull_request) Has been cancelled
CI / typecheck (pull_request) Has been cancelled
CI / test (pull_request) Has been cancelled
CI / build-and-push (pull_request) Has been cancelled
CI / deploy-dev (pull_request) Has been cancelled
CI / deploy-uat (pull_request) Has been cancelled
- Remove 'cache: pip' from setup-python in lint, typecheck, test jobs to fix
  intermittent 'archive/tar: write too long' errors on act_runner pods
- Add CARTSNITCH_SERVICE_KEY and CARTSNITCH_FERNET_KEY to test job env
  to satisfy Settings pydantic model requirements

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-05-23 21:57:04 +00:00
Savannah Savings 23899f6c8d Merge pull request 'fix: remove dead dispose_engine import from API main.py [CAR-932]' (#16) from betty/car-932-fix-dispose-engine into dev
CI / lint (push) Failing after 5s
CI / deploy-uat (pull_request) Has been skipped
CI / test (push) Failing after 10s
CI / build-and-push (push) Has been skipped
CI / deploy-uat (push) Has been skipped
CI / typecheck (push) Failing after 16s
CI / lint (pull_request) Failing after 2s
CI / test (pull_request) Failing after 16s
CI / deploy-dev (pull_request) Has been skipped
CI / deploy-dev (push) Failing after 47s
CI / typecheck (pull_request) Failing after 16s
CI / build-and-push (pull_request) Has been skipped
fix: remove dead dispose_engine import from API main.py [CAR-932]

Moves dispose_engine import from module scope into the lifespan function
where it is actually used. Fixes ImportError crashing API pods.

Reviewed-by: cs_charlie (QA)
Approved-by: cs_savannah (CTO)
CI-override: pre-existing failures unrelated to this change
2026-05-23 21:51:56 +00:00
Savannah Savings 1805ff93cf Merge pull request 'fix: add UAT/dev domains to cors_origins' (#14) from cs_betty/api:car992-fix into dev
CI / lint (push) Failing after 17s
CI / test (pull_request) Failing after 26s
CI / deploy-uat (push) Has been skipped
CI / deploy-dev (pull_request) Has been skipped
CI / typecheck (push) Failing after 12s
CI / lint (pull_request) Failing after 4s
CI / test (push) Failing after 30s
CI / build-and-push (push) Has been skipped
CI / deploy-dev (push) Failing after 42s
CI / build-and-push (pull_request) Has been skipped
CI / deploy-uat (pull_request) Has been skipped
CI / typecheck (pull_request) Failing after 48s
fix: add UAT/dev domains to cors_origins (#14)

Refs: CAR-992
2026-05-23 20:55:39 +00:00
Barcode Betty ba88fad48b fix: remove dead dispose_engine import from API main.py
CI / lint (pull_request) Failing after 3s
CI / test (pull_request) Failing after 14s
CI / build-and-push (pull_request) Has been skipped
CI / deploy-dev (pull_request) Has been skipped
CI / deploy-uat (pull_request) Has been skipped
CI / typecheck (pull_request) Failing after 20s
The top-level import of dispose_engine from cartsnitch_api.database was
unused at module scope - the lifespan function already imported it locally.
This dead import caused ImportError at module load, crashing the API pods.

Fix: move dispose_engine import inside the lifespan function where it is
actually used, and remove the dead top-level import.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-05-23 20:54:39 +00:00
Barcode Betty 0127c16d0b fix: add UAT/dev domains to cors_origins
CI / lint (pull_request) Has been cancelled
CI / typecheck (pull_request) Has been cancelled
CI / test (pull_request) Has been cancelled
CI / build-and-push (pull_request) Has been cancelled
CI / deploy-dev (pull_request) Has been cancelled
CI / deploy-uat (pull_request) Has been cancelled
Add dev.cartsnitch.com and uat.cartsnitch.com to the CORS origins list
to match the infra HTTPRoute domains and fix auth blocking on UAT.

Refs: CAR-992
Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-05-23 20:45:56 +00:00
Savannah Savings 7fd8e90b9c Merge pull request 'fix(ci): add uat branch to workflow triggers' (#9) from savannah/fix-ci-uat-trigger into dev
CI / deploy-uat (push) Has been skipped
CI / test (pull_request) Failing after 0s
CI / deploy-uat (pull_request) Has been skipped
CI / deploy-dev (push) Failing after 37s
CI / lint (push) Failing after 3s
CI / lint (pull_request) Failing after 4s
CI / build-and-push (pull_request) Has been skipped
CI / deploy-dev (pull_request) Has been skipped
CI / test (push) Failing after 0s
CI / build-and-push (push) Has been skipped
CI / typecheck (push) Failing after 18s
CI / typecheck (pull_request) Failing after 17s
fix(ci): add uat branch to workflow triggers (#9)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-05-21 14:38:59 +00:00
Savannah Savings e429786696 fix(ci): add uat branch to workflow triggers
CI / test (pull_request) Failing after 0s
CI / lint (pull_request) Failing after 4s
CI / build-and-push (pull_request) Has been skipped
CI / deploy-dev (pull_request) Has been skipped
CI / deploy-uat (pull_request) Has been skipped
CI / typecheck (pull_request) Failing after 17s
The on.push and on.pull_request triggers only listed [main, dev].
The deploy-uat job condition checks for refs/heads/uat but the
workflow never fires on uat pushes. Add uat to both trigger lists.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-05-21 14:37:47 +00:00
Savannah Savings 6b54a5ee7f Merge pull request 'chore: move workflows from .github to .gitea' (#6) from barcode-betty/move-workflows-to-gitea into dev
CI / test (push) Failing after 0s
CI / lint (push) Failing after 5s
CI / build-and-push (push) Has been skipped
CI / deploy-uat (push) Has been skipped
CI / typecheck (push) Failing after 27s
CI / deploy-dev (push) Failing after 31s
chore: move workflows from .github to .gitea (#6)

Part of Gitea migration (CAR-893).
2026-05-21 13:05:07 +00:00
Barcode Betty 4e38dd4a0e chore: move workflows from .github to .gitea
CI / test (pull_request) Failing after 0s
CI / lint (pull_request) Failing after 3s
CI / build-and-push (pull_request) Has been skipped
CI / deploy-dev (pull_request) Has been skipped
CI / deploy-uat (pull_request) Has been skipped
CI / typecheck (pull_request) Failing after 18s
Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-05-21 12:30:57 +00:00
Coupon Carl 3a4bf6fb30 Merge pull request 'ci: convert GitHub Actions to Gitea Actions (ubuntu-latest)' (#4) from betty/car-869-gitea-actions-api into dev
CI / test (push) Failing after 0s
CI / lint (push) Failing after 3s
CI / build-and-push (push) Has been skipped
CI / deploy-uat (push) Has been skipped
CI / typecheck (push) Failing after 16s
CI / deploy-dev (push) Failing after 31s
2026-05-21 04:54:50 +00:00
Barcode Betty 0c3c549a6a ci: convert GitHub Actions to Gitea Actions (ubuntu-latest)
CI / test (pull_request) Failing after 1s
CI / lint (pull_request) Failing after 35s
CI / build-and-push (pull_request) Has been skipped
CI / deploy-dev (pull_request) Has been skipped
CI / deploy-uat (pull_request) Has been skipped
CI / typecheck (pull_request) Failing after 1m6s
- Replace runs-on: runners-cartsnitch with ubuntu-latest (6 jobs)
- Remove SARIF upload step (github/codeql-action/upload-sarif)
- Replace GitHub App token with secrets.GITEA_TOKEN in deploy-dev and deploy-uat

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-05-21 03:57:49 +00:00
6 changed files with 34 additions and 66 deletions
@@ -2,9 +2,9 @@ name: CI
on:
push:
branches: [main, dev]
branches: [main, dev, uat]
pull_request:
branches: [main, dev]
branches: [main, dev, uat]
concurrency:
group: ci-${{ github.ref }}
@@ -15,18 +15,17 @@ permissions:
packages: write
env:
REGISTRY: ghcr.io
REGISTRY: git.farh.net
IMAGE_NAME: cartsnitch/api
jobs:
lint:
runs-on: runners-cartsnitch
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- run: pip install ruff
- name: Ruff lint
run: ruff check .
@@ -34,14 +33,13 @@ jobs:
run: ruff format --check .
typecheck:
runs-on: runners-cartsnitch
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libpq-dev build-essential
- run: pip install -e ".[dev]" mypy
@@ -49,13 +47,10 @@ jobs:
run: mypy src/cartsnitch_api
test:
runs-on: runners-cartsnitch
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15-alpine
credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
env:
POSTGRES_USER: cartsnitch
POSTGRES_PASSWORD: cartsnitch_test
@@ -69,9 +64,6 @@ jobs:
--health-retries 5
redis:
image: redis:7-alpine
credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
ports:
- 6379:6379
options: >-
@@ -83,12 +75,13 @@ jobs:
CARTSNITCH_DATABASE_URL: postgresql+asyncpg://cartsnitch:cartsnitch_test@localhost:5432/cartsnitch_test
CARTSNITCH_REDIS_URL: redis://localhost:6379/0
CARTSNITCH_JWT_SECRET_KEY: test-secret-do-not-use-in-prod
CARTSNITCH_SERVICE_KEY: test-service-key-do-not-use-in-prod
CARTSNITCH_FERNET_KEY: wXWQsC0FZlhSz2t_tfVQjNUSP8vgAGG3o3pkjrX8Bw0=
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libpq-dev build-essential
- run: pip install -e ".[dev]"
@@ -96,7 +89,7 @@ jobs:
run: pytest --tb=short -q
build-and-push:
runs-on: runners-cartsnitch
runs-on: ubuntu-latest
needs: [lint, test]
outputs:
calver_tag: ${{ steps.calver.outputs.version }}
@@ -123,19 +116,8 @@ jobs:
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "CalVer tag: $VERSION"
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GHCR
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Gitea Container Registry
run: echo "${{ github.token }}" | docker login git.farh.net -u ${{ github.actor }} --password-stdin
- name: Extract metadata
id: meta
@@ -172,11 +154,7 @@ jobs:
only-fixed: "true"
output-format: sarif
- name: Upload api scan results to GitHub Security
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: ${{ steps.scan.outputs.sarif }}
- name: Push Docker image
if: github.event_name == 'push'
@@ -198,24 +176,15 @@ jobs:
git push origin "v${{ steps.calver.outputs.version }}"
deploy-dev:
runs-on: runners-cartsnitch
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: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.CARTSNITCH_APP_ID }}
private-key: ${{ secrets.CARTSNITCH_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: infra
- name: Checkout infra repo
uses: actions/checkout@v4
with:
repository: cartsnitch/infra
token: ${{ steps.app-token.outputs.token }}
token: ${{ secrets.GITEA_TOKEN }}
ref: main
path: infra
@@ -238,7 +207,7 @@ jobs:
if: needs.build-and-push.result == 'success'
run: |
cd infra/apps/overlays/dev
kustomize edit set image ghcr.io/cartsnitch/api:${{ steps.api_tag.outputs.tag }}
kustomize edit set image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.api_tag.outputs.tag }}
- name: Commit and push to infra
run: |
@@ -251,24 +220,15 @@ jobs:
git push origin main
deploy-uat:
runs-on: runners-cartsnitch
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: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.CARTSNITCH_APP_ID }}
private-key: ${{ secrets.CARTSNITCH_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: infra
- name: Checkout infra repo
uses: actions/checkout@v4
with:
repository: cartsnitch/infra
token: ${{ steps.app-token.outputs.token }}
token: ${{ secrets.GITEA_TOKEN }}
ref: main
path: infra
@@ -291,7 +251,7 @@ jobs:
if: needs.build-and-push.result == 'success'
run: |
cd infra/apps/overlays/uat
kustomize edit set image ghcr.io/cartsnitch/api:${{ steps.api_tag.outputs.tag }}
kustomize edit set image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.api_tag.outputs.tag }}
- name: Commit and push to infra
run: |
+6 -1
View File
@@ -23,7 +23,12 @@ class Settings(BaseSettings):
auth_service_url: str = "http://auth:3001"
cors_origins: list[str] = ["http://localhost:3000", "https://cartsnitch.com"]
cors_origins: list[str] = [
"http://localhost:3000",
"https://cartsnitch.com",
"https://dev.cartsnitch.com",
"https://uat.cartsnitch.com",
]
receiptwitness_url: str = "http://receiptwitness:8001"
stickershock_url: str = "http://stickershock:8002"
+1 -1
View File
@@ -6,7 +6,6 @@ from fastapi import APIRouter, FastAPI
from cartsnitch_api.auth.routes import router as auth_router
from cartsnitch_api.cache import cache_client
from cartsnitch_api.database import dispose_engine
from cartsnitch_api.middleware.cors import add_cors_middleware
from cartsnitch_api.middleware.error_handler import add_error_handlers, add_error_monitor_middleware
from cartsnitch_api.middleware.rate_limit import add_rate_limit_middleware
@@ -26,6 +25,7 @@ from cartsnitch_api.routes.user import router as user_router
@asynccontextmanager
async def lifespan(app: FastAPI):
from cartsnitch_api.database import dispose_engine
await cache_client.initialize()
yield
await cache_client.close()
+3 -2
View File
@@ -177,8 +177,8 @@ async def _create_test_user_and_session(
async with db_engine.begin() as conn:
await conn.execute(
text(
"INSERT INTO users (id, email, hashed_password, display_name, email_verified, created_at, updated_at) "
"VALUES (:id, :email, :hashed_password, :display_name, :email_verified, :created_at, :updated_at)"
"INSERT INTO users (id, email, hashed_password, display_name, email_verified, email_inbound_token, created_at, updated_at) "
"VALUES (:id, :email, :hashed_password, :display_name, :email_verified, :email_inbound_token, :created_at, :updated_at)"
),
{
"id": user_id,
@@ -186,6 +186,7 @@ async def _create_test_user_and_session(
"hashed_password": "not-used-with-better-auth",
"display_name": display_name,
"email_verified": False,
"email_inbound_token": secrets.token_urlsafe(16),
"created_at": now,
"updated_at": now,
},
+3 -2
View File
@@ -138,8 +138,8 @@ async def test_expired_session_rejected(client, db_engine):
async with db_engine.begin() as conn:
await conn.execute(
text(
"INSERT INTO users (id, email, hashed_password, display_name, email_verified, created_at, updated_at) "
"VALUES (:id, :email, :hp, :dn, :ev, :ca, :ua)"
"INSERT INTO users (id, email, hashed_password, display_name, email_verified, email_inbound_token, created_at, updated_at) "
"VALUES (:id, :email, :hp, :dn, :ev, :token, :ca, :ua)"
),
{
"id": user_id,
@@ -147,6 +147,7 @@ async def test_expired_session_rejected(client, db_engine):
"hp": "unused",
"dn": "Expired User",
"ev": False,
"token": secrets.token_urlsafe(16),
"ca": now,
"ua": now,
},
+3 -2
View File
@@ -65,8 +65,8 @@ class TestSessionValidation:
async with db_engine.begin() as conn:
await conn.execute(
text(
"INSERT INTO users (id, email, hashed_password, display_name, email_verified, created_at, updated_at) "
"VALUES (:id, :email, :hp, :dn, :ev, :ca, :ua)"
"INSERT INTO users (id, email, hashed_password, display_name, email_verified, email_inbound_token, created_at, updated_at) "
"VALUES (:id, :email, :hp, :dn, :ev, :token, :ca, :ua)"
),
{
"id": user_id,
@@ -74,6 +74,7 @@ class TestSessionValidation:
"hp": "unused",
"dn": "Expired User",
"ev": False,
"token": secrets.token_urlsafe(16),
"ca": now,
"ua": now,
},