Form intent detector for better suggestions #109
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Form-Flow-AI CI/CD Pipeline | |
| # Runs tests, linting, and builds for all components on push and pull requests | |
| name: Form-Flow-AI CI | |
| on: | |
| push: | |
| branches: [ "main", "develop" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| permissions: | |
| contents: read | |
| env: | |
| PYTHON_VERSION: "3.11" | |
| NODE_VERSION: "20" | |
| jobs: | |
| # ============================================ | |
| # Backend Tests (Python/FastAPI) | |
| # ============================================ | |
| backend: | |
| name: Backend Tests | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: ./form-flow-backend | |
| steps: | |
| - 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: './form-flow-backend/requirements.txt' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install flake8 pytest pytest-asyncio pytest-cov | |
| pip install -r requirements.txt | |
| - name: Lint with flake8 | |
| run: | | |
| # Stop the build if there are Python syntax errors or undefined names | |
| flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
| # Exit-zero treats all errors as warnings. GitHub editor is 127 chars wide | |
| flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
| - name: Run tests with pytest | |
| env: | |
| # Add any required environment variables for testing | |
| GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }} | |
| TESTING: "true" | |
| run: | | |
| pytest tests/ -v --tb=short --cov=. --cov-report=xml --cov-report=term-missing | |
| continue-on-error: true # Allow workflow to continue even if some tests fail | |
| - name: Upload coverage reports | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| file: ./form-flow-backend/coverage.xml | |
| flags: backend | |
| fail_ci_if_error: false | |
| # ============================================ | |
| # Frontend Build & Lint (React/Vite) | |
| # ============================================ | |
| frontend: | |
| name: Frontend Build | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: ./form-flow-frontend | |
| steps: | |
| - 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: './form-flow-frontend/package-lock.json' | |
| - name: Install dependencies | |
| run: npm install --legacy-peer-deps | |
| - name: Lint | |
| run: npm run lint | |
| continue-on-error: true # ESLint warnings shouldn't fail the build | |
| - name: Build | |
| run: npm run build | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: frontend-build | |
| path: ./form-flow-frontend/dist | |
| retention-days: 7 | |
| # ============================================ | |
| # Browser Extension Validation | |
| # ============================================ | |
| extension: | |
| name: Extension Validation | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: ./form-flow-extension | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Validate manifest.json | |
| run: | | |
| echo "Validating manifest.json..." | |
| if [ ! -f manifest.json ]; then | |
| echo "❌ manifest.json not found!" | |
| exit 1 | |
| fi | |
| # Check if it's valid JSON | |
| python3 -c "import json; json.load(open('manifest.json'))" && echo "✅ manifest.json is valid JSON" | |
| - name: Check required files | |
| run: | | |
| echo "Checking required extension files..." | |
| files=("background.js" "content.js" "popup.html" "manifest.json") | |
| for file in "${files[@]}"; do | |
| if [ -f "$file" ]; then | |
| echo "✅ $file exists" | |
| else | |
| echo "❌ $file is missing!" | |
| exit 1 | |
| fi | |
| done | |
| - name: Package extension | |
| run: | | |
| mkdir -p ../extension-package | |
| cp -r . ../extension-package/ | |
| rm -rf ../extension-package/.git 2>/dev/null || true | |
| cd .. && zip -r form-flow-extension.zip extension-package | |
| - name: Upload extension package | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: browser-extension | |
| path: ./form-flow-extension.zip | |
| retention-days: 7 | |
| # ============================================ | |
| # Docker Build Validation | |
| # ============================================ | |
| docker: | |
| name: Docker Build | |
| runs-on: ubuntu-latest | |
| needs: [backend, frontend] | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| steps: | |
| - 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: ./form-flow-backend | |
| push: false | |
| tags: form-flow-backend:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Build Frontend Docker Image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./form-flow-frontend | |
| push: false | |
| tags: form-flow-frontend:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| # ============================================ | |
| # Security Scan | |
| # ============================================ | |
| security: | |
| name: Security Scan | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Install safety | |
| run: pip install safety | |
| - name: Check for vulnerabilities | |
| run: | | |
| cd form-flow-backend | |
| safety check -r requirements.txt --output text || true | |
| continue-on-error: true # Don't fail the build on vulnerabilities, just report them | |
| # ============================================ | |
| # Summary Job | |
| # ============================================ | |
| summary: | |
| name: CI Summary | |
| runs-on: ubuntu-latest | |
| needs: [backend, frontend, extension] | |
| if: always() | |
| steps: | |
| - name: Check job results | |
| run: | | |
| echo "## CI Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| Job | Status |" >> $GITHUB_STEP_SUMMARY | |
| echo "|-----|--------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| Backend | ${{ needs.backend.result }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Frontend | ${{ needs.frontend.result }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Extension | ${{ needs.extension.result }} |" >> $GITHUB_STEP_SUMMARY |