-
Notifications
You must be signed in to change notification settings - Fork 88
227 lines (219 loc) · 8.7 KB
/
ci.yml
File metadata and controls
227 lines (219 loc) · 8.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# Reference: https://github.com/karmada-io/karmada/blob/master/.github/workflows/ci.yml
# We cut some unused job to make the workflow more suitable for ci of karmada dashboard
name: CI Workflow
on:
# Run this workflow every time a new commit pushed to upstream/fork repository.
# Run workflow on fork repository will help contributors find and resolve issues before sending a PR.
push:
# Exclude branches created by Dependabot to avoid triggering current workflow
# for PRs initiated by Dependabot.
branches-ignore:
- 'dependabot/**'
pull_request:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.actor }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read # for actions/checkout to fetch code
env:
DEBUG: false
jobs:
golangci:
name: lint
runs-on: ubuntu-22.04
steps:
- name: checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: install Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
- name: verify license
run: hack/verify-license.sh
- name: lint
run: hack/verify-staticcheck.sh
unit-test:
name: unit test
runs-on: ubuntu-22.04
steps:
- name: checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: install Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
- name: Run tests
run: make test
build-frontend:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Use Node.js 20
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: 20
- uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
with:
# keep in sync with the packageManager version in `ui/package.json`
version: 9.1.2
- name: Build dashboard
run: |
echo "Start build"
pnpm --version
cd ui
pnpm install
pnpm turbo build
build-bin:
name: build-bin
runs-on: ubuntu-22.04
steps:
- name: checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
# Number of commits to fetch. 0 indicates all history for all branches and tags.
# We need to guess version via git tags.
fetch-depth: 0
- name: install Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
- name: compile
run: make all
e2e-frontend:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
# Here support the latest three minor releases of Kubernetes, this can be considered to be roughly
# the same as the End of Life of the Kubernetes release: https://kubernetes.io/releases/
# Please remember to update the CI Schedule Workflow when we add a new version.
k8s: [ v1.31.0, v1.32.0, v1.33.0 ]
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
with:
# this might remove tools that are actually needed, if set to "true" but frees about 6 GB
tool-cache: false
# all of these default to true, but feel free to set to "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: false
swap-storage: false
- name: Checkout karmada repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: karmada-io/karmada
path: karmada
- name: setup e2e test environment
run: |
cd karmada
export CLUSTER_VERSION=kindest/node:${{ matrix.k8s }}
hack/local-up-karmada.sh
echo "KUBECONFIG=/home/runner/.kube/karmada.config" >> $GITHUB_ENV
- name: Debug cluster status
if: ${{ env.DEBUG == 'true' }}
run: |
kubectl cluster-info || echo "Cluster info failed"
kubectl get nodes -o wide || echo "Get nodes failed"
kubectl get pods -A || echo "Get pods failed"
kind get clusters || echo "Kind get clusters failed"
- name: Checkout dashboard repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
path: karmada-dashboard
- name: Generate KARMADA_TOKEN for CI
run: |
kubectl --context=karmada-host apply -k karmada-dashboard/artifacts/overlays/nodeport-mode
kubectl --context=karmada-apiserver apply -f karmada-dashboard/artifacts/dashboard/karmada-dashboard-sa.yaml
TOKEN=$(kubectl --context=karmada-apiserver -n karmada-system get secret/karmada-dashboard-secret -o go-template="{{.data.token | base64decode}}")
echo "KARMADA_TOKEN=$TOKEN" >> $GITHUB_ENV
- name: Use Node.js 20
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: 20
- uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
with:
# keep in sync with the packageManager version in `ui/package.json`
version: 9.1.2
- name: Install dependencies
run: |
echo "Start build"
pnpm --version
cd karmada-dashboard/ui
pnpm install
pnpm turbo build
- name: Build API binary
run: |
cd karmada-dashboard
make build
- name: Start API server
run: |
cd karmada-dashboard
make run-api &
echo $! > .api.pid
sleep 5
- name: Wait for API server to be ready
run: |
echo "Waiting for API server to be ready..."
timeout 60s bash -c 'while ! nc -z localhost 8000; do echo "Waiting for API server port..."; sleep 5; done' || {
echo "API server failed to start within 60 seconds"
echo "=== API Server Debug ==="
if [ -f karmada-dashboard/.api.pid ]; then
API_PID=$(cat karmada-dashboard/.api.pid)
ps aux | grep $API_PID || echo "API process not found"
fi
ss -tuln | grep 8000 || echo "Port 8000 not listening"
exit 1
}
echo "API server is ready!"
- name: Install Playwright Browsers
run: |
cd karmada-dashboard/ui/apps/dashboard
pnpm exec playwright install --with-deps
- name: Debug environment before starting dashboard
if: ${{ env.DEBUG == 'true' }}
run: |
echo "KARMADA_TOKEN is set: ${{ env.KARMADA_TOKEN != '' }}"
echo "KUBECONFIG: $KUBECONFIG"
echo "Current directory: $(pwd)"
echo "Dashboard directory contents:"
ls -la karmada-dashboard/ || echo "No dashboard directory"
echo "Check if Makefile exists:"
ls -la karmada-dashboard/Makefile || echo "No Makefile found"
- name: Build frontend (for e2e)
working-directory: karmada-dashboard/ui/apps/dashboard
run: |
pnpm build
- name: Test API connectivity before running tests
run: |
echo "Testing API connectivity..."
curl -f http://localhost:8000/api/v1/cluster && echo "✓ Cluster API works" || echo "✗ Cluster API failed"
curl -f http://localhost:8000/api/v1/namespace && echo "✓ Namespace API works" || echo "✗ Namespace API failed"
echo "API tests completed"
- name: Debug working dir
if: ${{ env.DEBUG == 'true' }}
run: |
pwd
ls -al
- name: Run Playwright tests
working-directory: karmada-dashboard/ui/apps/dashboard
run: |
pnpm exec playwright test
- name: Cleanup processes
if: always()
run: |
echo "Cleaning up processes..."
if [ -f karmada-dashboard/.api.pid ]; then
API_PID=$(cat karmada-dashboard/.api.pid)
kill $API_PID 2>/dev/null || echo "API process already stopped"
fi
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
if: ${{ !cancelled() }}
with:
name: playwright-report-${{ matrix.k8s }}
path: karmada-dashboard/ui/apps/dashboard/playwright-report/
retention-days: 30