diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 78d36e0..3411529 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,8 +3,6 @@ name: CI Pipeline on: push: branches: [ "main", "develop" ] - pull_request: - branches: [ "main" ] env: REGISTRY: docker.io diff --git a/.github/workflows/goose-pr-review.yml b/.github/workflows/goose-pr-review.yml index d281338..57c362c 100644 --- a/.github/workflows/goose-pr-review.yml +++ b/.github/workflows/goose-pr-review.yml @@ -1,4 +1,4 @@ -name: Goose +name: AI Based PR Review with Goose on: pull_request: @@ -52,26 +52,19 @@ jobs: keyring: false EOF - - name: Create instructions for Goose + - name: Prepare review instructions run: | - cat > instructions.txt <<'EOF' - Create a summary of the changes provided. Don't provide any session or logging details. - The summary for each file should be brief and structured as: - - - dot points of changes - You don't need any extensions, don't mention extensions at all. - The changes to summarise are: - EOF - cat changes.txt >> instructions.txt - - - name: Test - run: cat instructions.txt + # Read custom instructions from repository + cat .goose/instructions.txt > review_instructions.txt + echo "" >> review_instructions.txt + echo "The changes to review are:" >> review_instructions.txt + cat changes.txt >> review_instructions.txt - - name: Run Goose and filter output + - name: Run Goose AI review env: GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }} run: | - goose run --instructions instructions.txt \ + goose run --instructions review_instructions.txt \ | sed -E 's/\x1B\[[0-9;]*[mK]//g' \ | grep -v "logging to /home/runner/.config/goose/sessions/" \ | grep -v "^starting session" \ @@ -79,7 +72,16 @@ jobs: | sed 's/[[:space:]]*$//' \ > pr_comment.txt - - name: Post comment to PR + - name: Post AI review to PR run: | - cat -A pr_comment.txt - gh pr comment "$PR_NUMBER" --body-file pr_comment.txt + { + echo "## 🤖 AI Code Review" + echo "*Automated review by Goose + Google Gemini*" + echo "" + cat pr_comment.txt + echo "" + echo "---" + echo "*This review was automatically generated. Use human judgment for final decisions.*" + } > final_comment.txt + + gh pr comment "$PR_NUMBER" --body-file final_comment.txt diff --git a/.goose/instructions.txt b/.goose/instructions.txt new file mode 100644 index 0000000..e8d4b8e --- /dev/null +++ b/.goose/instructions.txt @@ -0,0 +1,50 @@ +You are an expert DevOps engineer reviewing code changes for a machine learning application. + +Focus your review on these key areas: + +## 🐳 Docker & Containerization +- Dockerfile best practices and optimization +- Multi-stage builds and layer efficiency +- Security considerations (non-root users, minimal base images) +- Health checks and restart policies + +## 🏗️ Infrastructure & Orchestration +- Docker Compose service configuration +- Service dependencies and networking +- Volume mounts and data persistence +- Load balancing and proxy setup + +## 🔒 Security & Best Practices +- Exposed ports and network security +- Environment variable management +- Container security practices +- Access controls and permissions + +## 🚀 CI/CD & Automation +- Workflow efficiency and optimization +- Security scanning integration +- Caching strategies and performance +- Error handling and reliability + +## 📊 Code Quality +- Configuration file structure and clarity +- Documentation and maintainability +- Production readiness +- Scalability considerations + +## Review Format +Please structure your review as: + +**`filename`** +- Summary of changes +- Key observations +- Recommendations for improvement +- Security or performance notes + +**Overall Assessment:** +- Rate: Excellent/Good/Needs Improvement +- Main strengths +- Priority improvements +- Production readiness assessment + +Keep feedback constructive, specific, and actionable. diff --git a/docker-compose.yaml b/docker-compose.yaml index 9a6ef3c..7f345ec 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,3 +1,5 @@ +version: '3.8' + services: tech-stack-advisor: build: . @@ -13,3 +15,24 @@ services: start_period: 40s restart: unless-stopped + redis: + image: redis:7-alpine + ports: + - "6379:6379" + volumes: + - redis_data:/data + command: redis-server --appendonly yes + restart: unless-stopped + + nginx: + image: nginx:alpine + ports: + - "80:80" + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf:ro + depends_on: + - tech-stack-advisor + restart: unless-stopped + +volumes: + redis_data: diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..63b7f1d --- /dev/null +++ b/nginx.conf @@ -0,0 +1,28 @@ +events { + worker_connections 1024; +} + +http { + upstream tech_stack_advisor { + server tech-stack-advisor:7860; + } + + server { + listen 80; + server_name localhost; + + location / { + proxy_pass http://tech_stack_advisor; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /health { + access_log off; + return 200 "healthy\n"; + add_header Content-Type text/plain; + } + } +}