7676 # the same as the End of Life of the Kubernetes release: https://kubernetes.io/releases/
7777 # Please remember to update the CI Schedule Workflow when we add a new version.
7878 k8s : [ v1.31.0, v1.32.0, v1.33.0 ]
79+ # k8s: [ v1.31.0 ]
7980 steps :
8081 - name : Free Disk Space (Ubuntu)
8182 uses : jlumbroso/free-disk-space@main
@@ -89,20 +90,55 @@ jobs:
8990 large-packages : false
9091 docker-images : false
9192 swap-storage : false
93+
9294 - name : Checkout karmada repo
9395 uses : actions/checkout@v4
9496 with :
9597 repository : karmada-io/karmada
9698 path : karmada
99+
97100 - name : setup e2e test environment
98101 run : |
99102 cd karmada
100103 export CLUSTER_VERSION=kindest/node:${{ matrix.k8s }}
101104 hack/local-up-karmada.sh
105+ echo "KUBECONFIG=/home/runner/.kube/karmada.config" >> $GITHUB_ENV
106+ - name : Debug cluster status
107+ run : |
108+ echo "=== Debug Info ==="
109+ echo "check k8s ctx info"
110+ kubectl config get-contexts
111+ echo "check k8s ctx info finished"
112+ echo "Current directory: $(pwd)"
113+ echo "KUBECONFIG: $KUBECONFIG"
114+ kubectl config get-contexts || echo "No contexts available"
115+ kubectl cluster-info || echo "Cluster info failed"
116+ docker ps || echo "Docker ps failed"
117+ kind get clusters || echo "Kind get clusters failed"
118+ ls -la $HOME/.kube/ || echo "No .kube directory"
119+ cat $HOME/.kube/config || echo "No standard config"
120+ cat $HOME/.kube/karmada.config || echo "No karmada config"
121+ cat $HOME/.kube/members.config || echo "No members config"
122+ echo "=================="
102123 - name : Checkout dashboard repo
103124 uses : actions/checkout@v4
104125 with :
105126 path : karmada-dashboard
127+
128+ - name : Generate KARMADA_TOKEN for CI
129+ run : |
130+ # kubectl --context=karmada-apiserver create sa e2e-test -n kube-system
131+ # kubectl --context=karmada-apiserver create clusterrolebinding e2e-test-binding \
132+ # --clusterrole=cluster-admin \
133+ # --serviceaccount=kube-system:e2e-test
134+
135+ # 使用 kubectl create token 命令生成临时 token
136+ #TOKEN=$(kubectl --context=karmada-apiserver create token e2e-test -n kube-system --duration=3600s)
137+ # kubectl --context=karmada-apiserver apply -f karmada-dashboard/artifacts/dashboard
138+ kubectl --context=karmada-host apply -k karmada-dashboard/artifacts/overlays/nodeport-mode
139+ kubectl --context=karmada-apiserver apply -f karmada-dashboard/artifacts/dashboard/karmada-dashboard-sa.yaml
140+ TOKEN=$(kubectl --context=karmada-apiserver -n karmada-system get secret/karmada-dashboard-secret -o go-template="{{.data.token | base64decode}}")
141+ echo "KARMADA_TOKEN=$TOKEN" >> $GITHUB_ENV
106142 - name : Use Node.js 20
107143 uses : actions/setup-node@v4
108144 with :
@@ -111,25 +147,85 @@ jobs:
111147 with :
112148 # keep in sync with the packageManager version in `ui/package.json`
113149 version : 9.1.2
150+
114151 - name : Install dependencies
115152 run : |
116153 echo "Start build"
117154 pnpm --version
118155 cd karmada-dashboard/ui
119156 pnpm install
120157 pnpm turbo build
158+ - name : Build API binary
159+ run : |
160+ cd karmada-dashboard
161+ make build
162+ - name : Start API server
163+ run : |
164+ cd karmada-dashboard
165+ make run-api &
166+ echo $! > .api.pid
167+ sleep 5
168+ # ===== 添加API服务器健康检查 =====
169+ - name : Wait for API server to be ready
170+ run : |
171+ echo "Waiting for API server to be ready..."
172+ timeout 60s bash -c 'while ! nc -z localhost 8000; do echo "Waiting for API server port..."; sleep 5; done' || {
173+ echo "API server failed to start within 60 seconds"
174+ echo "=== API Server Debug ==="
175+ if [ -f karmada-dashboard/.api.pid ]; then
176+ API_PID=$(cat karmada-dashboard/.api.pid)
177+ ps aux | grep $API_PID || echo "API process not found"
178+ fi
179+ ss -tuln | grep 8000 || echo "Port 8000 not listening"
180+ exit 1
181+ }
182+ echo "API server is ready!"
121183 - name : Install Playwright Browsers
122184 run : |
123185 cd karmada-dashboard/ui/apps/dashboard
124186 pnpm exec playwright install --with-deps
187+ - name : Debug environment before starting dashboard
188+ run : |
189+ echo "=== Environment Debug ==="
190+ echo "KARMADA_TOKEN is set: ${{ env.KARMADA_TOKEN != '' }}"
191+ echo "KUBECONFIG: $KUBECONFIG"
192+ echo "Current directory: $(pwd)"
193+ echo "Dashboard directory contents:"
194+ ls -la karmada-dashboard/ || echo "No dashboard directory"
195+ echo "Check if Makefile exists:"
196+ ls -la karmada-dashboard/Makefile || echo "No Makefile found"
197+ echo "========================="
198+ - name : Build frontend (for e2e)
199+ working-directory : karmada-dashboard/ui/apps/dashboard
200+ run : |
201+ pnpm build
202+ - name : Test API connectivity before running tests
203+ run : |
204+ echo "Testing API connectivity..."
205+ # 测试几个关键的API端点
206+ curl -f http://localhost:8000/api/v1/cluster && echo "✓ Cluster API works" || echo "✗ Cluster API failed"
207+ curl -f http://localhost:8000/api/v1/namespace && echo "✓ Namespace API works" || echo "✗ Namespace API failed"
208+ echo "API tests completed"
209+ - name : Debug working dir
210+ run : |
211+ pwd
212+ ls -al
125213 - name : Run Playwright tests
214+ working-directory : karmada-dashboard/ui/apps/dashboard
126215 run : |
127- cd karmada-dashboard/ui/apps/dashboard
128216 pnpm exec playwright test
217+ # ===== 添加进程清理 =====
218+ - name : Cleanup processes
219+ if : always()
220+ run : |
221+ echo "Cleaning up processes..."
222+ if [ -f karmada-dashboard/.api.pid ]; then
223+ API_PID=$(cat karmada-dashboard/.api.pid)
224+ kill $API_PID 2>/dev/null || echo "API process already stopped"
225+ fi
129226 - uses : actions/upload-artifact@v4
130227 if : ${{ !cancelled() }}
131228 with :
132229 name : playwright-report-${{ matrix.k8s }}
133230 path : karmada-dashboard/ui/apps/dashboard/playwright-report/
134- retention-days : 30
135-
231+ retention-days : 30
0 commit comments