Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
251 changes: 18 additions & 233 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,274 +1,59 @@
name: CI/CD Pipeline
name: MVP CI/CD - Fast & Simple

on:
push:
branches: [ main, develop, dockerized-frontendlol ]
branches: [ main, develop ]
pull_request:
branches: [ main, develop, dockerized-frontendlol ]

jobs:
# Frontend CI/CD
# Quick build and basic tests only
frontend:
name: Frontend CI/CD
name: Frontend Quick Check
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend

strategy:
matrix:
node-version: [18.x, 20.x]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node-version }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version: '20.x'
cache: 'npm'
cache-dependency-path: package-lock.json

- name: Install dependencies
run: |
npm ci
npm rebuild

- name: Run ESLint
run: echo "ESLint disabled due to configuration compatibility issues"
continue-on-error: true

- name: Run type checking
run: npm run type-check

- name: Run tests
run: npm run test
working-directory: ./frontend
run: npm install

- name: Build application
- name: Build check
working-directory: ./frontend
run: npm run build
env:
NEXT_PUBLIC_BACKEND_URL: ${{ secrets.NEXT_PUBLIC_BACKEND_URL || 'http://localhost:8000' }}

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: frontend-build-${{ matrix.node-version }}
path: frontend/.next/
retention-days: 1
NEXT_PUBLIC_BACKEND_URL: http://localhost:8000

# Backend CI/CD
backend:
name: Backend CI/CD
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend

strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: backend/requirements-dev.txt

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt

- name: Run code formatting check (Black)
run: black --check --diff .

- name: Run import sorting check (isort)
run: isort --check-only --diff .

- name: Run linting (flake8)
run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics

- name: Run tests with coverage
run: pytest --cov=. --cov-report=xml --cov-report=html
env:
TESTING: true
DATABASE_URL: ${{ secrets.DATABASE_URL || 'sqlite:///test.db' }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY || 'test-key' }}

- name: Upload coverage reports
uses: codecov/codecov-action@v3
if: matrix.python-version == '3.11'
with:
file: ./backend/coverage.xml
flags: backend
name: backend-coverage

# Integration Tests
integration:
name: Integration Tests
name: Backend Quick Check
runs-on: ubuntu-latest
needs: [frontend, backend]
if: github.event_name == 'pull_request'

services:
postgres:
image: postgres:15
env:
POSTGRES_PASSWORD: test
POSTGRES_DB: smartquery_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
cache-dependency-path: package-lock.json

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: backend/requirements-dev.txt

- name: Install frontend dependencies
working-directory: ./frontend
run: |
npm ci
npm rebuild

- name: Install backend dependencies
- name: Install dependencies
working-directory: ./backend
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt

- name: Start backend server
- name: Basic tests (no coverage requirements)
working-directory: ./backend
run: |
uvicorn main:app --host 0.0.0.0 --port 8000 &
sleep 10
env:
DATABASE_URL: postgresql://postgres:test@localhost:5432/smartquery_test
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY || 'test-key' }}

- name: Run integration tests
working-directory: ./frontend
run: npm run test:integration
env:
NEXT_PUBLIC_BACKEND_URL: http://localhost:8000

- name: Run backend integration tests
working-directory: ./backend
run: |
RUN_INTEGRATION_TESTS=true pytest tests/test_project_integration.py -v
env:
DATABASE_URL: postgresql://postgres:test@localhost:5432/smartquery_test
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY || 'test-key' }}
RUN_INTEGRATION_TESTS: true

- name: Health check
run: |
curl -f http://localhost:8000/health || exit 1

# Security and Quality Checks
security:
name: Security & Quality
runs-on: ubuntu-latest
permissions:
security-events: write
actions: read
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
output: 'trivy-results.sarif'

- name: Upload Trivy scan results
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: 'trivy-results.sarif'

- name: Setup Node.js for audit
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
cache-dependency-path: package-lock.json

- name: Frontend security audit
working-directory: ./frontend
run: |
npm ci
npm rebuild
npm audit --audit-level=high || echo "Security audit found issues but continuing..."

- name: Setup Python for security check
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install safety
run: pip install safety

- name: Backend security audit
working-directory: ./backend
run: safety check -r requirements-dev.txt || echo "Security audit found issues but continuing..."

# Deployment (only on main branch)
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: [frontend, backend, security]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download frontend build
uses: actions/download-artifact@v4
with:
name: frontend-build-20.x
path: frontend/.next/

- name: Deploy to staging
run: |
echo "Deploying to staging environment..."
# Add your deployment commands here
# For example: deploy to Vercel, AWS, etc.

- name: Notify deployment
uses: 8398a7/action-slack@v3
if: always() && secrets.SLACK_WEBHOOK_URL
with:
status: ${{ job.status }}
text: 'Deployment completed'
run: pytest --tb=short
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
TESTING: true
DATABASE_URL: sqlite:///test.db
OPENAI_API_KEY: test-key
29 changes: 0 additions & 29 deletions .github/workflows/frontend-docker-ci.yml

This file was deleted.

Loading