-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTaskfile.yaml
241 lines (208 loc) · 8.71 KB
/
Taskfile.yaml
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
# Copyright AGNTCY Contributors (https://github.com/agntcy)
# SPDX-License-Identifier: Apache-2.0
---
version: '3'
silent: true
vars:
KIND_CLUSTER_NAME: '{{ .KIND_CLUSTER_NAME | default "agntcy-test" }}'
## Image config
IMAGE_REPO: '{{ .IMAGE_REPO | default "ghcr.io/agntcy" }}'
GATEWAY_IMAGE_TAG: '{{ .GATEWAY_IMAGE_TAG | default "0.3.2" }}'
DIRECTORY_IMAGE_TAG: '{{ .DIRECTORY_IMAGE_TAG | default "v0.2.0" }}'
IMAGE_BAKE_OPTS: '{{ .IMAGE_BAKE_OPTS | default "--set *.platform=linux/arm64" }}'
TEST_APP_TAG: '{{ .TEST_APP_TAG | default "v0.0.3" }}'
AZURE_OPENAI_API_KEY: '{{ .AZURE_OPENAI_API_KEY | default "" }}'
AZURE_OPENAI_ENDPOINT: '{{ .AZURE_OPENAI_ENDPOINT | default "" }}'
HELM_NAMESPACE: '{{ .HELM_NAMESPACE | default "default" }}'
REMOVE_CONTAINERS: '{{ .REMOVE_CONTAINERS | default "true" }}'
RUNNER_TYPE: '{{ .RUNNER_TYPE | default "docker" }}'
ARCH:
sh: |
if [ "$ARCH" == "" ]; then
uname -m
else
printf $ARCH
fi
OS:
sh: |
if [ "$OS" == "" ]; then
uname -s
else
printf $OS
fi
DIRCTL_BIN_PATH:
sh: |
if [ "$DIRCTL_BIN_PATH" == "" ]; then
mkdir -p $PWD/agntcy-dir/tests/.bin
printf $PWD/agntcy-dir/tests/.bin
else
printf $DIRCTL_BIN_PATH
fi
DIRCTL_BIN_VERSION: '{{ .DIRCTL_BIN_VERSION | default "v0.2.0" }}'
tasks:
kind:create:
desc: Create kind cluster
cmds:
- kind create cluster --name {{.KIND_CLUSTER_NAME}} --wait 60s || true
- kubectl cluster-info --context kind-{{.KIND_CLUSTER_NAME}}
kind:destroy:
desc: Destroy kind cluster
cmds:
- kind delete cluster --name {{.KIND_CLUSTER_NAME}}
k8s:port-forward:setup:directory:
internal: true
cmds:
- kubectl port-forward svc/agntcy-dir-apiserver -n {{ .HELM_NAMESPACE }} 8888 &
- sleep 1
k8s:port-forward:teardown:directory:
internal: true
cmds:
- kill -9 $(ps aux | grep port-forward | grep agntcy-dir-apiserver | awk '{print $2}') || true
k8s:port-forward:setup:gateway:
internal: true
cmds:
- kubectl port-forward svc/agntcy-agp -n {{ .HELM_NAMESPACE }} 46357 &
- sleep 1
k8s:port-forward:teardown:gateway:
internal: true
cmds:
- kill -9 $(ps aux | grep port-forward | grep agntcy-agp | awk '{print $2}') || true
test:env:directory:deploy:
desc: Deploy Agntcy directory test env
vars:
REGCRED_CREATE: '{{ .REGCRED_CREATE | default "false" }}'
cmds:
- |
helm dependency build ./agntcy-dir/components/helm
helm upgrade agntcy-dir \
./agntcy-dir/components/helm \
--set dir.apiserver.image.tag="{{ .DIRECTORY_IMAGE_TAG }}" \
--set regcred.create="{{ .REGCRED_CREATE }}" \
--namespace {{ .HELM_NAMESPACE }} \
--create-namespace \
--install \
--wait \
--wait-for-jobs \
--timeout "15m"
test:env:directory:cleanup:
desc: Remove agntcy directory test env
cmds:
- helm delete --namespace {{ .HELM_NAMESPACE }} agntcy-dir
test:env:gateway:deploy:
desc: Deploy agntcy gateway test env
cmds:
- |
helm dependency build ./agntcy-agp/components/helm
helm upgrade agntcy-agp \
./agntcy-agp/components/helm \
--set agp.image.tag="{{ .GATEWAY_IMAGE_TAG }}" \
--namespace {{ .HELM_NAMESPACE }} \
--create-namespace \
--install \
--wait \
--wait-for-jobs \
--timeout "15m"
test:env:gateway:cleanup:
desc: Remove agent gateway test env
cmds:
- helm delete --namespace {{ .HELM_NAMESPACE }} agntcy-agp
build:gateway:agentic-apps:
desc: Build agentic containers
dir: ./agntcy-agp/agentic-apps
cmds:
- IMAGE_TAG={{ .TEST_APP_TAG }} docker buildx bake {{ .IMAGE_BAKE_OPTS }} --load
test:directory:
desc: Directory test
cmds:
- task: k8s:port-forward:setup:directory
- defer: { task: k8s:port-forward:teardown:directory }
- defer: { task: manifests:cleanup }
- REMOVE_CONTAINERS={{.REMOVE_CONTAINERS}} RUNNER_TYPE={{.RUNNER_TYPE}} PATH=$PATH:{{.DIRCTL_BIN_PATH}} IMAGE_REPO={{.IMAGE_REPO}} DIRECTORY_IMAGE_TAG={{.DIRECTORY_IMAGE_TAG}} go test ./agntcy-dir/tests -v -failfast -test.v -test.paniconexit0 -ginkgo.timeout 30m -timeout 30m -ginkgo.v
test:directory:compiler:
desc: Agntcy compiler test
cmds:
- docker pull {{.IMAGE_REPO}}/dir-ctl:{{.DIRECTORY_IMAGE_TAG}}
- REMOVE_CONTAINERS={{.REMOVE_CONTAINERS}} RUNNER_TYPE={{.RUNNER_TYPE}} PATH=$PATH:{{.DIRCTL_BIN_PATH}} IMAGE_REPO={{.IMAGE_REPO}} DIRECTORY_IMAGE_TAG={{.DIRECTORY_IMAGE_TAG}} go test ./agntcy-dir/tests -v -failfast -test.v -test.paniconexit0 -ginkgo.timeout 10m -timeout 10m -ginkgo.v -ginkgo.focus "agent compilation"
test:directory:compile:samples:
desc: Agntcy compiler test in samples
cmds:
- docker pull {{.IMAGE_REPO}}/dir-ctl:{{.DIRECTORY_IMAGE_TAG}}
- REMOVE_CONTAINERS={{.REMOVE_CONTAINERS}} RUNNER_TYPE={{.RUNNER_TYPE}} PATH=$PATH:{{.DIRCTL_BIN_PATH}} IMAGE_REPO={{.IMAGE_REPO}} DIRECTORY_IMAGE_TAG={{.DIRECTORY_IMAGE_TAG}} go test ./agntcy-dir/tests -v -failfast -test.v -test.paniconexit0 -ginkgo.timeout 10m -timeout 10m -ginkgo.v -ginkgo.focus "Samples build test"
test:directory:push:
desc: Directory agent push test
cmds:
- task: k8s:port-forward:setup:directory
- defer: { task: k8s:port-forward:teardown:directory }
- defer: { task: manifests:cleanup }
- REMOVE_CONTAINERS={{.REMOVE_CONTAINERS}} RUNNER_TYPE={{.RUNNER_TYPE}} PATH=$PATH:{{.DIRCTL_BIN_PATH}} IMAGE_REPO={{.IMAGE_REPO}} DIRECTORY_IMAGE_TAG={{.DIRECTORY_IMAGE_TAG}} go test ./agntcy-dir/tests -v -failfast -test.v -test.paniconexit0 -ginkgo.timeout 30m -timeout 30m -ginkgo.v -ginkgo.focus "agent push and pull"
test:directory:list:
desc: Directory agent list test
cmds:
- task: k8s:port-forward:setup:directory
- defer: { task: k8s:port-forward:teardown:directory }
- defer: { task: manifests:cleanup }
- REMOVE_CONTAINERS={{.REMOVE_CONTAINERS}} RUNNER_TYPE={{.RUNNER_TYPE}} PATH=$PATH:{{.DIRCTL_BIN_PATH}} IMAGE_REPO={{.IMAGE_REPO}} DIRECTORY_IMAGE_TAG={{.DIRECTORY_IMAGE_TAG}} go test ./agntcy-dir/tests -v -failfast -test.v -test.paniconexit0 -ginkgo.timeout 30m -timeout 30m -ginkgo.v -ginkgo.focus "Agntcy agent list tests"
test:autogen-agent:run:
internal: true
cmds:
- |
hostNetFlag=""
hostMachine=http://host.docker.internal:46357
unameOut=$(uname -s)
case ${unameOut} in
Linux*)
hostMachine=http://127.0.0.1:46357
hostNetFlag="--net=host"
;;
Darwin*)
hostMachine=http://host.docker.internal:46357
;;
*)
esac
echo "gw host: ${hostMachine}"
docker run -d --rm \
-e AZURE_OPENAI_API_KEY={{.AZURE_OPENAI_API_KEY}} \
-e AZURE_OPENAI_ENDPOINT={{.AZURE_OPENAI_ENDPOINT}} \
${hostNetFlag} \
--name autogen-agent \
{{ .IMAGE_REPO }}/csit/test-autogen-agent:{{ .TEST_APP_TAG }} \
poetry run python autogen_agent.py -g ${hostMachine}
test:autogen-agent:remove:
internal: true
cmds:
- docker stop $(docker ps -a --no-trunc --filter name=^/autogen-agent$ -q)
test:gateway:
desc: Gateway test
cmds:
- task: k8s:port-forward:setup:gateway
- defer: { task: k8s:port-forward:teardown:gateway }
- task: test:autogen-agent:run
- defer: { task: test:autogen-agent:remove }
- docker pull {{ .IMAGE_REPO }}/csit/test-langchain-agent:{{ .TEST_APP_TAG }}
- REMOVE_CONTAINERS={{.REMOVE_CONTAINERS}} RUNNER_TYPE={{.RUNNER_TYPE}} IMAGE_REPO={{.IMAGE_REPO}} TEST_APP_TAG={{.TEST_APP_TAG}} go test ./agntcy-agp/tests -v -failfast -test.v -test.paniconexit0 -ginkgo.timeout 30m -timeout 30m -ginkgo.v
version:
desc: Get version
cmds:
- git describe --tags --match "v*" | cut -c 2-
download:dirctl-bin:
desc: Get dirctl binary from GitHub
vars:
ARCH:
sh: |
printf "%s" "{{.ARCH}}" | \
sed -E 's/^(aarch64|aarch64_be|armv6l|armv7l|armv8b|armv8l)$$/arm64/g' | \
sed -E 's/^x86_64$$/amd64/g'
OS:
sh: printf "%s" "{{.OS}}" | tr '[:upper:]' '[:lower:]'
cmds:
- |
URL=https://github.com/agntcy/dir/releases/download/{{.DIRCTL_BIN_VERSION}}/dirctl-{{.OS}}-{{.ARCH}}
echo $URL
curl \
--fail \
--show-error \
--location $URL \
--output "{{.DIRCTL_BIN_PATH}}/dirctl" && \
chmod +x "{{.DIRCTL_BIN_PATH}}/dirctl"
# NOTE: The attribute may removed already, silent errors
xattr -d com.apple.quarantine "{{.DIRCTL_BIN_PATH}}/dirctl" &> /dev/null || true