|
| 1 | +name: CI/CD Pipeline |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, develop ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + test-backend: |
| 11 | + name: Backend Tests |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Set up Python |
| 18 | + uses: actions/setup-python@v5 |
| 19 | + with: |
| 20 | + python-version: '3.11' |
| 21 | + cache: 'pip' |
| 22 | + |
| 23 | + - name: Install dependencies |
| 24 | + working-directory: ./backend |
| 25 | + run: | |
| 26 | + python -m pip install --upgrade pip |
| 27 | + pip install pytest pytest-cov httpx |
| 28 | + pip install -r requirements.txt |
| 29 | + |
| 30 | + - name: Run tests |
| 31 | + working-directory: ./backend |
| 32 | + env: |
| 33 | + DEBUG: "true" |
| 34 | + API_KEY: "test-secret-key" |
| 35 | + run: | |
| 36 | + pytest tests/ -v --cov=services --cov-report=term-missing |
| 37 | + |
| 38 | + - name: Check code quality |
| 39 | + working-directory: ./backend |
| 40 | + run: | |
| 41 | + pip install flake8 |
| 42 | + flake8 services/ --max-line-length=120 --ignore=E501,W503 || true |
| 43 | +
|
| 44 | + test-frontend: |
| 45 | + name: Frontend Tests |
| 46 | + runs-on: ubuntu-latest |
| 47 | + |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v4 |
| 50 | + |
| 51 | + - name: Set up Node.js |
| 52 | + uses: actions/setup-node@v4 |
| 53 | + with: |
| 54 | + node-version: '20' |
| 55 | + cache: 'npm' |
| 56 | + cache-dependency-path: './frontend/package-lock.json' |
| 57 | + |
| 58 | + - name: Install dependencies |
| 59 | + working-directory: ./frontend |
| 60 | + run: npm ci |
| 61 | + |
| 62 | + - name: Build frontend |
| 63 | + working-directory: ./frontend |
| 64 | + run: npm run build |
| 65 | + |
| 66 | + - name: Check TypeScript |
| 67 | + working-directory: ./frontend |
| 68 | + run: npx tsc --noEmit |
| 69 | + |
| 70 | + security-scan: |
| 71 | + name: Security Scan |
| 72 | + runs-on: ubuntu-latest |
| 73 | + continue-on-error: true # Don't fail build on security warnings |
| 74 | + |
| 75 | + steps: |
| 76 | + - uses: actions/checkout@v4 |
| 77 | + with: |
| 78 | + fetch-depth: 0 # Full history for TruffleHog |
| 79 | + |
| 80 | + - name: Run Trivy vulnerability scanner |
| 81 | + uses: aquasecurity/trivy-action@master |
| 82 | + with: |
| 83 | + scan-type: 'fs' |
| 84 | + scan-ref: '.' |
| 85 | + format: 'table' |
| 86 | + exit-code: '0' |
| 87 | + |
| 88 | + - name: Check for secrets |
| 89 | + uses: trufflesecurity/trufflehog@main |
| 90 | + continue-on-error: true # Don't fail on false positives |
| 91 | + with: |
| 92 | + path: ./ |
| 93 | + base: main |
| 94 | + head: HEAD |
| 95 | + |
| 96 | + lint: |
| 97 | + name: Lint Code |
| 98 | + runs-on: ubuntu-latest |
| 99 | + continue-on-error: true # Don't fail build on style issues |
| 100 | + |
| 101 | + steps: |
| 102 | + - uses: actions/checkout@v4 |
| 103 | + |
| 104 | + - name: Lint Python |
| 105 | + uses: py-actions/flake8@v2 |
| 106 | + continue-on-error: true |
| 107 | + with: |
| 108 | + path: "backend/services" |
| 109 | + max-line-length: "120" |
| 110 | + ignore: "E501,W503" |
0 commit comments