Skip to content

Commit dab1e23

Browse files
authored
Merge branch 'main' into wegent/team-icon-favorites-showcase
2 parents a8d6702 + 76b9b22 commit dab1e23

33 files changed

+2425
-91
lines changed

.githooks/pre-push

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
# =============================================================================
3+
# Pre-push Hook - AI Code Quality Check
4+
# =============================================================================
5+
# This hook runs quality checks before push for AI coding agents.
6+
# It directly calls the ai-push-gate.sh script without requiring pre-commit.
7+
#
8+
# Usage:
9+
# git push (runs all checks)
10+
# AI_VERIFIED=1 git push (skip doc reminders after review)
11+
# git push --no-verify (skip all checks - not recommended)
12+
# =============================================================================
13+
14+
# Get the directory where this script is located
15+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
16+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
17+
18+
# Change to project root
19+
cd "$PROJECT_ROOT"
20+
21+
# Run the AI push gate script
22+
if [ -f "scripts/hooks/ai-push-gate.sh" ]; then
23+
bash scripts/hooks/ai-push-gate.sh
24+
exit $?
25+
fi
26+
27+
# If the script doesn't exist, just pass
28+
echo "⚠️ scripts/hooks/ai-push-gate.sh not found, skipping checks."
29+
exit 0

.github/workflows/e2e-tests.yml

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
name: E2E Tests
2+
3+
on:
4+
pull_request:
5+
branches: [main, develop]
6+
workflow_dispatch:
7+
8+
env:
9+
# Next.js rewrites /api/* to ${NEXT_PUBLIC_API_URL}/api/*, so only set the base URL
10+
NEXT_PUBLIC_API_URL: http://localhost:8000
11+
# Use pymysql driver (installed via requirements.txt)
12+
DATABASE_URL: mysql+pymysql://root:123456@localhost:3306/task_manager
13+
REDIS_URL: redis://localhost:6379
14+
ENVIRONMENT: development
15+
# Enable auto migration on backend startup
16+
DB_AUTO_MIGRATE: 'True'
17+
18+
jobs:
19+
e2e-tests:
20+
runs-on: ubuntu-latest
21+
timeout-minutes: 30
22+
23+
services:
24+
mysql:
25+
image: mysql:8.4
26+
env:
27+
MYSQL_ROOT_PASSWORD: '123456'
28+
MYSQL_DATABASE: task_manager
29+
ports:
30+
- 3306:3306
31+
options: >-
32+
--health-cmd="mysqladmin ping -h localhost"
33+
--health-interval=10s
34+
--health-timeout=5s
35+
--health-retries=5
36+
37+
redis:
38+
image: redis:7
39+
ports:
40+
- 6379:6379
41+
options: >-
42+
--health-cmd="redis-cli ping"
43+
--health-interval=10s
44+
--health-timeout=5s
45+
--health-retries=5
46+
47+
steps:
48+
- name: Checkout code
49+
uses: actions/checkout@v4
50+
51+
- name: Set up Python
52+
uses: actions/setup-python@v5
53+
with:
54+
python-version: '3.11'
55+
cache: 'pip'
56+
cache-dependency-path: backend/requirements.txt
57+
58+
- name: Install backend dependencies
59+
working-directory: backend
60+
run: |
61+
python -m pip install --upgrade pip
62+
pip install -r requirements.txt
63+
64+
- name: Set up Node.js
65+
uses: actions/setup-node@v4
66+
with:
67+
node-version: '20'
68+
cache: 'npm'
69+
cache-dependency-path: frontend/package-lock.json
70+
71+
- name: Install frontend dependencies
72+
working-directory: frontend
73+
run: npm ci
74+
75+
- name: Build frontend
76+
working-directory: frontend
77+
env:
78+
# Next.js rewrites /api/* to ${NEXT_PUBLIC_API_URL}/api/*, so only set the base URL
79+
NEXT_PUBLIC_API_URL: http://localhost:8000
80+
run: npm run build
81+
82+
- name: Install Playwright browsers
83+
working-directory: frontend
84+
run: npx playwright install chromium --with-deps
85+
86+
- name: Start backend server
87+
working-directory: backend
88+
env:
89+
DATABASE_URL: mysql+pymysql://root:[email protected]:3306/task_manager
90+
REDIS_URL: redis://127.0.0.1:6379
91+
ENVIRONMENT: development
92+
DB_AUTO_MIGRATE: 'True'
93+
INIT_DATA_ENABLED: 'True'
94+
INIT_DATA_DIR: ${{ github.workspace }}/backend/init_data
95+
# Add project root to PYTHONPATH so 'shared' module can be imported
96+
PYTHONPATH: ${{ github.workspace }}
97+
run: |
98+
uvicorn app.main:app --host 0.0.0.0 --port 8000 &
99+
echo "Backend server starting (with auto migration and YAML init enabled)..."
100+
101+
- name: Start frontend server
102+
working-directory: frontend
103+
env:
104+
# Next.js rewrites /api/* to ${NEXT_PUBLIC_API_URL}/api/*, so only set the base URL
105+
NEXT_PUBLIC_API_URL: http://localhost:8000
106+
run: |
107+
npm start &
108+
echo "Frontend server starting..."
109+
110+
- name: Wait for services to be ready
111+
run: |
112+
echo "Waiting for backend..."
113+
for i in {1..60}; do
114+
if curl -s http://localhost:8000/api/health > /dev/null 2>&1 || curl -s http://localhost:8000/ > /dev/null 2>&1; then
115+
echo "Backend is ready!"
116+
break
117+
fi
118+
echo "Waiting for backend... ($i/60)"
119+
sleep 2
120+
done
121+
122+
echo "Waiting for frontend..."
123+
for i in {1..30}; do
124+
if curl -s http://localhost:3000 > /dev/null 2>&1; then
125+
echo "Frontend is ready!"
126+
break
127+
fi
128+
echo "Waiting for frontend... ($i/30)"
129+
sleep 2
130+
done
131+
132+
- name: Run E2E tests
133+
working-directory: frontend
134+
env:
135+
E2E_BASE_URL: http://localhost:3000
136+
CI: true
137+
run: npm run e2e
138+
139+
- name: Upload test results
140+
uses: actions/upload-artifact@v4
141+
if: always()
142+
with:
143+
name: e2e-test-results
144+
path: |
145+
frontend/e2e-results.json
146+
frontend/playwright-report/
147+
frontend/test-results/
148+
retention-days: 7
149+
150+
- name: Upload failure screenshots
151+
uses: actions/upload-artifact@v4
152+
if: failure()
153+
with:
154+
name: e2e-failure-screenshots
155+
path: frontend/test-results/**/*.png
156+
retention-days: 7

