forked from fastapi/full-stack-fastapi-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautomations.yaml
More file actions
185 lines (166 loc) · 5.62 KB
/
automations.yaml
File metadata and controls
185 lines (166 loc) · 5.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
services:
database:
name: PostgreSQL Database
description: Development database server
triggeredBy:
- manual
commands:
start: |
docker run --rm -d \
--name postgres-dev \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=changethis \
-e POSTGRES_DB=app \
-p 5432:5432 \
postgres:17
ready: docker exec postgres-dev pg_isready -U postgres -d app
stop: docker stop postgres-dev
adminer:
name: Adminer Database Admin
description: Web-based database administration tool
triggeredBy:
- manual
commands:
start: |
docker run --rm -d \
--name adminer-dev \
-p 8080:8080 \
-e ADMINER_DESIGN=pepa-linha-dark \
adminer
ready: curl -f http://localhost:8080 >/dev/null 2>&1
stop: docker stop adminer-dev
backend:
name: FastAPI Backend
description: Backend API server
triggeredBy:
- manual
commands:
start: |
cd backend && \
export POSTGRES_SERVER=localhost && \
export POSTGRES_PORT=5432 && \
export POSTGRES_DB=app && \
export POSTGRES_USER=postgres && \
export POSTGRES_PASSWORD=changethis && \
export SECRET_KEY=changethis && \
export [email protected] && \
export FIRST_SUPERUSER_PASSWORD=changethis && \
export BACKEND_CORS_ORIGINS="http://localhost,http://localhost:5173,https://localhost,https://localhost:5173" && \
export ENVIRONMENT=local && \
uv run alembic upgrade head && \
uv run python app/initial_data.py && \
uv run fastapi dev app/main.py --host 0.0.0.0 --port 8000
ready: curl -f http://localhost:8000/api/v1/utils/health-check/ >/dev/null 2>&1
frontend:
name: React Frontend
description: Frontend development server
triggeredBy:
- manual
commands:
start: |
cd frontend && \
export VITE_API_URL=http://localhost:8000 && \
npm run dev -- --host 0.0.0.0 --port 5173
ready: curl -f http://localhost:5173 >/dev/null 2>&1
tasks:
setup:
name: Setup Development Environment
description: Install dependencies and configure environment
command: |
echo "Setting up development environment..."
# Install UV if not present
if ! command -v uv &> /dev/null; then
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.cargo/bin:$PATH"
fi
# Install backend dependencies
echo "Installing backend dependencies..."
cd backend && uv sync --dev && cd ..
# Install frontend dependencies
echo "Installing frontend dependencies..."
cd frontend && npm ci && cd ..
# Set up pre-commit hooks
echo "Setting up pre-commit hooks..."
cd backend && uv run pre-commit install && cd ..
# Make scripts executable
chmod +x scripts/*.sh
echo "Setup complete! Run 'gitpod automations service start database' to start services"
lint:
name: Lint Code
description: Run linting on backend and frontend code
command: |
echo "Linting backend..."
cd backend && uv run ruff check . && uv run mypy .
echo "Linting frontend..."
cd frontend && npm run lint
test-backend:
name: Test Backend
description: Run backend unit tests
command: |
cd backend && \
export POSTGRES_SERVER=localhost && \
export POSTGRES_PORT=5432 && \
export POSTGRES_DB=app && \
export POSTGRES_USER=postgres && \
export POSTGRES_PASSWORD=changethis && \
export SECRET_KEY=changethis && \
export [email protected] && \
export FIRST_SUPERUSER_PASSWORD=changethis && \
uv run pytest
test-frontend:
name: Test Frontend
description: Build frontend to verify it compiles
command: |
cd frontend && npm run build
test-e2e:
name: End-to-End Tests
description: Run Playwright end-to-end tests
command: |
cd frontend && \
export VITE_API_URL=http://localhost:8000 && \
npx playwright test
build:
name: Build Application
description: Build both backend and frontend for production
command: |
echo "Building backend..."
cd backend && uv build
echo "Building frontend..."
cd frontend && npm run build
generate-client:
name: Generate API Client
description: Generate TypeScript client from OpenAPI spec
command: |
cd frontend && npm run generate-client
db-migrate:
name: Run Database Migrations
description: Apply database migrations
command: |
cd backend && \
export POSTGRES_SERVER=localhost && \
export POSTGRES_PORT=5432 && \
export POSTGRES_DB=app && \
export POSTGRES_USER=postgres && \
export POSTGRES_PASSWORD=changethis && \
uv run alembic upgrade head
db-reset:
name: Reset Database
description: Reset database to clean state with initial data
command: |
cd backend && \
export POSTGRES_SERVER=localhost && \
export POSTGRES_PORT=5432 && \
export POSTGRES_DB=app && \
export POSTGRES_USER=postgres && \
export POSTGRES_PASSWORD=changethis && \
uv run alembic downgrade base && \
uv run alembic upgrade head && \
uv run python app/initial_data.py
logs:
name: View Service Logs
description: Display logs from running services
command: |
echo "=== Database Logs ==="
docker logs postgres-dev --tail 50 2>/dev/null || echo "Database not running"
echo -e "\n=== Adminer Logs ==="
docker logs adminer-dev --tail 50 2>/dev/null || echo "Adminer not running"