name: CI on: push: branches: [main, develop] pull_request: branches: [main] concurrency: group: ci-${{ github.ref }} cancel-in-progress: true jobs: # ============================================================ # Backend: lint + test # ============================================================ backend: runs-on: ubuntu-latest defaults: run: working-directory: backend services: mysql: image: mysql:8.0 env: MYSQL_ROOT_PASSWORD: test_password MYSQL_DATABASE: aiagent_test ports: - 3306:3306 options: >- --health-cmd="mysqladmin ping -h localhost" --health-interval=10s --health-timeout=5s --health-retries=5 redis: image: redis:7-alpine ports: - 6379:6379 options: >- --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=5 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: "3.12" cache: pip cache-dependency-path: backend/requirements.txt - name: Install Python dependencies run: | pip install --upgrade pip pip install -r requirements.txt pip install pytest pytest-cov pytest-asyncio httpx - name: Lint with flake8 run: | pip install flake8 flake8 app/ --count --select=E9,F63,F7,F82 --show-source --statistics - name: Run backend tests env: DATABASE_URL: mysql+pymysql://root:test_password@127.0.0.1:3306/aiagent_test?charset=utf8mb4 REDIS_URL: redis://127.0.0.1:6379/0 JWT_SECRET_KEY: ci-test-jwt-secret-not-for-production SECRET_KEY: ci-test-secret-not-for-production ENVIRONMENT: ci DEBUG: "false" run: | python -m pytest tests/ \ -q --tb=short \ --cov=app \ --cov-report=xml \ --cov-report=term-missing \ --timeout=120 \ -p no:warnings \ --ignore=tests/test_workflows.py \ --ignore=tests/test_auth.py \ --ignore=tests/test_tools_api.py - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 if: github.event_name == 'pull_request' with: file: backend/coverage.xml flags: backend fail_ci_if_error: false # ============================================================ # Frontend: lint + type-check + build # ============================================================ frontend: runs-on: ubuntu-latest defaults: run: working-directory: frontend steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 with: version: 8 - uses: actions/setup-node@v4 with: node-version: 20 cache: pnpm cache-dependency-path: frontend/pnpm-lock.yaml - name: Install dependencies run: pnpm install --frozen-lockfile - name: Type check run: pnpm vue-tsc --noEmit || true - name: Lint run: pnpm lint || true - name: Build frontend run: pnpm build # ============================================================ # Docker: verify build # ============================================================ docker-build: runs-on: ubuntu-latest needs: [backend, frontend] steps: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Build backend image uses: docker/build-push-action@v6 with: context: ./backend push: false load: true tags: aiagent-backend:ci-test cache-from: type=gha cache-to: type=gha,mode=max - name: Build frontend image uses: docker/build-push-action@v6 with: context: ./frontend push: false load: true tags: aiagent-frontend:ci-test cache-from: type=gha cache-to: type=gha,mode=max