Skip to content

Commit 5380587

Browse files
committed
Split taskfiles by components (#49)
* refactor: split taskfiles by components This commit contains modifications to the existing taskfiles and creates new one as well. The modifications are the followings: - Remove forced current working directory in samples apps - Mark unused tasks as internal - Fix some bugs - Create some checks The new taskfiles is for organizing all of the tasks into the repo root main taskfile, so tasks can be called from everywhere. Signed-off-by: Árpád Csepi <[email protected]> * ci: use new taskfile structure Signed-off-by: Árpád Csepi <[email protected]> * fix: change all taskfile extension to .yml Signed-off-by: Árpád Csepi <[email protected]> * ci: fix detect changes in samples Signed-off-by: Árpád Csepi <[email protected]> * fix(samples): call task without subshell Signed-off-by: Árpád Csepi <[email protected]> * ci(integrations): enable workflow run on PR and main merge Signed-off-by: Árpád Csepi <[email protected]> * ci(integrations): fix kind version on alt trigger Signed-off-by: Árpád Csepi <[email protected]> --------- Signed-off-by: Árpád Csepi <[email protected]>
1 parent 27c6804 commit 5380587

File tree

15 files changed

+330
-248
lines changed

15 files changed

+330
-248
lines changed

.github/workflows/test-integrations.yaml

+32-29
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,38 @@
33

44
name: test-integrations
55
on:
6+
push:
7+
branches:
8+
- main
9+
pull_request:
610
workflow_dispatch:
711
inputs:
8-
destroy-cluster:
9-
description: 'Destroy test cluster'
10-
required: false
11-
default: true
12-
type: boolean
13-
python-version:
14-
description: 'Python version to install'
15-
required: false
16-
default: '3.12'
1712
kind-version:
1813
description: 'Kind version'
1914
required: false
2015
default: '0.24.0'
2116

2217
jobs:
18+
set-kind-version:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
kind-version: ${{steps.set-kind-version.outputs.kind-version }}
22+
steps:
23+
- name: Set KinD version
24+
id: set-kind-version
25+
env:
26+
KIND_VERSION: '0.24.0'
27+
shell: bash
28+
run: |
29+
if [ "${{ github.event_name }}" == 'workflow_dispatch' ]; then
30+
KIND_VERSION="${{ inputs.kind-version }}"
31+
fi
32+
33+
echo "Set KinD version to: $KIND_VERSION"
34+
echo "kind-version=$KIND_VERSION" >> "$GITHUB_OUTPUT"
35+
2336
run-tests-gateway:
37+
needs: [ set-kind-version ]
2438
runs-on: ubuntu-latest
2539

2640
permissions:
@@ -51,18 +65,14 @@ jobs:
5165
- name: Setup K8S Tools
5266
uses: ./.github/actions/setup-k8s
5367
with:
54-
kind-version: ${{ inputs.kind-version }}
68+
kind-version: ${{ needs.set-kind-version.outputs.kind-version }}
5569

5670
- name: Create kind cluster
57-
run: |
58-
cd integrations
59-
task kind:create
71+
run: task integrations:kind:create
6072
shell: bash
6173

6274
- name: Deploy agntcy agp
63-
run: |
64-
cd integrations
65-
task test:env:gateway:deploy
75+
run: task integrations:gateway:test-env:deploy
6676
shell: bash
6777

6878
- name: Run simple gateway tests
@@ -72,12 +82,11 @@ jobs:
7282
AZURE_DEPLOYMENT_NAME: ${{ vars.AZURE_DEPLOYMENT_NAME }}
7383
AZURE_OPENAI_API_VERSION: ${{ vars.AZURE_OPENAI_API_VERSION }}
7484
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
75-
run: |
76-
cd integrations
77-
task test:gateway
85+
run: task integrations:gateway:test
7886
shell: bash
7987

8088
run-tests-directory:
89+
needs: [ set-kind-version ]
8190
runs-on: ubuntu-latest
8291

8392
permissions:
@@ -108,22 +117,16 @@ jobs:
108117
- name: Setup K8S Tools
109118
uses: ./.github/actions/setup-k8s
110119
with:
111-
kind-version: ${{ inputs.kind-version }}
120+
kind-version: ${{ needs.set-kind-version.outputs.kind-version }}
112121

113122
- name: Create kind cluster
114-
run: |
115-
cd integrations
116-
task kind:create
123+
run: task integrations:kind:create
117124
shell: bash
118125

119126
- name: Deploy agntcy dir
120-
run: |
121-
cd integrations
122-
task test:env:directory:deploy
127+
run: task integrations:directory:test-env:deploy
123128
shell: bash
124129

125130
- name: Run agent build tests
126-
run: |
127-
cd integrations
128-
task test:directory
131+
run: task integrations:directory:test
129132
shell: bash

.github/workflows/test-samples.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
uses: ./.github/actions/detect-changes
2828
id: detect-changes
2929
with:
30-
dirs: $(find ./samples \( -name 'pyproject.toml' -o -name 'Taskfile.yaml' \) | xargs -n1 dirname | sort -u)
30+
dirs: $(find ./samples -mindepth 2 \( -name 'pyproject.toml' -o -name 'Taskfile.yml' \) | xargs -n1 dirname | sort -u)
3131

3232
test:
3333
name: Test on samples

Taskfile.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright AGNTCY Contributors (https://github.com/agntcy)
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
---
5+
version: '3'
6+
7+
silent: true
8+
9+
includes:
10+
integrations:
11+
taskfile: ./integrations/Taskfile.yml
12+
dir: ./integrations
13+
samples:
14+
taskfile: ./samples/Taskfile.yml
15+
dir: ./samples
16+
17+
tasks:
18+
default:
19+
cmd: task -l

integrations/Taskfile.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright AGNTCY Contributors (https://github.com/agntcy)
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
---
5+
version: '3'
6+
7+
silent: true
8+
9+
includes:
10+
gateway:
11+
taskfile: ./agntcy-agp/Taskfile.yml
12+
dir: ./agntcy-agp
13+
directory:
14+
taskfile: ./agntcy-dir/Taskfile.yml
15+
dir: ./agntcy-dir
16+
17+
vars:
18+
KIND_CLUSTER_NAME: '{{ .KIND_CLUSTER_NAME | default "agntcy-test" }}'
19+
20+
tasks:
21+
kind:create:
22+
desc: Create kind cluster
23+
cmds:
24+
- kind create cluster --name {{.KIND_CLUSTER_NAME}} --wait 60s || true
25+
- kubectl cluster-info --context kind-{{.KIND_CLUSTER_NAME}}
26+
27+
kind:destroy:
28+
desc: Destroy kind cluster
29+
cmds:
30+
- kind delete cluster --name {{.KIND_CLUSTER_NAME}}
31+
32+
version:
33+
desc: Get version
34+
cmds:
35+
- git describe --tags --match "v*" | cut -c 2-

integrations/agntcy-agp/Taskfile.yml

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Copyright AGNTCY Contributors (https://github.com/agntcy)
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
---
5+
version: '3'
6+
7+
silent: true
8+
9+
vars:
10+
KIND_CLUSTER_NAME: '{{ .KIND_CLUSTER_NAME | default "agntcy-test" }}'
11+
12+
## Image config
13+
IMAGE_REPO: '{{ .IMAGE_REPO | default "ghcr.io/agntcy" }}'
14+
GATEWAY_IMAGE_TAG: '{{ .GATEWAY_IMAGE_TAG | default "0.3.2" }}'
15+
16+
IMAGE_BAKE_OPTS: '{{ .IMAGE_BAKE_OPTS | default "--set *.platform=linux/arm64" }}'
17+
TEST_APP_TAG: '{{ .TEST_APP_TAG | default "v0.0.3" }}'
18+
19+
AZURE_OPENAI_API_KEY: '{{ .AZURE_OPENAI_API_KEY | default "" }}'
20+
AZURE_OPENAI_ENDPOINT: '{{ .AZURE_OPENAI_ENDPOINT | default "" }}'
21+
22+
HELM_NAMESPACE: '{{ .HELM_NAMESPACE | default "default" }}'
23+
24+
REMOVE_CONTAINERS: '{{ .REMOVE_CONTAINERS | default "true" }}'
25+
26+
RUNNER_TYPE: '{{ .RUNNER_TYPE | default "docker" }}'
27+
28+
tasks:
29+
k8s:port-forward:setup:
30+
internal: true
31+
cmds:
32+
- kubectl port-forward svc/agntcy-agp -n {{ .HELM_NAMESPACE }} 46357 &
33+
- sleep 1
34+
35+
k8s:port-forward:teardown:
36+
internal: true
37+
cmds:
38+
- kill -9 $(ps aux | grep port-forward | grep agntcy-agp | awk '{print $2}') || true
39+
40+
test-env:deploy:
41+
desc: Deploy agntcy gateway test env
42+
cmds:
43+
- |
44+
kubectl config use-context kind-{{ .KIND_CLUSTER_NAME }} &&
45+
helm dependency build ./components/helm
46+
helm upgrade agntcy-agp \
47+
./components/helm \
48+
--set agp.image.tag="{{ .GATEWAY_IMAGE_TAG }}" \
49+
--namespace {{ .HELM_NAMESPACE }} \
50+
--create-namespace \
51+
--install \
52+
--wait \
53+
--wait-for-jobs \
54+
--timeout "15m"
55+
56+
test-env:cleanup:
57+
desc: Remove agent gateway test env
58+
cmds:
59+
- kubectl config use-context kind-{{ .KIND_CLUSTER_NAME }} &&
60+
- helm delete --namespace {{ .HELM_NAMESPACE }} agntcy-agp
61+
62+
build:agentic-apps:
63+
desc: Build agentic containers
64+
dir: ./agentic-apps
65+
cmds:
66+
- IMAGE_TAG={{ .TEST_APP_TAG }} docker buildx bake {{ .IMAGE_BAKE_OPTS }} --load
67+
68+
test:autogen-agent:run:
69+
internal: true
70+
cmds:
71+
- |
72+
hostNetFlag=""
73+
hostMachine=http://host.docker.internal:46357
74+
unameOut=$(uname -s)
75+
case ${unameOut} in
76+
Linux*)
77+
hostMachine=http://127.0.0.1:46357
78+
hostNetFlag="--net=host"
79+
;;
80+
Darwin*)
81+
hostMachine=http://host.docker.internal:46357
82+
;;
83+
*)
84+
esac
85+
echo "gw host: ${hostMachine}"
86+
87+
docker run -d --rm \
88+
-e AZURE_OPENAI_API_KEY={{.AZURE_OPENAI_API_KEY}} \
89+
-e AZURE_OPENAI_ENDPOINT={{.AZURE_OPENAI_ENDPOINT}} \
90+
${hostNetFlag} \
91+
--name autogen-agent \
92+
{{ .IMAGE_REPO }}/csit/test-autogen-agent:{{ .TEST_APP_TAG }} \
93+
poetry run python autogen_agent.py -g ${hostMachine}
94+
95+
test:autogen-agent:remove:
96+
internal: true
97+
cmds:
98+
- docker stop $(docker ps -a --no-trunc --filter name=^/autogen-agent$ -q)
99+
100+
test:
101+
desc: All gateway test
102+
cmds:
103+
- task: k8s:port-forward:setup
104+
- defer: { task: k8s:port-forward:teardown }
105+
- task: test:autogen-agent:run
106+
- defer: { task: test:autogen-agent:remove }
107+
- docker pull {{ .IMAGE_REPO }}/csit/test-langchain-agent:{{ .TEST_APP_TAG }}
108+
- REMOVE_CONTAINERS={{.REMOVE_CONTAINERS}} RUNNER_TYPE={{.RUNNER_TYPE}} IMAGE_REPO={{.IMAGE_REPO}} TEST_APP_TAG={{.TEST_APP_TAG}} go test ./tests -v -failfast -test.v -test.paniconexit0 -ginkgo.timeout 30m -timeout 30m -ginkgo.v

0 commit comments

Comments
 (0)