Skip to content

Moved Assets for UI #115

Moved Assets for UI

Moved Assets for UI #115

name: Bundle Analysis
on:
pull_request:
paths:
- 'frontend/**'
branches: [ main, master ]
push:
paths:
- 'frontend/**'
branches: [ main, master ]
jobs:
bundle-analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install Dependencies
run: npm install
working-directory: ./frontend
- name: Setup EAS
uses: expo/expo-github-action@v8
with:
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: Build for Bundle Analysis
run: |
# Try to build with Expo for web, but handle React Native compatibility issues
if npx expo export --platform web --output-dir web-build 2>/dev/null; then
echo "✅ Expo web export successful"
else
echo "⚠️ Web export failed, using alternative bundle analysis approach"
# Create a basic bundle using Metro bundler directly
npx metro build --entry-file index.js --platform web --bundle-output web-build/bundle.js --assets-dest web-build/static || true
# If that also fails, create a minimal analysis report
if [ ! -f "web-build/bundle.js" ]; then
echo "📊 Creating basic size analysis from node_modules..."
mkdir -p web-build/static/js
# Analyze the main dependencies that would be bundled
echo "# Bundle Analysis Report (Estimated)" > bundle-analysis.md
echo "" >> bundle-analysis.md
echo "## Bundle Size Analysis" >> bundle-analysis.md
echo "- React Native web build failed due to platform-specific modules" >> bundle-analysis.md
echo "- This is common with React Native apps that use platform-specific code" >> bundle-analysis.md
echo "" >> bundle-analysis.md
echo "## Key Dependencies Analysis" >> bundle-analysis.md
du -sh node_modules/react node_modules/react-native node_modules/@expo 2>/dev/null | while read size dir; do
echo "- ${dir}: ${size}" >> bundle-analysis.md
done || echo "- Unable to analyze individual dependencies" >> bundle-analysis.md
exit 0
fi
fi
working-directory: ./frontend
- name: Analyze Bundle Size
working-directory: ./frontend
run: |
# Install analysis tools
npm install --no-save @expo/metro-config metro-visualizer
sudo apt-get update && sudo apt-get install -y bc
echo "📊 Analyzing bundle size for Expo/React Native project..."
# Check if bundle analysis report already exists (from build step failure handling)
if [ -f "bundle-analysis.md" ]; then
echo "� Using existing analysis report from build step"
cat bundle-analysis.md
exit 0
fi
# Check if web-build directory exists
if [ -d "web-build" ]; then
echo "✅ Web build directory found"
ls -la web-build/
# Look for JavaScript bundles in various locations
BUNDLE_FOUND=false
# Check standard Expo web build structure
if [ -d "web-build/static/js" ] && [ "$(ls -A web-build/static/js 2>/dev/null)" ]; then
echo "📁 JavaScript bundle files in static/js:"
find web-build/static/js -name "*.js" -type f -exec ls -lh {} \; | awk '{print $5 " " $9}'
# Calculate total bundle size
TOTAL_SIZE=$(find web-build/static/js -name "*.js" -type f -exec stat -c%s {} \; | awk '{sum+=$1} END {print sum}')
TOTAL_SIZE_MB=$(echo "scale=2; $TOTAL_SIZE / 1024 / 1024" | bc -l)
echo "📊 Total JavaScript bundle size: ${TOTAL_SIZE_MB} MB"
BUNDLE_FOUND=true
elif [ -f "web-build/bundle.js" ]; then
echo "📁 Single bundle file found:"
ls -lh web-build/bundle.js
BUNDLE_SIZE=$(stat -c%s web-build/bundle.js)
TOTAL_SIZE_MB=$(echo "scale=2; $BUNDLE_SIZE / 1024 / 1024" | bc -l)
echo "📊 Bundle size: ${TOTAL_SIZE_MB} MB"
BUNDLE_FOUND=true
fi
if [ "$BUNDLE_FOUND" = true ]; then
# Create analysis report
echo "# Bundle Analysis Report" > bundle-analysis.md
echo "" >> bundle-analysis.md
echo "## Bundle Size Summary" >> bundle-analysis.md
echo "- Total JavaScript bundle size: **${TOTAL_SIZE_MB} MB**" >> bundle-analysis.md
echo "" >> bundle-analysis.md
echo "## Build Details" >> bundle-analysis.md
echo "- Platform: Web (React Native)" >> bundle-analysis.md
echo "- Bundler: Metro (Expo)" >> bundle-analysis.md
echo "" >> bundle-analysis.md
if [ -d "web-build/static/js" ]; then
echo "## Individual Files" >> bundle-analysis.md
find web-build/static/js -name "*.js" -type f -exec ls -lh {} \; | awk '{print "- " $9 ": " $5}' >> bundle-analysis.md
fi
cat bundle-analysis.md
else
echo "❌ No JavaScript bundles found in expected locations"
echo "📁 Available files in web-build:"
find web-build -type f -name "*.js" -o -name "*.json" | head -10
fi
else
echo "❌ No web-build directory found"
echo "📁 Available directories:"
ls -la
# Create fallback analysis
echo "# Bundle Analysis Report (Fallback)" > bundle-analysis.md
echo "" >> bundle-analysis.md
echo "## Analysis Status" >> bundle-analysis.md
echo "- Web build failed - this is common for React Native apps with platform-specific code" >> bundle-analysis.md
echo "- Bundle analysis skipped for this build" >> bundle-analysis.md
fi
- name: Upload Bundle Analysis Report
if: always() && hashFiles('frontend/bundle-analysis.md') != ''
uses: actions/upload-artifact@v4
with:
name: bundle-analysis-report
path: frontend/bundle-analysis.md
retention-days: 30
- name: Upload Bundle Analysis to Codecov
uses: codecov/codecov-action@v5
if: github.actor != 'dependabot[bot]' && hashFiles('frontend/bundle-analysis.md') != ''
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: bundle,frontend,javascript
name: "Bundle Analysis"
fail_ci_if_error: false
- name: Bundle Analysis Skipped
if: github.actor == 'dependabot[bot]'
run: echo "📦 Bundle analysis skipped for Dependabot PR"