AGENTS.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,77 @@ const form = useForm({ resolver: zodResolver(schema) })
311311

312312
## 🔄 Git Workflow
313313

314+
### AI Code Quality Check (Pre-push)
315+
316+
Wegent uses git hooks to ensure code quality for AI coding agents (Claude Code, Cursor, etc.). All quality checks run **before push**, allowing multiple commits locally without interruption.
317+
318+
**Auto-enabled in Executor:**
319+
When the executor clones a repository, git hooks are automatically configured via `core.hooksPath=.githooks`. No manual installation required.
320+
321+
**Local Development (via npm install):**
322+
```bash
323+
cd frontend && npm install # Husky automatically configures pre-push hook
324+
```
325+
326+
**Manual Installation (alternative):**
327+
```bash
328+
# Configure git to use .githooks directory
329+
git config core.hooksPath .githooks
330+
```
331+
332+
**Usage:**
333+
334+
```bash
335+
# Normal workflow - checks run automatically before push
336+
git add .
337+
git commit -m "feat: your feature"
338+
git push # <- Quality checks run here
339+
340+
# If documentation reminders shown, verify and push
341+
AI_VERIFIED=1 git push
342+
343+
# Skip all checks (not recommended)
344+
git push --no-verify
345+
```
346+
347+
**Quality Checks:**
348+
349+
| Check | Tools | Scope |
350+
|-------|-------|-------|
351+
| Doc Reminders | Custom script | API, Schema changes |
352+
353+
**Manual Commands:**
354+
```bash
355+
# Run checks manually
356+
bash scripts/hooks/ai-push-gate.sh
357+
358+
# Skip all checks (not recommended)
359+
git push --no-verify
360+
```
361+
362+
**Check Output Example:**
363+
```
364+
══════════════════════════════════════════════════════════
365+
📋 AI Code Quality Check Report (Pre-push)
366+
══════════════════════════════════════════════════════════
367+
368+
📁 Files to be pushed:
369+
Total: 6 file(s)
370+
Modules affected:
371+
- Backend: 3 file(s)
372+
- Frontend: 2 file(s)
373+
374+
✅ Lint & Format: PASSED
375+
✅ Type Check: PASSED
376+
✅ Unit Tests: PASSED (backend: 42 passed)
377+
✅ Build Check: PASSED
378+
379+
⚠️ Documentation Reminders:
380+
- backend/app/api/ changed → Check docs/ for updates
381+
382+
══════════════════════════════════════════════════════════
383+
```
384+
314385
### Branch Naming
315386

