Files
trendyol-analiz/.github/workflows/ci.yml
furkanyigit34 c7be57064b Initial commit: Trendyol Analiz platform
- FastAPI backend with Python
- React + Vite admin panel
- PostgreSQL database
- Trendyol marketplace analytics
- GitHub Actions CI/CD workflow

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 00:14:38 +03:00

202 lines
5.7 KiB
YAML

name: Trendyol Analiz CI/CD
on:
push:
branches: [main, master, develop]
pull_request:
branches: [main, master]
env:
PYTHON_VERSION: '3.13'
NODE_VERSION: '20'
jobs:
# Backend Build & Test (FastAPI)
backend:
name: Backend (FastAPI)
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15-alpine
env:
POSTGRES_DB: trendyol_db
POSTGRES_USER: postgres
POSTGRES_PASSWORD: testpassword
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
defaults:
run:
working-directory: backend
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: backend/requirements.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-test.txt || true
- name: Lint with flake8 (optional)
run: |
pip install flake8 || true
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics || true
- name: Run tests
run: |
pip install pytest pytest-asyncio httpx || true
pytest || echo "No tests found or tests skipped"
env:
DATABASE_URL: postgresql://postgres:testpassword@localhost:5432/trendyol_db
# Frontend Build & Test (React + Vite)
frontend:
name: Frontend (React + Vite)
runs-on: ubuntu-latest
defaults:
run:
working-directory: admin-panel
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: admin-panel/package-lock.json
- name: Install dependencies
run: npm ci
- name: Lint check
run: npm run lint || true
- name: Build
run: npm run build
env:
VITE_API_URL: http://localhost:8001
- name: Upload frontend artifact
uses: actions/upload-artifact@v4
with:
name: frontend-dist
path: admin-panel/dist
retention-days: 1
# Docker Build Test
docker-build:
name: Docker Build Test
runs-on: ubuntu-latest
needs: [backend, frontend]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Backend Docker image
uses: docker/build-push-action@v5
with:
context: ./backend
push: false
tags: trendyol-backend:test
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build Frontend Docker image
uses: docker/build-push-action@v5
with:
context: ./admin-panel
push: false
tags: trendyol-frontend:test
build-args: |
VITE_API_URL=http://localhost:8010
cache-from: type=gha
cache-to: type=gha,mode=max
# Full Integration Test (Docker Compose)
integration:
name: Integration Test
runs-on: ubuntu-latest
needs: [backend, frontend]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create test docker-compose
run: |
cat > docker-compose.test.yml << 'EOF'
name: trendyol-test
services:
postgres:
image: postgres:15-alpine
environment:
POSTGRES_DB: trendyol_db
POSTGRES_USER: postgres
POSTGRES_PASSWORD: testpassword
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 10
backend:
build:
context: ./backend
environment:
PYTHONUNBUFFERED: 1
DATABASE_URL: postgresql://postgres:testpassword@postgres:5432/trendyol_db
CATEGORIES_DIR: /data/categories
REPORTS_DIR: /data/reports
FRONTEND_URL: http://localhost:3010
depends_on:
postgres:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8001/health"]
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
EOF
- name: Start services
run: docker compose -f docker-compose.test.yml up -d --build
- name: Wait for backend
run: |
echo "Waiting for backend to be healthy..."
timeout 120 bash -c 'until docker compose -f docker-compose.test.yml ps backend | grep -q "healthy"; do sleep 5; done' || \
(docker compose -f docker-compose.test.yml logs && exit 1)
- name: Test backend health
run: |
docker compose -f docker-compose.test.yml exec -T backend curl -f http://localhost:8001/health || \
(docker compose -f docker-compose.test.yml logs backend && exit 1)
- name: Cleanup
if: always()
run: docker compose -f docker-compose.test.yml down -v