Skip to content

Commit 663a0da

Browse files
ambvclaude
andauthored
Pin backend dependencies using pip-compile (#11)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d880d86 commit 663a0da

File tree

9 files changed

+2128
-75
lines changed

9 files changed

+2128
-75
lines changed

.github/workflows/ci.yml

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,42 @@
1-
name: Dummy-CI
1+
name: CI
22

3-
on: [push]
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
47

58
jobs:
6-
build:
9+
check-lockfile:
10+
name: Check backend lockfile is up to date
11+
if: github.event_name == 'pull_request'
712
runs-on: ubuntu-latest
813
steps:
9-
- uses: actions/checkout@v1
10-
- name: Pass
11-
run: echo Success!
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
- name: Ensure lockfiles are updated when .in files change
18+
run: |
19+
BASE=${{ github.event.pull_request.base.sha }}
20+
HEAD=${{ github.event.pull_request.head.sha }}
21+
CHANGED=$(git diff --name-only "$BASE" "$HEAD")
22+
FAIL=0
23+
if echo "$CHANGED" | grep -q 'backend/requirements\.in$'; then
24+
if ! echo "$CHANGED" | grep -q 'backend/requirements\.txt$'; then
25+
echo "::error::backend/requirements.in was modified but backend/requirements.txt was not."
26+
FAIL=1
27+
fi
28+
if ! echo "$CHANGED" | grep -q 'backend/requirements-dev\.txt$'; then
29+
echo "::error::backend/requirements.in was modified but backend/requirements-dev.txt was not."
30+
FAIL=1
31+
fi
32+
fi
33+
if echo "$CHANGED" | grep -q 'backend/requirements-dev\.in$'; then
34+
if ! echo "$CHANGED" | grep -q 'backend/requirements-dev\.txt$'; then
35+
echo "::error::backend/requirements-dev.in was modified but backend/requirements-dev.txt was not."
36+
FAIL=1
37+
fi
38+
fi
39+
if [ "$FAIL" -eq 1 ]; then
40+
echo "::error::Please run pip-compile to regenerate lockfiles. See README for instructions."
41+
exit 1
42+
fi

README.md

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,24 @@ This project consists of three main components:
1313
## Quick Start
1414

1515
### Prerequisites
16-
- Python 3.8+
17-
- Node.js 16+
18-
- CPython source repository (for benchmarking)
16+
- Docker Engine 20.10+ and Docker Compose 2.0+
17+
- CPython source repository (for benchmarking with the worker)
1918

2019
### Setup & Installation
2120
```bash
22-
# Install all dependencies and set up database
23-
make setup
21+
# Copy environment config
22+
cp .env.example .env
2423

25-
# Or install components separately
26-
make install # Install frontend + backend dependencies
27-
make init-db # Initialize SQLite database
28-
make populate-db # Add mock data for development
24+
# Build and start all services
25+
docker compose -f docker-compose.dev.yml up --build
2926
```
3027

3128
### Development
32-
```bash
33-
# Start both frontend and backend servers
34-
make dev
3529

36-
# Or start them individually
37-
make dev-frontend # Frontend on http://localhost:9002
38-
make dev-backend # Backend API on http://localhost:8000
39-
```
30+
Services start automatically with hot reload:
31+
- Frontend: http://localhost:9002
32+
- Backend API: http://localhost:8000
33+
- API Documentation: http://localhost:8000/api/docs
4034

4135
## Development Commands
4236

@@ -46,16 +40,23 @@ npm run lint # Frontend linting (in frontend directory)
4640
npm run typecheck # TypeScript type checking
4741
```
4842

49-
### Database Management
43+
### Populating Mock Data
5044
```bash
51-
make reset-db # Drop and recreate database with fresh data
52-
make populate-db # Add mock benchmark data
45+
docker compose -f docker-compose.dev.yml exec backend python scripts/populate_db.py
5346
```
5447

55-
### Production
48+
### Updating Backend Dependencies
5649
```bash
57-
make build # Build frontend for production
58-
make clean # Clean up generated files and caches
50+
# Edit backend/requirements.in, then regenerate both lockfiles:
51+
docker run --rm -v "$(pwd)/backend:/app" -w /app python:3.13-slim-bookworm \
52+
sh -c "pip install --quiet pip-tools && \
53+
pip-compile --strip-extras --generate-hashes \
54+
--output-file requirements.txt requirements.in && \
55+
pip-compile --strip-extras --generate-hashes \
56+
--output-file requirements-dev.txt requirements-dev.in"
57+
58+
# Rebuild the backend container:
59+
docker compose -f docker-compose.dev.yml up --build -d backend
5960
```
6061

6162
## Worker Setup
@@ -91,10 +92,30 @@ memory-tracker benchmark /path/to/cpython HEAD~5..HEAD \
9192

9293
```bash
9394
# Development with hot reload
94-
docker-compose -f docker-compose.dev.yml up
95+
docker compose -f docker-compose.dev.yml up
9596

9697
# Production deployment
97-
docker-compose up
98+
docker compose up
99+
```
100+
101+
## Local Development (not recommended)
102+
103+
Running services directly on the host is possible but not recommended.
104+
Docker Compose ensures consistent Python/Node versions, database setup,
105+
and dependency isolation across all platforms.
106+
107+
### Prerequisites
108+
- Python 3.13+
109+
- Node.js 20+
110+
111+
```bash
112+
make setup # Install deps, init DB, populate mock data
113+
make dev # Start frontend + backend with hot reload
114+
make test # Run backend tests
115+
make reset-db # Drop and recreate database with fresh data
116+
make populate-db # Populate the DB with mock data
117+
make build # Build frontend for production
118+
make clean # Clean up generated files and caches
98119
```
99120

100121
## Usage Examples
@@ -130,7 +151,7 @@ memory-tracker benchmark ~/cpython HEAD~10..HEAD \
130151
## Contributing
131152

132153
1. Follow the existing code style and conventions
133-
2. Run tests before committing: `make test`
154+
2. Run tests before committing
134155
3. Use TypeScript for all frontend code
135156
4. Follow the repository patterns for new features
136157
5. Never commit secrets or authentication tokens

backend/Dockerfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ RUN apt-get update && apt-get install -y \
1212
# Copy requirements first to leverage Docker layer caching
1313
COPY requirements.txt .
1414

15-
# Install PostgreSQL adapter
16-
RUN pip install --no-cache-dir asyncpg psycopg2-binary
17-
1815
# Install Python dependencies
1916
RUN pip install --no-cache-dir -r requirements.txt
2017

backend/Dockerfile.dev

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.11-slim
1+
FROM python:3.13-slim-bookworm
22

33
WORKDIR /app
44

@@ -7,10 +7,10 @@ RUN apt-get update && apt-get install -y \
77
gcc \
88
&& rm -rf /var/lib/apt/lists/*
99

10-
COPY requirements.txt .
10+
COPY requirements-dev.txt .
1111

12-
# Install Python dependencies
13-
RUN pip install --no-cache-dir -r requirements.txt
12+
# Install Python dependencies (dev lockfile includes test tooling)
13+
RUN pip install --no-cache-dir -r requirements-dev.txt
1414

1515
# The source code will be mounted as a volume, so we don't copy it here
1616

backend/requirements-dev.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-r requirements.in
2+
pytest
3+
pytest-asyncio

0 commit comments

Comments
 (0)