-
Notifications
You must be signed in to change notification settings - Fork 1
Dev tazi 001 #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Dev tazi 001 #1
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| module.exports = { | ||
| overrides: [ | ||
| // UI components - less strict rules since they're often auto-generated | ||
| { | ||
| files: ["src/components/ui/**/*.tsx"], | ||
| rules: { | ||
| "react-refresh/only-export-components": "warn", | ||
| "@typescript-eslint/no-empty-object-type": "off" | ||
| } | ||
| }, | ||
| // Config files | ||
| { | ||
| files: ["*.config.ts", "*.config.js"], | ||
| rules: { | ||
| "@typescript-eslint/no-require-imports": "off" | ||
| } | ||
| }, | ||
| // Supabase generated files | ||
| { | ||
| files: ["src/integrations/**/*.ts"], | ||
| rules: { | ||
| "@typescript-eslint/no-explicit-any": "warn" | ||
| } | ||
| } | ||
| ] | ||
| }; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,182 @@ | ||
| # CI/CD Setup for SimplyAlgo | ||
|
|
||
| This document describes the GitHub Actions workflows set up for the SimplyAlgo LeetCode platform. | ||
|
|
||
| ## 🚀 Workflows | ||
|
|
||
| ### 1. CI/CD Pipeline (`.github/workflows/ci.yml`) | ||
| **Comprehensive testing and deployment pipeline** | ||
|
|
||
| **Triggers:** | ||
| - Push to `main` branch | ||
| - Pull requests to `main` branch | ||
|
|
||
| **Jobs:** | ||
| 1. **test-frontend** - Tests the React/Vite frontend | ||
| - Uses Bun for package management | ||
| - Runs linting with `bun run lint` | ||
| - Builds the app with `bun run build` | ||
| - Starts preview server for health check | ||
|
|
||
| 2. **test-api** - Tests the Node.js API server | ||
| - Uses Node.js 18 | ||
| - Installs dependencies in `code-executor-api/` | ||
| - Creates test environment file | ||
| - Tests API server startup and health endpoints | ||
|
|
||
| 3. **integration-test** - Tests both services together | ||
| - Starts both frontend and API servers | ||
| - Runs connectivity tests between services | ||
| - Validates end-to-end functionality | ||
|
|
||
| 4. **deploy-staging** - Deployment preparation (main branch only) | ||
| - Runs after all tests pass | ||
| - Builds production assets | ||
| - Ready for staging deployment | ||
|
|
||
| 5. **security-check** - Security audit | ||
| - Runs `bun audit` and `npm audit` | ||
| - Checks for vulnerable dependencies | ||
|
|
||
| ### 2. Development Tests (`.github/workflows/dev-test.yml`) | ||
| **Quick testing for development branches** | ||
|
|
||
| **Triggers:** | ||
| - Push to `main` or `develop` branches | ||
| - Pull requests to `main` or `develop` branches | ||
|
|
||
| **Features:** | ||
| - Faster execution with focused tests | ||
| - Tests both `bun run dev` and API server startup | ||
| - Validates that development environment works correctly | ||
|
|
||
| ## 🛠️ Local Development | ||
|
|
||
| ### Quick Start | ||
| ```bash | ||
| # Start both frontend and API server | ||
| bun run dev:all | ||
|
|
||
| # Or individually: | ||
| bun run dev # Frontend only (port 5173) | ||
| bun run api # API server only (port 3001) | ||
| ``` | ||
|
|
||
| ### Development Script Features | ||
| The `scripts/dev-start.sh` script provides: | ||
| - ✅ Dependency installation for both frontend and API | ||
| - ✅ Automatic .env file creation for API | ||
| - ✅ Health checks for both servers | ||
| - ✅ Graceful shutdown with Ctrl+C | ||
| - ✅ Colored output for better visibility | ||
|
|
||
| ### Environment Setup | ||
|
|
||
| #### Frontend (.env in root) | ||
| ```env | ||
| VITE_SUPABASE_URL=your-supabase-url | ||
| VITE_SUPABASE_ANON_KEY=your-supabase-anon-key | ||
| ``` | ||
|
|
||
| #### API (code-executor-api/.env) | ||
| ```env | ||
| PORT=3001 | ||
| JUDGE0_API_URL=https://judge0-extra-ce.p.rapidapi.com | ||
| SUPABASE_URL=your-supabase-url | ||
| SUPABASE_SERVICE_ROLE_KEY=your-supabase-service-role-key | ||
| JUDGE0_API_KEY=your-judge0-api-key # Optional | ||
| ``` | ||
|
|
||
|
swoosh1337 marked this conversation as resolved.
|
||
| ## 📋 Available Scripts | ||
|
|
||
| ### Frontend (Root directory) | ||
| ```bash | ||
| bun run dev # Start Vite dev server | ||
| bun run dev:all # Start both frontend and API | ||
| bun run build # Build for production | ||
| bun run lint # Run ESLint | ||
| bun run preview # Preview production build | ||
| bun run test:ci # Run CI tests (lint + build) | ||
| ``` | ||
|
|
||
| ### API (code-executor-api/) | ||
| ```bash | ||
| npm run start # Start production server | ||
| npm run dev # Start with file watching | ||
| ``` | ||
|
|
||
| ## 🔧 CI/CD Configuration | ||
|
|
||
| ### Branch Protection | ||
| Recommended branch protection rules for `main`: | ||
| - ✅ Require status checks (all CI jobs must pass) | ||
| - ✅ Require up-to-date branches | ||
| - ✅ Require signed commits (optional) | ||
| - ✅ Include administrators | ||
|
|
||
| ### Environment Variables (GitHub Secrets) | ||
| For production deployment, add these secrets: | ||
| - `VITE_SUPABASE_URL` | ||
| - `VITE_SUPABASE_ANON_KEY` | ||
| - `SUPABASE_SERVICE_ROLE_KEY` | ||
| - `JUDGE0_API_KEY` (optional) | ||
|
|
||
|
swoosh1337 marked this conversation as resolved.
|
||
| ## 📊 Status Badges | ||
|
|
||
| Add these to your main README.md: | ||
|
|
||
| ```markdown | ||
|  | ||
|  | ||
| ``` | ||
|
|
||
| ## 🚨 Troubleshooting | ||
|
|
||
| ### Common Issues | ||
|
|
||
| 1. **API Server fails to start in CI** | ||
| - Check environment variables | ||
| - Verify .env file creation in workflow | ||
|
|
||
| 2. **Frontend build fails** | ||
| - Check for TypeScript errors | ||
| - Verify all dependencies are installed | ||
|
|
||
| 3. **Integration tests timeout** | ||
| - Increase timeout in workflow | ||
| - Check server startup timing | ||
|
|
||
| 4. **Bun cache issues** | ||
| - Clear cache in GitHub Actions settings | ||
| - Update cache key in workflow | ||
|
|
||
| ### Debug Commands | ||
| ```bash | ||
| # Test locally what CI does: | ||
| bun install | ||
| bun run lint | ||
| bun run build | ||
|
|
||
| # Test API startup: | ||
| cd code-executor-api | ||
| npm install | ||
| npm start | ||
| curl http://localhost:3001/health | ||
| ``` | ||
|
|
||
| ## 🔄 Workflow Updates | ||
|
|
||
| To modify workflows: | ||
| 1. Edit `.github/workflows/ci.yml` or `dev-test.yml` | ||
| 2. Test changes on feature branch first | ||
| 3. Monitor workflow runs in GitHub Actions tab | ||
| 4. Update this documentation when adding new features | ||
|
|
||
| ## 📈 Future Enhancements | ||
|
|
||
| Planned improvements: | ||
| - [ ] Add automated testing with Jest/Vitest | ||
| - [ ] Docker containerization for consistent environments | ||
| - [ ] Automated deployment to staging/production | ||
| - [ ] Performance monitoring integration | ||
| - [ ] Slack/Discord notifications for build status | ||
Binary file not shown.
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Development startup script for SimplyAlgo platform | ||
| # Starts both the frontend (Bun) and API server (Node.js) in parallel | ||
|
|
||
| set -e | ||
|
|
||
| echo "🚀 Starting SimplyAlgo Development Environment..." | ||
|
|
||
| # Colors for output | ||
| RED='\033[0;31m' | ||
| GREEN='\033[0;32m' | ||
| YELLOW='\033[1;33m' | ||
| BLUE='\033[0;34m' | ||
| NC='\033[0m' # No Color | ||
|
|
||
| # Function to cleanup on exit | ||
| # Ensure cleanup runs on SIGINT, SIGTERM, or normal exit | ||
| cleanup() { | ||
| echo -e "${YELLOW}🧹 Cleaning up background processes...${NC}" | ||
| if [[ -n "${API_PID:-}" ]]; then | ||
| kill ${API_PID} 2>/dev/null || true | ||
| fi | ||
| if [[ -n "${FRONTEND_PID:-}" ]]; then | ||
| kill ${FRONTEND_PID} 2>/dev/null || true | ||
| fi | ||
| } | ||
| trap cleanup SIGINT SIGTERM EXIT | ||
|
|
||
| # Check if bun is installed | ||
| if ! command -v bun &> /dev/null; then | ||
| echo -e "${RED}❌ Bun is not installed. Please install Bun first: https://bun.sh${NC}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Check if node is installed | ||
| if ! command -v node &> /dev/null; then | ||
| echo -e "${RED}❌ Node.js is not installed. Please install Node.js first${NC}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo -e "${BLUE}📦 Installing frontend dependencies...${NC}" | ||
| bun install | ||
|
|
||
| echo -e "${BLUE}📦 Installing API dependencies...${NC}" | ||
| cd code-executor-api | ||
| npm install | ||
|
|
||
| # Check if .env exists in API directory | ||
| if [ ! -f .env ]; then | ||
| echo -e "${YELLOW}⚠️ Creating API .env file with default values...${NC}" | ||
| cat > .env << EOL | ||
| PORT=3001 | ||
| JUDGE0_API_URL=https://judge0-extra-ce.p.rapidapi.com | ||
| # Add your actual Supabase credentials below: | ||
| SUPABASE_URL=your-supabase-url | ||
| SUPABASE_SERVICE_ROLE_KEY=your-supabase-service-role-key | ||
| # Optional: Add your Judge0 API key for better rate limits | ||
| # JUDGE0_API_KEY=your-judge0-api-key | ||
| EOL | ||
| echo -e "${YELLOW}📝 Please update code-executor-api/.env with your actual credentials${NC}" | ||
| fi | ||
|
|
||
| cd .. | ||
|
|
||
| echo -e "${BLUE}🚀 Starting API server on port 3001...${NC}" | ||
| cd code-executor-api | ||
| npm run dev & | ||
| API_PID=$! | ||
| cd .. | ||
|
|
||
| # Wait for API to start | ||
| echo -e "${YELLOW}⏳ Waiting for API server to start...${NC}" | ||
| sleep 3 | ||
|
|
||
| # Check if API is running | ||
| if curl -f http://localhost:3001/health &>/dev/null; then | ||
| echo -e "${GREEN}✅ API server is running at http://localhost:3001${NC}" | ||
| else | ||
| echo -e "${YELLOW}⚠️ API server may not be fully ready yet (this is normal)${NC}" | ||
| fi | ||
|
|
||
| echo -e "${BLUE}🚀 Starting frontend server on port 5173...${NC}" | ||
| bun run dev & | ||
| FRONTEND_PID=$! | ||
|
|
||
| # Wait for frontend to start | ||
| echo -e "${YELLOW}⏳ Waiting for frontend server to start...${NC}" | ||
| sleep 5 | ||
|
|
||
| echo -e "${GREEN}🎉 Development environment is ready!${NC}" | ||
| echo -e "${GREEN}📱 Frontend: http://localhost:5173${NC}" | ||
| echo -e "${GREEN}🔧 API Server: http://localhost:3001${NC}" | ||
| echo -e "${GREEN}💊 API Health Check: http://localhost:3001/health${NC}" | ||
| echo -e "${GREEN}⚖️ Judge0 Status: http://localhost:3001/judge0-info${NC}" | ||
| echo "" | ||
| echo -e "${BLUE}Press Ctrl+C to stop both servers${NC}" | ||
|
|
||
| # Wait for user to stop | ||
| wait $API_PID $FRONTEND_PID |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.