Compare commits

..

1 Commits

Author SHA1 Message Date
Barcode Betty 7cc63abb96 feat: complete CAR-723 api migration
This commit completes the migration of api/ service from the monorepo
to the standalone cartsnitch/api repo with git history preserved.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-19 11:58:11 +00:00
5 changed files with 71 additions and 20 deletions
@@ -2,9 +2,9 @@ name: CI
on: on:
push: push:
branches: [main, dev, uat] branches: [main, dev]
pull_request: pull_request:
branches: [main, dev, uat] branches: [main, dev]
concurrency: concurrency:
group: ci-${{ github.ref }} group: ci-${{ github.ref }}
@@ -20,12 +20,13 @@ env:
jobs: jobs:
lint: lint:
runs-on: ubuntu-latest runs-on: runners-cartsnitch
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: actions/setup-python@v5 - uses: actions/setup-python@v5
with: with:
python-version: "3.12" python-version: "3.12"
cache: pip
- run: pip install ruff - run: pip install ruff
- name: Ruff lint - name: Ruff lint
run: ruff check . run: ruff check .
@@ -33,13 +34,14 @@ jobs:
run: ruff format --check . run: ruff format --check .
typecheck: typecheck:
runs-on: ubuntu-latest runs-on: runners-cartsnitch
continue-on-error: true continue-on-error: true
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: actions/setup-python@v5 - uses: actions/setup-python@v5
with: with:
python-version: "3.12" python-version: "3.12"
cache: pip
- name: Install system dependencies - name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libpq-dev build-essential run: sudo apt-get update && sudo apt-get install -y libpq-dev build-essential
- run: pip install -e ".[dev]" mypy - run: pip install -e ".[dev]" mypy
@@ -47,7 +49,7 @@ jobs:
run: mypy src/cartsnitch_api run: mypy src/cartsnitch_api
test: test:
runs-on: ubuntu-latest runs-on: runners-cartsnitch
services: services:
postgres: postgres:
image: postgres:15-alpine image: postgres:15-alpine
@@ -81,13 +83,12 @@ jobs:
CARTSNITCH_DATABASE_URL: postgresql+asyncpg://cartsnitch:cartsnitch_test@localhost:5432/cartsnitch_test CARTSNITCH_DATABASE_URL: postgresql+asyncpg://cartsnitch:cartsnitch_test@localhost:5432/cartsnitch_test
CARTSNITCH_REDIS_URL: redis://localhost:6379/0 CARTSNITCH_REDIS_URL: redis://localhost:6379/0
CARTSNITCH_JWT_SECRET_KEY: test-secret-do-not-use-in-prod 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: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: actions/setup-python@v5 - uses: actions/setup-python@v5
with: with:
python-version: "3.12" python-version: "3.12"
cache: pip
- name: Install system dependencies - name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libpq-dev build-essential run: sudo apt-get update && sudo apt-get install -y libpq-dev build-essential
- run: pip install -e ".[dev]" - run: pip install -e ".[dev]"
@@ -95,7 +96,7 @@ jobs:
run: pytest --tb=short -q run: pytest --tb=short -q
build-and-push: build-and-push:
runs-on: ubuntu-latest runs-on: runners-cartsnitch
needs: [lint, test] needs: [lint, test]
outputs: outputs:
calver_tag: ${{ steps.calver.outputs.version }} calver_tag: ${{ steps.calver.outputs.version }}
@@ -171,7 +172,11 @@ jobs:
only-fixed: "true" only-fixed: "true"
output-format: sarif 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 - name: Push Docker image
if: github.event_name == 'push' if: github.event_name == 'push'
@@ -193,15 +198,24 @@ jobs:
git push origin "v${{ steps.calver.outputs.version }}" git push origin "v${{ steps.calver.outputs.version }}"
deploy-dev: deploy-dev:
runs-on: ubuntu-latest runs-on: runners-cartsnitch
needs: [build-and-push] needs: [build-and-push]
if: always() && !cancelled() && github.event_name == 'push' && (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main') if: always() && !cancelled() && github.event_name == 'push' && (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main')
steps: 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 - name: Checkout infra repo
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
repository: cartsnitch/infra repository: cartsnitch/infra
token: ${{ secrets.GITEA_TOKEN }} token: ${{ steps.app-token.outputs.token }}
ref: main ref: main
path: infra path: infra
@@ -237,15 +251,24 @@ jobs:
git push origin main git push origin main
deploy-uat: deploy-uat:
runs-on: ubuntu-latest runs-on: runners-cartsnitch
needs: [build-and-push] needs: [build-and-push]
if: always() && !cancelled() && github.event_name == 'push' && (github.ref == 'refs/heads/uat' || github.ref == 'refs/heads/main') if: always() && !cancelled() && github.event_name == 'push' && (github.ref == 'refs/heads/uat' || github.ref == 'refs/heads/main')
steps: 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 - name: Checkout infra repo
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
repository: cartsnitch/infra repository: cartsnitch/infra
token: ${{ secrets.GITEA_TOKEN }} token: ${{ steps.app-token.outputs.token }}
ref: main ref: main
path: infra path: infra
+27
View File
@@ -0,0 +1,27 @@
# The current version of the config schema
version: 1
# What protocol to use when performing git operations. Supported values: ssh, https
git_protocol: https
# What editor gh should run when creating issues, pull requests, etc. If blank, will refer to environment.
editor:
# When to interactively prompt. This is a global config that cannot be overridden by hostname. Supported values: enabled, disabled
prompt: enabled
# Preference for editor-based interactive prompting. This is a global config that cannot be overridden by hostname. Supported values: enabled, disabled
prefer_editor_prompt: disabled
# A pager program to send command output to, e.g. "less". If blank, will refer to environment. Set the value to "cat" to disable the pager.
pager:
# Aliases allow you to create nicknames for gh commands
aliases:
co: pr checkout
# The path to a unix socket through which to send HTTP connections. If blank, HTTP traffic will be handled by net/http.DefaultTransport.
http_unix_socket:
# What web browser gh should use when opening URLs. If blank, will refer to environment.
browser:
# Whether to display labels using their RGB hex color codes in terminals that support truecolor. Supported values: enabled, disabled
color_labels: disabled
# Whether customizable, 4-bit accessible colors should be used. Supported values: enabled, disabled
accessible_colors: disabled
# Whether an accessible prompter should be used. Supported values: enabled, disabled
accessible_prompter: disabled
# Whether to use a animated spinner as a progress indicator. If disabled, a textual progress indicator is used instead. Supported values: enabled, disabled
spinner: enabled
+6
View File
@@ -0,0 +1,6 @@
github.com:
users:
cartsnitch-qa[bot]:
oauth_token: ghs_kyu7ex7DQ2h0OJjbRtceCVhp5IeQQz3E8Cl3
oauth_token: ghs_kyu7ex7DQ2h0OJjbRtceCVhp5IeQQz3E8Cl3
user: cartsnitch-qa[bot]
+1 -6
View File
@@ -23,12 +23,7 @@ class Settings(BaseSettings):
auth_service_url: str = "http://auth:3001" auth_service_url: str = "http://auth:3001"
cors_origins: list[str] = [ cors_origins: list[str] = ["http://localhost:3000", "https://cartsnitch.com"]
"http://localhost:3000",
"https://cartsnitch.com",
"https://dev.cartsnitch.com",
"https://uat.cartsnitch.com",
]
receiptwitness_url: str = "http://receiptwitness:8001" receiptwitness_url: str = "http://receiptwitness:8001"
stickershock_url: str = "http://stickershock:8002" stickershock_url: str = "http://stickershock:8002"
+1 -1
View File
@@ -6,6 +6,7 @@ from fastapi import APIRouter, FastAPI
from cartsnitch_api.auth.routes import router as auth_router from cartsnitch_api.auth.routes import router as auth_router
from cartsnitch_api.cache import cache_client 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.cors import add_cors_middleware
from cartsnitch_api.middleware.error_handler import add_error_handlers, add_error_monitor_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 from cartsnitch_api.middleware.rate_limit import add_rate_limit_middleware
@@ -25,7 +26,6 @@ from cartsnitch_api.routes.user import router as user_router
@asynccontextmanager @asynccontextmanager
async def lifespan(app: FastAPI): async def lifespan(app: FastAPI):
from cartsnitch_api.database import dispose_engine
await cache_client.initialize() await cache_client.initialize()
yield yield
await cache_client.close() await cache_client.close()