6666 runs-on : ubuntu-latest
6767 container :
6868 image : quay.io/stackrox-io/apollo-ci:stackrox-test-0.4.9
69+ outputs :
70+ session-secret : ${{ steps.deploy.outputs.session-secret }}
6971 env :
7072 KUBECONFIG : /github/home/artifacts/kubeconfig
7173 INFRA_TOKEN : ${{ secrets.INFRA_TOKEN }}
@@ -100,10 +102,26 @@ jobs:
100102 - name : Download artifacts
101103 run : |
102104 /github/home/.local/bin/infractl artifacts "$CLUSTER_NAME" -d /github/home/artifacts >> "$GITHUB_STEP_SUMMARY"
103- kubectl get nodes -o wide || true
105+
106+ - name : Wait for cluster to be ready
107+ run : |
108+ echo "Waiting for cluster API server to be ready..."
109+ timeout 300 sh -c 'until kubectl get nodes >/dev/null 2>&1; do
110+ echo "Waiting for cluster..."
111+ sleep 5
112+ done'
113+ echo "Cluster is ready"
114+ kubectl get nodes -o wide
104115
105116 - name : Deploy infra to dev cluster
117+ id : deploy
106118 run : |
119+ # Generate random session secret for JWT signing
120+ # This secret is used by both the server (for verification) and Cypress (for JWT generation)
121+ SESSION_SECRET=$(openssl rand -base64 32 | tr -d '\n')
122+ export SESSION_SECRET
123+ echo "Generated random session secret for this PR cluster deployment"
124+
107125 ENVIRONMENT=development TEST_MODE=true make helm-deploy
108126 sleep 10 # wait for old pods to disappear so the svc port-forward doesn't connect to them
109127 kubectl -n infra port-forward svc/infra-server-service 8443:8443 > /dev/null 2>&1 &
@@ -115,6 +133,11 @@ jobs:
115133
116134 kill %1
117135
136+ # Save session secret for UI E2E tests (job output for next job)
137+ echo "session-secret=$SESSION_SECRET" >> "$GITHUB_OUTPUT"
138+ # Also set as env var for steps in this job
139+ echo "SESSION_SECRET=$SESSION_SECRET" >> "$GITHUB_ENV"
140+
118141 - name : Check the deployment
119142 run : |
120143 kubectl -n infra port-forward svc/infra-server-service 8443:8443 > /dev/null 2>&1 &
@@ -155,9 +178,194 @@ jobs:
155178 run : |
156179 make argo-workflow-lint
157180
158- - name : Run Go e2e tests
181+ ui-e2e-test-pr-cluster :
182+ needs :
183+ - deploy-and-test
184+ runs-on : ubuntu-latest
185+ # Note: This job does NOT use the apollo-ci container to avoid path issues
186+ env :
187+ KUBECONFIG : /tmp/kubeconfig
188+ INFRA_TOKEN : ${{ secrets.INFRA_TOKEN }}
189+ USE_GKE_GCLOUD_AUTH_PLUGIN : " True"
190+
191+ steps :
192+ - name : Checkout
193+ uses : actions/checkout@v6
194+ with :
195+ fetch-depth : 0
196+ ref : ${{ github.event.pull_request.head.sha }}
197+ path : go/src/github.com/stackrox/infra
198+
199+ - name : Authenticate to GCloud
200+ uses : google-github-actions/auth@v3
201+ with :
202+ credentials_json : ${{ secrets.INFRA_CI_AUTOMATION_GCP_SA }}
203+
204+ - name : Set up Cloud SDK
205+ uses : google-github-actions/setup-gcloud@v3
206+ with :
207+ install_components : " gke-gcloud-auth-plugin"
208+
209+ - name : Download production infractl
210+ uses : stackrox/actions/infra/install-infractl@v1
211+
212+ - name : Get kubeconfig for PR cluster
213+ run : |
214+ echo "Downloading kubeconfig for $CLUSTER_NAME..."
215+ /home/runner/.local/bin/infractl artifacts "$CLUSTER_NAME" -d /tmp/artifacts
216+ cp /tmp/artifacts/kubeconfig "$KUBECONFIG"
217+
218+ echo "Verifying cluster access..."
219+ kubectl get nodes -o wide
220+
221+ - name : Wait for infra-server deployment
222+ run : |
223+ echo "Checking infra-server pods..."
224+ kubectl get pods -n infra
225+ kubectl wait --for=condition=ready pod -l app=infra-server -n infra --timeout=5m
226+
227+ - name : Setup Node.js
228+ uses : actions/setup-node@v4
229+ with :
230+ node-version : ' 20'
231+
232+ - name : Install UI dependencies
233+ run : |
234+ cd ui
235+ npm install --legacy-peer-deps
236+
237+ - name : Start port-forward to PR cluster
238+ run : |
239+ kubectl -n infra port-forward svc/infra-server-service 8443:8443 >/dev/null 2>&1 &
240+ PORT_FORWARD_PID=$!
241+ echo "PORT_FORWARD_PID=$PORT_FORWARD_PID" >> "$GITHUB_ENV"
242+ echo "Started port-forward with PID: $PORT_FORWARD_PID"
243+ sleep 10
244+
245+ # Verify port-forward is working
246+ echo "Verifying port-forward connectivity..."
247+ timeout 30 sh -c 'until curl -k -f https://localhost:8443/v1/whoami 2>/dev/null; do
248+ echo "Waiting for port-forward..."
249+ sleep 2
250+ done' || {
251+ echo "Port-forward verification failed"
252+ pgrep -a port-forward || true
253+ exit 1
254+ }
255+ echo "Port-forward is working"
256+
257+ - name : Debug - Check flavors API
258+ run : |
259+ echo "Checking if flavors are available..."
260+
261+ # First try without auth (should fail with access denied)
262+ echo "1. Testing without authentication:"
263+ UNAUTH_RESPONSE=$(curl -k -s https://localhost:8443/v1/flavor/list || echo "API call failed")
264+ echo "$UNAUTH_RESPONSE" | jq . || echo "$UNAUTH_RESPONSE"
265+
266+ # Check whoami endpoint
267+ echo ""
268+ echo "2. Testing /v1/whoami:"
269+ WHOAMI=$(curl -k -s https://localhost:8443/v1/whoami || echo "whoami failed")
270+ echo "$WHOAMI" | jq . || echo "$WHOAMI"
271+
272+ # The real issue is the UI itself - let's check if the flavors endpoint
273+ # works at all. The UI must be getting an error from somewhere.
274+ echo ""
275+ echo "3. Checking flavors API (unauthenticated count):"
276+ FLAVOR_COUNT=$(echo "$UNAUTH_RESPONSE" | jq '.flavors | length' 2>/dev/null || echo "0")
277+ echo "Number of flavors available: $FLAVOR_COUNT"
278+
279+ if [ "$FLAVOR_COUNT" = "0" ]; then
280+ echo "NOTE: Flavors API requires authentication"
281+ echo "This is expected - Cypress tests use JWT authentication with randomly generated secret"
282+ fi
283+
284+ - name : Run UI E2E tests
285+ uses : cypress-io/github-action@v6
286+ with :
287+ working-directory : go/src/github.com/stackrox/infra/ui
288+ install : false
289+ start : npm run start
290+ wait-on : ' http://localhost:3001'
291+ wait-on-timeout : 60
292+ command : npm run cypress:run:e2e
159293 env :
160- INFRA_TOKEN : ${{ secrets.INFRA_TOKEN_DEV }}
294+ BROWSER : none
295+ PORT : 3001
296+ # Backend is the PR cluster deployment accessed via port-forward
297+ # This deployment uses ENVIRONMENT=development with real OIDC (NOT localDeploy=true)
298+ INFRA_API_ENDPOINT : https://localhost:8443
299+ # Session secret for JWT generation (matches what the server uses)
300+ # Retrieved from deploy-and-test job output
301+ CYPRESS_SESSION_SECRET : ${{ needs.deploy-and-test.outputs.session-secret }}
302+
303+ - name : Upload test artifacts
304+ if : failure()
305+ uses : actions/upload-artifact@v4
306+ with :
307+ name : cypress-artifacts-pr-cluster-${{ github.event.pull_request.number }}
308+ path : |
309+ go/src/github.com/stackrox/infra/ui/cypress/videos
310+ go/src/github.com/stackrox/infra/ui/cypress/screenshots
311+ retention-days : 7
312+
313+ - name : Cleanup port-forward
314+ if : always()
315+ run : |
316+ if [ -n "${{ env.PORT_FORWARD_PID }}" ]; then
317+ echo "Cleaning up port-forward (PID: ${{ env.PORT_FORWARD_PID }})..."
318+ kill ${{ env.PORT_FORWARD_PID }} 2>/dev/null || true
319+ fi
320+ pkill -f "kubectl port-forward.*8443:8443" 2>/dev/null || true
321+
322+ go-e2e-test :
323+ needs :
324+ - ui-e2e-test-pr-cluster
325+ runs-on : ubuntu-latest
326+ container :
327+ image : quay.io/stackrox-io/apollo-ci:stackrox-test-0.4.9
328+ env :
329+ KUBECONFIG : /github/home/artifacts/kubeconfig
330+ INFRA_TOKEN : ${{ secrets.INFRA_TOKEN_DEV }}
331+ INFRACTL : bin/infractl -k -e localhost:8443
332+ USE_GKE_GCLOUD_AUTH_PLUGIN : " True"
333+
334+ steps :
335+ - name : Checkout
336+ uses : actions/checkout@v6
337+ with :
338+ fetch-depth : 0
339+ ref : ${{ github.event.pull_request.head.sha }}
340+ path : go/src/github.com/stackrox/infra
341+
342+ - uses : actions/setup-go@v6
343+ with :
344+ go-version-file : go/src/github.com/stackrox/infra/go.mod
345+
346+ - name : Authenticate to GCloud
347+ uses : google-github-actions/auth@v3
348+ with :
349+ credentials_json : ${{ secrets.INFRA_CI_AUTOMATION_GCP_SA }}
350+
351+ - name : Set up Cloud SDK
352+ uses : " google-github-actions/setup-gcloud@v3"
353+ with :
354+ install_components : " gke-gcloud-auth-plugin"
355+
356+ - name : Download production infractl
357+ uses : stackrox/actions/infra/install-infractl@v1
358+
359+ - name : Download artifacts
360+ run : |
361+ /github/home/.local/bin/infractl artifacts "$CLUSTER_NAME" -d /github/home/artifacts >> "$GITHUB_STEP_SUMMARY"
362+
363+ - name : Verify cluster connectivity
364+ run : |
365+ echo "Verifying cluster is accessible..."
366+ kubectl get nodes -o wide
367+
368+ - name : Run Go e2e tests
161369 run : |
162370 kubectl -n infra port-forward svc/infra-server-service 8443:8443 > /dev/null 2>&1 &
163371 sleep 5
0 commit comments