-
Notifications
You must be signed in to change notification settings - Fork 423
363 lines (324 loc) · 11 KB
/
ci.yaml
File metadata and controls
363 lines (324 loc) · 11 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
name: CI Build
on:
push:
branches: [main, release/v0.7.x]
paths-ignore:
- "**/*.md"
pull_request:
branches: [main, release/v0.7.x]
paths-ignore:
- "**/*.md"
workflow_dispatch:
env:
# Cache key components for better organization
CACHE_KEY_PREFIX: kagent-v2
BRANCH_CACHE_KEY: ${{ github.head_ref || github.ref_name }}
# Consistent builder configuration
BUILDX_BUILDER_NAME: kagent-builder-v0.23.0
BUILDX_VERSION: v0.23.0
jobs:
setup:
runs-on: ubuntu-latest
outputs:
cache-key: ${{ steps.cache-key.outputs.key }}
steps:
- name: Generate cache keys
id: cache-key
run: |
# Generate branch-based cache key
BRANCH_KEY="${CACHE_KEY_PREFIX}-${BRANCH_CACHE_KEY}"
echo "key=${BRANCH_KEY}" >> $GITHUB_OUTPUT
echo "::notice title=Cache Key::Branch: ${BRANCH_KEY}"
test-e2e:
needs:
- setup
strategy:
fail-fast: false
matrix:
database: [sqlite, postgres]
env:
VERSION: v0.0.1-test
runs-on: ubuntu-latest
services:
postgres:
image: pgvector/pgvector:pg18-trixie
env:
POSTGRES_DB: kagent
POSTGRES_USER: postgres
POSTGRES_PASSWORD: kagent
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Initialize Environment
uses: ./.github/actions/initialize-environment
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
name: ${{ env.BUILDX_BUILDER_NAME }}
version: ${{ env.BUILDX_VERSION }}
platforms: linux/amd64,linux/arm64
use: "true"
driver-opts: network=host
- name: Set up Helm
uses: azure/setup-helm@v4.2.0
with:
version: v3.18.0
- name: Install Kind
id: kind
uses: helm/kind-action@b72c923563e6e80ea66e8e8c810798cc73e97e5e
with:
install_only: true
- name: Install Kagent
id: install-kagent
env:
OPENAI_API_KEY: fake
BUILDX_BUILDER_NAME: ${{ env.BUILDX_BUILDER_NAME }}
KAGENT_HELM_EXTRA_ARGS: --cleanup-on-fail=false
DOCKER_BUILD_ARGS: >-
--cache-from=type=gha,scope=${{ needs.setup.outputs.cache-key }}-e2e
--cache-from=type=gha,scope=${{ env.CACHE_KEY_PREFIX }}-main-e2e
--cache-to=type=gha,scope=${{ needs.setup.outputs.cache-key }}-e2e,mode=max
--platform=linux/amd64
--push
run: |
make create-kind-cluster
echo "Cache key: ${{ needs.setup.outputs.cache-key }}"
if [ "${{ matrix.database }}" = "postgres" ]; then
HOST_IP=$(docker network inspect kind -f '{{range .IPAM.Config}}{{if .Gateway}}{{.Gateway}}{{"\n"}}{{end}}{{end}}' | grep -E '^[0-9]+\.' | head -1)
export KAGENT_HELM_EXTRA_ARGS="$KAGENT_HELM_EXTRA_ARGS --set database.type=postgres --set database.postgres.url=postgres://postgres:kagent@${HOST_IP}:5432/kagent"
echo "Postgres URL: postgres://postgres:kagent@${HOST_IP}:5432/kagent"
fi
make helm-install
make push-test-agent push-test-skill
kubectl wait --for=condition=Ready agents.kagent.dev -n kagent --all --timeout=60s || kubectl get po -n kagent -o wide ||:
kubectl wait --for=condition=Ready agents.kagent.dev -n kagent --all --timeout=60s
- name: Run e2e tests
if: success()
working-directory: go/core
run: |
# Get the Kind network gateway IP that pods can reach
HOST_IP=$(docker network inspect kind -f '{{range .IPAM.Config}}{{if .Gateway}}{{.Gateway}}{{"\n"}}{{end}}{{end}}' | grep -E '^[0-9]+\.' | head -1)
echo "Detected Kind network gateway: $HOST_IP"
export KAGENT_LOCAL_HOST=$HOST_IP
export KAGENT_URL="http://$(kubectl get svc -n kagent kagent-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}'):8083"
echo "KAGENT_URL: $KAGENT_URL"
echo "KAGENT_LOCAL_HOST: $KAGENT_LOCAL_HOST"
# no need to run e2e tests with race, as this will just apply to the test code.
# all objects created in e2e tests have a generated name, so they can run in parallel safely.
go test -v github.com/kagent-dev/kagent/go/core/test/e2e -failfast -shuffle=on
- name: fail print info
if: failure()
run: |
echo "::error::Failed to run e2e tests"
echo "::error::Kubectl get pods -n kagent"
kubectl describe pods -n kagent
echo "::error::Kubectl get events -n kagent"
kubectl get events -n kagent
echo "::error::Kubectl get agents -n kagent"
echo "::error::Kubectl logs -n kagent deployment/kagent-controller"
kubectl logs -n kagent deployment/kagent-controller
go-unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.25"
cache: true
cache-dependency-path: go/*/go.sum
- name: Run Go unit tests
working-directory: go
run: |
go test -race -skip 'TestE2E.*' -v ./api/... ./adk/... ./core/...
helm-unit-tests:
env:
VERSION: v0.0.1-test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Helm
uses: azure/setup-helm@v4.2.0
with:
version: v3.18.0
# Install unittest plugin
- name: Install unittest plugin
run: |
helm plugin install https://github.com/helm-unittest/helm-unittest
- name: Chart init
run: |
make helm-version
- name: Run helm unit tests
run: |
helm unittest helm/kagent
ui-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "24"
cache: "npm"
cache-dependency-path: ui/package-lock.json
- name: Install dependencies
working-directory: ./ui
env:
CYPRESS_INSTALL_BINARY: 0 # Skip Cypress binary - not needed for lint/unit tests
run: npm ci
- name: Run lint
working-directory: ./ui
run: npm run lint
- name: Run tests
working-directory: ./ui
run: npm run test
# This job builds the Docker images for the controller, UI, app, and CLI on arm64.
build:
needs: setup
env:
VERSION: v0.0.1-test
strategy:
matrix:
image:
- controller
- ui
- app
- cli
- golang-adk
- skills-init
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5001:5000
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
name: ${{ env.BUILDX_BUILDER_NAME }}
platforms: linux/amd64,linux/arm64
version: ${{ env.BUILDX_VERSION }}
use: "true"
driver-opts: network=host
- name: Run make build
env:
BUILDX_BUILDER_NAME: ${{ env.BUILDX_BUILDER_NAME }}
DOCKER_BUILD_ARGS: >-
--cache-from=type=gha,scope=${{ needs.setup.outputs.cache-key }}-${{ matrix.image }}
--cache-from=type=gha,scope=${{ env.CACHE_KEY_PREFIX }}-main-${{ matrix.image }}
--cache-to=type=gha,scope=${{ needs.setup.outputs.cache-key }}-${{ matrix.image }},mode=max
--platform=linux/amd64,linux/arm64
--push
DOCKER_REPO: "${{ github.repository_owner }}/kagent"
DOCKER_BUILDER: "docker buildx"
run: make build-${{ matrix.image }}
working-directory: ./
go-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.25"
cache: true
cache-dependency-path: go/*/go.sum
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.8.0
working-directory: go/core
python-test:
env:
OPENAI_API_KEY: fake
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Install python
run: uv python install ${{ matrix.python-version }}
- name: Sync dependencies
working-directory: ./python
run: uv sync --all-extras
- name: Generate test certificates
working-directory: ./python
run: make generate-test-certs
- name: Run tests
working-directory: ./python
run: make test
python-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Install python
run: uv python install 3.10
- name: Sync dependencies
working-directory: ./python
run: uv sync --all-extras
- name: Run ruff linter
working-directory: ./python
run: uv run ruff check
- name: Run ruff format check
working-directory: ./python
run: |
if ! uv run ruff format --diff .; then
echo "Ruff formatting issues detected. Please run 'uv run ruff format' locally to fix formatting issues."
exit 1
fi
manifests-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.25"
cache: true
cache-dependency-path: go/*/go.sum
- name: Generate controller manifests
run: make controller-manifests
- name: Check for uncommitted changes
run: |
if ! git diff --exit-code; then
echo "::error::Controller manifests are out of date!"
echo "::error::Please run 'make controller-manifests' and commit the changes."
echo ""
echo "The following files have differences:"
git diff --name-only
echo ""
echo "Diff details:"
git diff
exit 1
fi
echo "✓ Controller manifests are up to date"