66 workflow_dispatch :
77
88jobs :
9+ detect-e2e-projects :
10+ name : π Detect Changed Projects
11+ runs-on : ubuntu-22.04
12+ outputs :
13+ e2e_packages : ${{ steps.detect.outputs.e2e_packages }}
14+ steps :
15+ - name : π₯ Checkout Repository
16+ uses : actions/checkout@v4
17+
18+ - name : π» Node setup
19+ uses : ./.github/actions/node-setup
20+
21+ - name : π§© Detect changed apps and related E2E packages
22+ id : detect
23+ run : |
24+ echo "π Detecting changed packages..."
25+ CHANGED=$(pnpm turbo run build --filter=[HEAD^1]... --dry=json | jq -r '.packages[].name' | tr '\n' ' ')
26+ echo "Changed packages: $CHANGED"
27+
28+ E2E_PACKAGES=""
29+ for PKG in $CHANGED; do
30+ NAME=$(echo "$PKG" | sed 's/@infinum\///')
31+ E2E_NAME="e2e-$NAME"
32+ if [ -d "packages/$E2E_NAME" ]; then
33+ E2E_PACKAGES="$E2E_PACKAGES $E2E_NAME"
34+ fi
35+ done
36+
37+ if [ -z "$E2E_PACKAGES" ]; then
38+ echo "β οΈ No changed E2E packages found. Defaulting to e2e-frontend."
39+ E2E_PACKAGES="e2e-frontend"
40+ fi
41+
42+ echo "β
Detected E2E packages: $E2E_PACKAGES"
43+
44+ # Convert space-separated list into JSON array for matrix
45+ JSON_ARRAY=$(jq -cn --arg list "$E2E_PACKAGES" '{e2e_packages: ($list | split(" ") | map(select(length > 0)))}')
46+ echo "$JSON_ARRAY"
47+ echo "e2e_packages=$(echo $JSON_ARRAY | jq -r '.e2e_packages | @json')" >> $GITHUB_OUTPUT
48+
949 e2e-tests :
10- name : π§ͺ E2E Tests
11- timeout-minutes : 60
50+ name : π§ͺ Run E2E Tests (${{ matrix.e2e_package }})
51+ needs : detect-e2e-projects
1252 runs-on : ubuntu-22.04
53+ timeout-minutes : 60
54+
55+ strategy :
56+ fail-fast : false
57+ matrix :
58+ e2e_package : ${{ fromJSON(needs.detect-e2e-projects.outputs.e2e_packages) }}
1359
1460 env :
1561 NODE_ENV : test
1662 NEXTAUTH_SECRET : ' test-secret-for-ci-only'
63+ NEXTAUTH_URL : ' http://localhost:3000'
1764 NEXT_PUBLIC_EXAMPLE_VARIABLE : ' CI Test Variable'
1865 PRIVATE_EXAMPLE_VARIABLE : ' Private CI Test Variable'
1966 CI : true
@@ -38,80 +85,59 @@ jobs:
3885 with :
3986 browsers : ' chromium'
4087
41- - name : ποΈ Build Frontend App
42- run : pnpm --filter @infinum/frontend build
88+ # Build only the related app (derived from e2e-{project})
89+ - name : ποΈ Build Related App
90+ run : |
91+ APP_NAME=$(echo "${{ matrix.e2e_package }}" | sed 's/^e2e-//')
92+ echo "ποΈ Building @infinum/$APP_NAME..."
93+ pnpm --filter @infinum/$APP_NAME build
4394 shell : bash
4495
45- - name : π Start Frontend App (Background)
96+ - name : π Start Related App (Background)
4697 run : |
47- echo "π§ Environment variables:"
48- echo "NODE_ENV: $NODE_ENV"
49- echo "NEXTAUTH_SECRET: ${NEXTAUTH_SECRET:0:10}..."
50- echo ""
51- echo "π Starting server..."
52- node apps/frontend/.next/standalone/apps/frontend/server.js &
98+ APP_NAME=$(echo "${{ matrix.e2e_package }}" | sed 's/^e2e-//')
99+ echo "π Starting $APP_NAME..."
100+ node apps/$APP_NAME/.next/standalone/apps/$APP_NAME/server.js &
53101 SERVER_PID=$!
54102 echo "FRONTEND_PID=$SERVER_PID" >> $GITHUB_ENV
55- echo "β
Server started with PID: $SERVER_PID"
103+ echo "β
$APP_NAME started with PID: $SERVER_PID"
56104 sleep 2
57- echo "π Server process status:"
58105 ps aux | grep $SERVER_PID || echo "β Server process not found"
59106 shell : bash
60107 env :
61108 NODE_ENV : production
62109 NEXTAUTH_SECRET : ' test-secret-for-ci-only'
110+ NEXTAUTH_URL : ' http://localhost:3000'
63111 NEXT_PUBLIC_EXAMPLE_VARIABLE : ' CI Test Variable'
64112 PRIVATE_EXAMPLE_VARIABLE : ' Private CI Test Variable'
65113
66- - name : β³ Wait for Frontend to be Ready
114+ - name : β³ Wait for App to be Ready
67115 run : |
68- echo "β³ Waiting for frontend to start on http://localhost:3000..."
116+ echo "β³ Waiting for app to start on http://localhost:3000..."
69117 ATTEMPT=0
70118 MAX_ATTEMPTS=20
71119
72120 until curl -f http://localhost:3000 > /dev/null 2>&1; do
73121 ATTEMPT=$((ATTEMPT + 1))
74- echo "π Attempt $ATTEMPT/$MAX_ATTEMPTS - waiting for frontend ..."
122+ echo "π Attempt $ATTEMPT/$MAX_ATTEMPTS - waiting..."
75123
76124 if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
77- echo "β Frontend failed to start after $MAX_ATTEMPTS attempts"
78- echo "π Current processes:"
125+ echo "β App failed to start after $MAX_ATTEMPTS attempts"
79126 ps aux | grep -E "(node|next)" | grep -v grep
80- echo "π Checking port 3000:"
81- netstat -tulpn | grep 3000 || echo "No process on port 3000"
82127 exit 1
83128 fi
84-
85129 sleep 3
86130 done
87-
88- echo "β
Frontend is ready!"
131+ echo "β
App is ready!"
89132 shell : bash
90133
91- - name : π Detailed Health Check
134+ - name : π§ͺ Run Playwright Tests for ${{ matrix.e2e_package }}
92135 run : |
93- echo "π₯ Running detailed health check..."
94- echo "π‘ HTTP response:"
95- curl -f http://localhost:3000 -I | head -10
96- echo ""
97- echo "π Basic page content:"
98- curl -s http://localhost:3000 | head -20
99- echo ""
100- echo "π Testing login page:"
101- curl -s http://localhost:3000/login | head -10 || echo "β Login page not accessible"
102- echo ""
103- echo "β
Health check completed!"
136+ echo "π¬ Running pnpm ${{ matrix.e2e_package }}..."
137+ pnpm ${{ matrix.e2e_package }}
104138 shell : bash
105139
106- - name : π§ͺ Run Playwright E2E Tests
107- run : |
108- echo "π¬ Starting Playwright E2E Tests..."
109- echo "================================================"
110- pnpm e2e
111- echo "================================================"
112- echo "β
E2E Tests completed!"
113-
114- - name : π Stop Frontend App
140+ - name : π Stop App
115141 shell : bash
116142 if : always()
117143 run : |
0 commit comments