Skip to content

Commit 7d8b8a0

Browse files
Resolve merge conflicts in pyproject.toml and uv.lock
Keep both modal and psycopg2-binary dependencies, regenerate lockfile. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2 parents 69b12cb + 9b65d39 commit 7d8b8a0

80 files changed

Lines changed: 5784 additions & 1754 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/settings.local.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(*)",
5+
"Read",
6+
"Edit",
7+
"Write",
8+
"Task",
9+
"Agent",
10+
"Explore",
11+
"Find",
12+
"Search",
13+
"WebSearch"
14+
]
15+
}
16+
}

.cursor/rules/general.mdc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ When building out features, always keep changes atomic and make sure to write an
1111
uv run pytest tests # or the path to a specific test file
1212
```
1313

14-
All code should be rigorously type hinted so as to pass a static type check with `mypy`. To run a `mypy` check, use:
14+
All code should be rigorously type hinted so as to pass a static type check with `ty`. To run a `ty` check, use:
1515

1616
```bash
17-
uv run mypy .
17+
uv run ty check .
1818
```

.devcontainer/devcontainer.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "FastAPI Jinja2 Postgres WebApp",
3+
"image": "mcr.microsoft.com/devcontainers/python:3.13-bookworm",
4+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
5+
6+
"features": {
7+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
8+
"ghcr.io/devcontainers/features/github-cli:1": {},
9+
"ghcr.io/devcontainers-extra/features/uv:1": {}
10+
},
11+
12+
"runArgs": [
13+
"--add-host=host.docker.internal:host-gateway"
14+
],
15+
16+
"remoteEnv": {
17+
"DOCKER_API_VERSION": "1.43"
18+
},
19+
20+
"forwardPorts": [8000, 5432],
21+
"portsAttributes": {
22+
"8000": { "label": "FastAPI", "onAutoForward": "openBrowser" },
23+
"5432": { "label": "PostgreSQL" }
24+
},
25+
"initializeCommand": "bash \"${localWorkspaceFolder}/.devcontainer/ensure-env.sh\"",
26+
"postStartCommand": "bash .devcontainer/post-start.sh",
27+
"postCreateCommand": "bash .devcontainer/init-env.sh && { curl -LsSf https://astral.sh/uv/install.sh | sh && ~/.local/bin/uv sync && curl -sSLO https://github.com/hetznercloud/cli/releases/latest/download/hcloud-linux-amd64.tar.gz && sudo tar -C /usr/local/bin --no-same-owner -xzf hcloud-linux-amd64.tar.gz hcloud && rm hcloud-linux-amd64.tar.gz; } >> /tmp/devcontainer-postcreate.log 2>&1",
28+
"customizations": {
29+
"vscode": {
30+
"extensions": [
31+
"ms-python.python",
32+
"ms-python.vscode-pylance",
33+
"anthropic.claude-code"
34+
]
35+
}
36+
}
37+
}

.devcontainer/docker-compose.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
services:
2+
db:
3+
image: postgres:16
4+
restart: unless-stopped
5+
ports:
6+
- "5432:5432"
7+
environment:
8+
POSTGRES_USER: ${DB_USER:-postgres}
9+
POSTGRES_PASSWORD: ${DB_PASSWORD:-postgres}
10+
POSTGRES_DB: ${DB_NAME:-fastapi-jinja2-postgres-webapp}
11+
volumes:
12+
- pgdata:/var/lib/postgresql/data
13+
14+
volumes:
15+
pgdata:

.devcontainer/ensure-env.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Run from repo root
5+
cd "$(dirname "${BASH_SOURCE[0]}")/.."
6+
7+
# Ensure a .env exists BEFORE docker compose evaluates env_file
8+
if [ ! -f ".env" ]; then
9+
if [ -f ".env.example" ]; then
10+
cp .env.example .env || true
11+
else
12+
touch .env
13+
fi
14+
fi
15+
16+
echo ".env ensured for compose evaluation."
17+

.devcontainer/init-env.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Run from repo root
5+
cd "$(dirname "${BASH_SOURCE[0]}")/.."
6+
7+
# Ensure a working .env exists
8+
if [ ! -f ".env" ]; then
9+
if [ -f ".env.example" ]; then
10+
cp .env.example .env || true
11+
else
12+
touch .env
13+
fi
14+
fi
15+
16+
# Ensure DB_HOST points to host.docker.internal for DooD sibling container access
17+
if grep -q '^DB_HOST=' .env; then
18+
sed -i 's/^DB_HOST=.*/DB_HOST=host.docker.internal/' .env
19+
else
20+
echo 'DB_HOST=host.docker.internal' >> .env
21+
fi
22+
23+
generate_secret() {
24+
if command -v openssl >/dev/null 2>&1; then
25+
openssl rand -base64 32
26+
else
27+
python - <<'PY'
28+
import base64, os
29+
print(base64.b64encode(os.urandom(32)).decode('ascii'))
30+
PY
31+
fi
32+
}
33+
34+
# Ensure SECRET_KEY exists and is non-empty/non-placeholder
35+
if grep -q '^SECRET_KEY=' .env; then
36+
current_secret="$(grep '^SECRET_KEY=' .env | cut -d= -f2-)"
37+
if [ -z "${current_secret}" ] || [ "${current_secret}" = "changeme" ] || [ "${current_secret}" = "REPLACE_ME" ]; then
38+
new_secret="$(generate_secret)"
39+
sed -i "s|^SECRET_KEY=.*|SECRET_KEY=${new_secret}|" .env
40+
fi
41+
else
42+
echo "SECRET_KEY=$(generate_secret)" >> .env
43+
fi
44+
45+
echo "Environment prepared. DB_HOST set to 'host.docker.internal' and SECRET_KEY ensured."
46+

.devcontainer/post-start.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Tee all output to a log file for post-hoc debugging
5+
exec > >(tee -a /tmp/devcontainer-poststart.log) 2>&1
6+
7+
cd "$(dirname "${BASH_SOURCE[0]}")/.."
8+
9+
docker compose -f .devcontainer/docker-compose.yml up -d

.env.example

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,28 @@ SECRET_KEY=
44
# Base URL
55
BASE_URL=http://localhost:8000
66

7-
# Database
8-
DB_USER=
9-
DB_PASSWORD=
10-
DB_HOST=localhost
7+
# Database connection mode (0 = direct, 1 = pooled)
8+
USE_POOL=0
9+
10+
# Shared database settings
11+
DB_HOST=127.0.0.1
12+
DB_SSLMODE=prefer
13+
14+
# Direct connection settings (when USE_POOL=0)
15+
DB_USER=postgres
16+
DB_PASSWORD=postgres
1117
DB_PORT=5432
1218
DB_NAME=
1319

20+
# Pooled connection settings (when USE_POOL=1)
21+
# DB_APPUSER=
22+
# DB_APPUSER_PASSWORD=
23+
# DB_POOL_PORT=6543
24+
# DB_POOL_NAME=
25+
26+
# Domain for production (used by Caddy for TLS)
27+
DOMAIN=
28+
1429
# Resend
1530
RESEND_API_KEY=
1631
EMAIL_FROM=

.github/workflows/release.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: release
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
release:
12+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Generate token for version incrementer app
16+
id: create_token
17+
uses: tibdex/github-app-token@v2
18+
with:
19+
app_id: ${{ secrets.APP_ID }}
20+
private_key: ${{ secrets.PRIVATE_KEY }}
21+
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
ref: ${{ github.sha }}
27+
token: ${{ steps.create_token.outputs.token }}
28+
29+
- name: Force correct branch on workflow sha
30+
run: git checkout -B ${{ github.ref_name }} ${{ github.sha }}
31+
32+
- name: Bump patch version
33+
id: bump
34+
run: |
35+
CURRENT_VERSION=$(grep -oP '^version = "\K[^"]+' pyproject.toml)
36+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
37+
NEW_PATCH=$((PATCH + 1))
38+
NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH"
39+
sed -i "s/^version = \"$CURRENT_VERSION\"/version = \"$NEW_VERSION\"/" pyproject.toml
40+
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
41+
echo "tag=v$NEW_VERSION" >> "$GITHUB_OUTPUT"
42+
echo "Bumped version: $CURRENT_VERSION -> $NEW_VERSION"
43+
44+
- name: Install uv
45+
uses: astral-sh/setup-uv@v5
46+
47+
- name: Sync uv lockfile
48+
run: uv lock
49+
50+
- name: Get merged PR info
51+
id: pr_info
52+
env:
53+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
run: |
55+
PR_NUMBER=$(gh pr list --state merged --search "${{ github.sha }}" --json number --jq '.[0].number' 2>/dev/null || echo "")
56+
if [ -n "$PR_NUMBER" ]; then
57+
PR_BODY=$(gh pr view "$PR_NUMBER" --json body --jq '.body')
58+
echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
59+
{
60+
echo "notes<<EOF"
61+
echo "$PR_BODY"
62+
echo "EOF"
63+
} >> "$GITHUB_OUTPUT"
64+
else
65+
echo "notes=Release ${{ steps.bump.outputs.tag }}" >> "$GITHUB_OUTPUT"
66+
fi
67+
68+
- name: Create GitHub release
69+
env:
70+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
RELEASE_NOTES: ${{ steps.pr_info.outputs.notes }}
72+
run: |
73+
gh release create "${{ steps.bump.outputs.tag }}" \
74+
--title "${{ steps.bump.outputs.tag }}" \
75+
--notes "$RELEASE_NOTES"
76+
77+
- name: Commit version bump
78+
uses: stefanzweifel/git-auto-commit-action@v5
79+
with:
80+
commit_message: "chore: release ${{ steps.bump.outputs.tag }} [skip ci]"
81+
branch: ${{ github.ref_name }}
82+
file_pattern: "pyproject.toml uv.lock"

.github/workflows/test.yml

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
python-version: ["3.12"]
14+
python-version: ["3.13"]
1515
os: [ubuntu-latest]
1616

1717
runs-on: ${{ matrix.os }}
@@ -20,7 +20,7 @@ jobs:
2020
postgres:
2121
image: postgres:latest
2222
env:
23-
POSTGRES_DB: test_db
23+
POSTGRES_DB: db
2424
POSTGRES_USER: postgres
2525
POSTGRES_PASSWORD: postgres
2626
ports:
@@ -45,31 +45,11 @@ jobs:
4545
- name: Install project
4646
run: uv sync --all-extras --dev
4747

48-
- name: Set env variables for pytest
49-
run: |
50-
echo "DB_USER=postgres" >> $GITHUB_ENV
51-
echo "DB_PASSWORD=postgres" >> $GITHUB_ENV
52-
echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV
53-
echo "DB_PORT=5432" >> $GITHUB_ENV
54-
echo "DB_NAME=test_db" >> $GITHUB_ENV
55-
echo "SECRET_KEY=$(openssl rand -base64 32)" >> $GITHUB_ENV
56-
echo "BASE_URL=http://localhost:8000" >> $GITHUB_ENV
57-
echo "RESEND_API_KEY=resend_api_key" >> $GITHUB_ENV
58-
echo "EMAIL_FROM=noreply@promptlytechnologies.com" >> $GITHUB_ENV
59-
60-
- name: Verify environment variables
61-
run: |
62-
echo "Checking if required environment variables are set..."
63-
[ -n "$DB_USER" ] && \
64-
[ -n "$DB_PASSWORD" ] && \
65-
[ -n "$DB_HOST" ] && \
66-
[ -n "$DB_PORT" ] && \
67-
[ -n "$DB_NAME" ] && \
68-
[ -n "$SECRET_KEY" ] && \
69-
[ -n "$RESEND_API_KEY" ]
48+
- name: Run linting with ruff
49+
run: uv run ruff check .
7050

71-
- name: Run type checking with mypy
72-
run: uv run mypy .
51+
- name: Run type checking with ty
52+
run: uv run ty check .
7353

7454
- name: Run tests with pytest
7555
run: uv run pytest tests/

0 commit comments

Comments
 (0)