diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..d597ce27 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,194 @@ +name: CI + +on: + push: + branches: [ main, develop ] + pull_request: + branches: [ main, develop ] + +jobs: + test: + name: Test and Build + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Run TypeScript check + run: npx tsc --noEmit + + - name: Run ESLint (if available) + run: | + if [ -f ".eslintrc.js" ] || [ -f ".eslintrc.json" ] || [ -f "eslint.config.js" ]; then + npx eslint . --ext .ts,.tsx,.js,.jsx + else + echo "No ESLint config found, skipping linting" + fi + continue-on-error: true + + - name: Check for common issues + run: | + echo "Checking for common React Native issues..." + + # Check for console.log statements in production code + if grep -r "console\.log" src/ --include="*.ts" --include="*.tsx" | grep -v "// console.log" | head -5; then + echo "⚠️ Found console.log statements in source code" + else + echo "✅ No console.log statements found" + fi + + # Check for TODO comments + if grep -r "TODO\|FIXME\|HACK" src/ --include="*.ts" --include="*.tsx" | head -5; then + echo "⚠️ Found TODO/FIXME/HACK comments" + else + echo "✅ No TODO comments found" + fi + + # Check package.json for required fields + if [ -f "package.json" ]; then + echo "✅ package.json exists" + if grep -q '"name"' package.json; then + echo "✅ Package name defined" + else + echo "❌ Package name missing" + exit 1 + fi + else + echo "❌ package.json missing" + exit 1 + fi + + - name: Verify React Native setup + run: | + echo "Verifying React Native setup..." + + # Check if React Native is properly installed + if npm list react-native > /dev/null 2>&1; then + echo "✅ React Native is installed" + else + echo "❌ React Native not found" + exit 1 + fi + + # Check if Expo is properly installed + if npm list expo > /dev/null 2>&1; then + echo "✅ Expo is installed" + else + echo "❌ Expo not found" + exit 1 + fi + + # Check for required config files + if [ -f "app.json" ]; then + echo "✅ app.json exists" + else + echo "❌ app.json missing" + exit 1 + fi + + if [ -f "babel.config.js" ]; then + echo "✅ babel.config.js exists" + else + echo "❌ babel.config.js missing" + exit 1 + fi + + if [ -f "metro.config.js" ]; then + echo "✅ metro.config.js exists" + else + echo "❌ metro.config.js missing" + exit 1 + fi + + - name: Test Metro bundler + run: | + echo "Testing Metro bundler..." + npx expo export --platform web --output-dir ./dist-test + if [ -d "./dist-test" ]; then + echo "✅ Metro bundler test successful" + rm -rf ./dist-test + else + echo "❌ Metro bundler test failed" + exit 1 + fi + + - name: Check Android build files + run: | + echo "Checking Android build configuration..." + if [ -d "android" ]; then + echo "✅ Android directory exists" + if [ -f "android/build.gradle" ]; then + echo "✅ Android build.gradle exists" + else + echo "❌ Android build.gradle missing" + exit 1 + fi + if [ -f "android/app/build.gradle" ]; then + echo "✅ Android app build.gradle exists" + else + echo "❌ Android app build.gradle missing" + exit 1 + fi + else + echo "⚠️ Android directory not found" + fi + + - name: Check iOS build files + run: | + echo "Checking iOS build configuration..." + if [ -d "ios" ]; then + echo "✅ iOS directory exists" + if [ -f "ios/Podfile" ]; then + echo "✅ iOS Podfile exists" + else + echo "❌ iOS Podfile missing" + exit 1 + fi + else + echo "⚠️ iOS directory not found" + fi + + - name: Security check + run: | + echo "Running security audit..." + npm audit --audit-level moderate || echo "⚠️ Security vulnerabilities found (non-blocking)" + + - name: Check environment variables + run: | + echo "Checking for required environment variables..." + if [ -f ".env.example" ]; then + echo "✅ .env.example found" + else + echo "⚠️ .env.example not found" + fi + + # Check for hardcoded secrets (basic check) + if grep -r "password\|secret\|key\|token" src/ --include="*.ts" --include="*.tsx" | grep -v "// " | grep -v "password:" | head -3; then + echo "⚠️ Potential hardcoded secrets found" + else + echo "✅ No obvious hardcoded secrets found" + fi + + - name: Build summary + run: | + echo "🎉 Build Summary:" + echo "✅ Dependencies installed" + echo "✅ TypeScript compilation check passed" + echo "✅ React Native setup verified" + echo "✅ Metro bundler test passed" + echo "✅ Build configuration verified" + echo "" + echo "📊 Project Stats:" + echo "- TypeScript files: $(find src -name '*.ts' -o -name '*.tsx' | wc -l)" + echo "- Total source lines: $(find src -name '*.ts' -o -name '*.tsx' -exec wc -l {} + | tail -1 | awk '{print $1}')" + echo "- Dependencies: $(npm list --depth=0 | wc -l)"