Skip to content

Commit 53aadfe

Browse files
authored
Merge pull request #233 from codeunia-dev/fix/ci-cd-pipeline-and-performance-optimizations
🔧 Fix CI/CD Pipeline Errors & Enhance Performance Optimizations
2 parents 9969e51 + 649d153 commit 53aadfe

File tree

41,348 files changed

+6069383
-277
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41,348 files changed

+6069383
-277
lines changed

.github/workflows/ci-cd.yml

Lines changed: 86 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,16 @@ jobs:
106106
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
107107
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
108108
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
109+
REDIS_URL: ${{ secrets.REDIS_URL }}
109110

110111
- name: Analyze bundle size
111112
run: npm run build:analyze
113+
env:
114+
NODE_ENV: production
115+
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
116+
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
117+
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
118+
REDIS_URL: ${{ secrets.REDIS_URL }}
112119

113120
- name: Upload build artifacts
114121
uses: actions/upload-artifact@v4
@@ -183,6 +190,7 @@ jobs:
183190
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
184191
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
185192
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
193+
REDIS_URL: ${{ secrets.REDIS_URL }}
186194

187195
- name: Wait for app to be ready
188196
run: |
@@ -314,6 +322,7 @@ jobs:
314322
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
315323
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
316324
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
325+
REDIS_URL: ${{ secrets.REDIS_URL }}
317326

318327
- name: Deploy to Vercel (Staging)
319328
id: deploy-staging
@@ -439,6 +448,7 @@ jobs:
439448
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
440449
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
441450
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
451+
REDIS_URL: ${{ secrets.REDIS_URL }}
442452

443453
- name: Deploy to Vercel (Production)
444454
id: deploy-production
@@ -592,16 +602,33 @@ jobs:
592602