316387
**Pattern:** `<type>/<description>`
@@ -611,3 +682,4 @@ docker-compose up -d --build [service]
611682
**Last Updated**: 2025-07
612683
**Wegent Version**: 1.0.8
613684
**Maintained by**: WeCode-AI Team
685+

CONTRIBUTING.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,55 @@ git checkout -b feature/your-feature-name
153153
```bash
154154
git add .
155155
git commit -m "feat: add new feature description"
156+
```
157+
158+
### 4. Push Code (Quality Checks Run Here)
159+
160+
#### Pre-push Setup (Required)
161+
162+
Wegent uses pre-commit hooks to ensure code quality before pushing. This is especially important for AI coding agents (Claude Code, Cursor, etc.).
163+
164+
```bash
165+
# Install pre-commit
166+
pip install pre-commit
167+
168+
# Install pre-push hooks
169+
pre-commit install --hook-type pre-push
170+
```
171+
172+
#### Pre-push Quality Checks
173+
174+
When pushing code, pre-commit automatically runs quality checks:
175+
176+
- Lint & Format (Black, isort, ESLint)
177+
- Type Check (TypeScript, mypy)
178+
- Unit Tests (only for changed modules)
179+
- Build Check (syntax validation)
180+
- Documentation update reminders
181+
182+
```bash
183+
# Push to remote (triggers quality checks)
156184
git push origin feature/your-feature-name
185+
186+
# If documentation reminders shown, verify and push
187+
AI_VERIFIED=1 git push origin feature/your-feature-name
188+
189+
# Skip checks if needed (not recommended)
190+
git push --no-verify origin feature/your-feature-name
191+
```
192+
193+
#### Manual Quality Checks
194+
195+
```bash
196+
# Run all pre-push checks manually
197+
pre-commit run --all-files --hook-stage pre-push
198+
199+
# Run specific checks
200+
pre-commit run black --all-files
201+
pre-commit run eslint-frontend --all-files
157202
```
158203

159-
### 4. Create Pull Request
204+
### 5. Create Pull Request
160205

161206
- Fill out complete PR description
162207
- Link related issues

frontend/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@
33
# SPDX-License-Identifier: Apache-2.0
44

55
.next/
6+
7+
# Playwright
8+
e2e/.auth/
9+
playwright-report/
10+
test-results/
11+
e2e-results.json

frontend/.husky/pre-push

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env sh
2+
3+
# Navigate to project root
4+
PROJECT_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
5+
cd "$PROJECT_ROOT" || exit 1
6+
7+
# Run AI push gate script
8+
if [ -f "scripts/hooks/ai-push-gate.sh" ]; then
9+
bash scripts/hooks/ai-push-gate.sh
10+
exit $?
11+
fi
12+
13+
# If script doesn't exist, just pass
14+
echo "⚠️ scripts/hooks/ai-push-gate.sh not found, skipping checks."
15+
exit 0

0 commit comments

Comments
 (0)