593603
- name: Create Lighthouse configuration for deployed site
594604
run: |
595-
cat > lighthouserc-deployed.js << 'EOF'
605+
# Get the deployment URL from the previous step
606+
DEPLOYMENT_URL="${{ needs.deploy-production.outputs.deployment-url }}"
607+
608+
# Validate deployment URL
609+
if [ -z "$DEPLOYMENT_URL" ]; then
610+
echo "❌ Deployment URL is empty, using fallback URL"
611+
DEPLOYMENT_URL="${{ secrets.PRODUCTION_URL }}"
612+
fi
613+
614+
# Ensure URL has protocol
615+
if [[ ! "$DEPLOYMENT_URL" =~ ^https?:// ]]; then
616+
echo "⚠️ Adding https:// protocol to URL: $DEPLOYMENT_URL"
617+
DEPLOYMENT_URL="https://$DEPLOYMENT_URL"
618+
fi
619+
620+
echo "🔍 Using deployment URL for Lighthouse: $DEPLOYMENT_URL"
621+
622+
cat > lighthouserc-deployed.js << EOF
596623
module.exports = {
597624
ci: {
598625
collect: {
599626
url: [
600-
'${{ needs.deploy-production.outputs.deployment-url }}/',
601-
'${{ needs.deploy-production.outputs.deployment-url }}/about',
602-
'${{ needs.deploy-production.outputs.deployment-url }}/hackathons',
603-
'${{ needs.deploy-production.outputs.deployment-url }}/leaderboard',
604-
'${{ needs.deploy-production.outputs.deployment-url }}/auth/signin'
627+
'${DEPLOYMENT_URL}/',
628+
'${DEPLOYMENT_URL}/about',
629+
'${DEPLOYMENT_URL}/hackathons',
630+
'${DEPLOYMENT_URL}/leaderboard',
631+
'${DEPLOYMENT_URL}/auth/signin'
605632
],
606633
numberOfRuns: 3,
607634
settings: {
@@ -653,7 +680,21 @@ jobs:
653680
- name: Run Lighthouse CI on deployed site
654681
run: |
655682
echo "🚀 Starting Lighthouse CI performance testing..."
656-
echo "Testing URL: ${{ needs.deploy-production.outputs.deployment-url }}"
683+
684+
# Get the deployment URL
685+
DEPLOYMENT_URL="${{ needs.deploy-production.outputs.deployment-url }}"
686+
if [ -z "$DEPLOYMENT_URL" ]; then
687+
DEPLOYMENT_URL="${{ secrets.PRODUCTION_URL }}"
688+
fi
689+
690+
echo "Testing URL: $DEPLOYMENT_URL"
691+
692+
# Validate that we have a URL before running Lighthouse
693+
if [ -z "$DEPLOYMENT_URL" ]; then
694+
echo "❌ No deployment URL available for Lighthouse testing"
695+
echo "Skipping Lighthouse CI test"
696+
exit 0
697+
fi
657698
658699
# Run Lighthouse CI with the deployed configuration
659700
lhci autorun --config=lighthouserc-deployed.js
@@ -710,16 +751,33 @@ jobs:
710751

711752
- name: Create Lighthouse configuration for staging
712753
run: |
713-
cat > lighthouserc-staging.js << 'EOF'
754+
# Get the deployment URL from the previous step
755+
DEPLOYMENT_URL="${{ needs.deploy-staging.outputs.deployment-url }}"
756+
757+
# Validate deployment URL
758+
if [ -z "$DEPLOYMENT_URL" ]; then
759+
echo "❌ Staging deployment URL is empty, using fallback URL"
760+
DEPLOYMENT_URL="${{ secrets.STAGING_URL }}"
761+
fi
762+
763+
# Ensure URL has protocol
764+
if [[ ! "$DEPLOYMENT_URL" =~ ^https?:// ]]; then
765+
echo "⚠️ Adding https:// protocol to staging URL: $DEPLOYMENT_URL"
766+
DEPLOYMENT_URL="https://$DEPLOYMENT_URL"
767+
fi
768+
769+
echo "🔍 Using staging deployment URL for Lighthouse: $DEPLOYMENT_URL"
770+
771+
cat > lighthouserc-staging.js << EOF
714772
module.exports = {
715773
ci: {
716774
collect: {
717775
url: [
718-
'${{ needs.deploy-staging.outputs.deployment-url }}/',
719-
'${{ needs.deploy-staging.outputs.deployment-url }}/about',
720-
'${{ needs.deploy-staging.outputs.deployment-url }}/hackathons',
721-
'${{ needs.deploy-staging.outputs.deployment-url }}/leaderboard',
722-
'${{ needs.deploy-staging.outputs.deployment-url }}/auth/signin'
776+
'${DEPLOYMENT_URL}/',
777+
'${DEPLOYMENT_URL}/about',
778+
'${DEPLOYMENT_URL}/hackathons',
779+
'${DEPLOYMENT_URL}/leaderboard',
780+
'${DEPLOYMENT_URL}/auth/signin'
723781
],
724782
numberOfRuns: 2,
725783
settings: {
@@ -765,7 +823,21 @@ jobs:
765823
- name: Run Lighthouse CI on staging site
766824
run: |
767825
echo "🚀 Starting Lighthouse CI performance testing on staging..."
768-
echo "Testing URL: ${{ needs.deploy-staging.outputs.deployment-url }}"
826+
827+
# Get the deployment URL
828+
DEPLOYMENT_URL="${{ needs.deploy-staging.outputs.deployment-url }}"
829+
if [ -z "$DEPLOYMENT_URL" ]; then
830+
DEPLOYMENT_URL="${{ secrets.STAGING_URL }}"
831+
fi
832+
833+
echo "Testing URL: $DEPLOYMENT_URL"
834+
835+
# Validate that we have a URL before running Lighthouse
836+
if [ -z "$DEPLOYMENT_URL" ]; then
837+
echo "❌ No staging deployment URL available for Lighthouse testing"
838+
echo "Skipping Lighthouse CI test"
839+
exit 0
840+
fi
769841
770842
# Run Lighthouse CI with the staging configuration
771843
lhci autorun --config=lighthouserc-staging.js

app/api/admin-collaboration/route.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { NextResponse } from "next/server";
22
import { createClient } from "@supabase/supabase-js";
33

4+
// Force Node.js runtime for API routes
5+
export const runtime = 'nodejs';
6+
7+
48
// Create Supabase client function to avoid build-time initialization
59
function getSupabaseClient() {
610
return createClient(

app/api/admin-judges/route.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { NextResponse } from "next/server";
22
import { createClient } from "@supabase/supabase-js";
33

4+
// Force Node.js runtime for API routes
5+
export const runtime = 'nodejs';
6+
7+
48
// Create Supabase client function to avoid build-time initialization
59
function getSupabaseClient() {
610
return createClient(

app/api/admin-mentors/route.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { NextResponse } from "next/server";
22
import { createClient } from "@supabase/supabase-js";
33

4+
// Force Node.js runtime for API routes
5+
export const runtime = 'nodejs';
6+
7+
48
// Create Supabase client function to avoid build-time initialization
59
function getSupabaseClient() {
610
return createClient(

app/api/admin-page-views/route.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { NextResponse } from 'next/server';
22
import { createClient } from '@/lib/supabase/server';
33

4+
// Force Node.js runtime for API routes
5+
export const runtime = 'nodejs';
6+
7+
48
export async function GET() {
59
const supabase = await createClient();
610
const { data, error } = await supabase
@@ -11,6 +15,6 @@ export async function GET() {
1115
return NextResponse.json({ error: error.message }, { status: 500 });
1216
}
1317

14-
const totalViews = (data || []).reduce((sum, blog) => sum + (blog.views || 0), 0);
18+
const totalViews = (data || []).reduce((sum: number, blog: any) => sum + (blog.views || 0), 0);
1519
return NextResponse.json({ totalViews });
1620
}

app/api/admin-sponsorship/route.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { NextResponse } from "next/server";
22
import { createClient } from "@supabase/supabase-js";
33

4+
// Force Node.js runtime for API routes
5+
export const runtime = 'nodejs';
6+
7+
48
// Create Supabase client function to avoid build-time initialization
59
function getSupabaseClient() {
610
return createClient(

app/api/admin-users/route.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { NextResponse } from "next/server";
22
import { createClient } from "@supabase/supabase-js";
33

4+
// Force Node.js runtime for API routes
5+
export const runtime = 'nodejs';
6+
7+
48
// Create Supabase client function to avoid build-time initialization
59
function getSupabaseClient() {
610
return createClient(

app/api/admin-volunteers/route.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { NextResponse } from "next/server";
22
import { createClient } from "@supabase/supabase-js";
33

4+
// Force Node.js runtime for API routes
5+
export const runtime = 'nodejs';
6+
7+
48
// Create Supabase client function to avoid build-time initialization
59
function getSupabaseClient() {
610
return createClient(

app/api/admin/audit-logs/route.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import { NextRequest, NextResponse } from 'next/server';
22
import { withAdminAuth, AuthenticatedUser } from '@/lib/auth/admin-auth';
33
import { createAuditLogger, AuditLogFilter, AuditActionType } from '@/lib/services/audit-logger';
44

5+
// Force Node.js runtime for API routes
6+
export const runtime = 'nodejs';
7+
8+
59
/**
610
* GET /api/admin/audit-logs
711
* Retrieve audit logs with filtering and pagination

app/api/admin/audit-logs/stats/route.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import { NextRequest, NextResponse } from 'next/server';
22
import { withAdminAuth, AuthenticatedUser } from '@/lib/auth/admin-auth';
33
import { createAuditLogger } from '@/lib/services/audit-logger';
44

5+
// Force Node.js runtime for API routes
6+
export const runtime = 'nodejs';
7+
8+
59
/**
610
* GET /api/admin/audit-logs/stats
711
* Get audit log statistics

0 commit comments

Comments
 (0)