diff --git a/.github/workflows/test-integrations.yaml b/.github/workflows/test-integrations.yaml index 116f2ab..3c24946 100644 --- a/.github/workflows/test-integrations.yaml +++ b/.github/workflows/test-integrations.yaml @@ -3,24 +3,38 @@ name: test-integrations on: + push: + branches: + - main + pull_request: workflow_dispatch: inputs: - destroy-cluster: - description: 'Destroy test cluster' - required: false - default: true - type: boolean - python-version: - description: 'Python version to install' - required: false - default: '3.12' kind-version: description: 'Kind version' required: false default: '0.24.0' jobs: + set-kind-version: + runs-on: ubuntu-latest + outputs: + kind-version: ${{steps.set-kind-version.outputs.kind-version }} + steps: + - name: Set KinD version + id: set-kind-version + env: + KIND_VERSION: '0.24.0' + shell: bash + run: | + if [ "${{ github.event_name }}" == 'workflow_dispatch' ]; then + KIND_VERSION="${{ inputs.kind-version }}" + fi + + echo "Set KinD version to: $KIND_VERSION" + echo "kind-version=$KIND_VERSION" >> "$GITHUB_OUTPUT" + run-tests-gateway: + needs: [ set-kind-version ] runs-on: ubuntu-latest permissions: @@ -51,18 +65,14 @@ jobs: - name: Setup K8S Tools uses: ./.github/actions/setup-k8s with: - kind-version: ${{ inputs.kind-version }} + kind-version: ${{ needs.set-kind-version.outputs.kind-version }} - name: Create kind cluster - run: | - cd integrations - task kind:create + run: task integrations:kind:create shell: bash - name: Deploy agntcy agp - run: | - cd integrations - task test:env:gateway:deploy + run: task integrations:gateway:test-env:deploy shell: bash - name: Run simple gateway tests @@ -72,12 +82,11 @@ jobs: AZURE_DEPLOYMENT_NAME: ${{ vars.AZURE_DEPLOYMENT_NAME }} AZURE_OPENAI_API_VERSION: ${{ vars.AZURE_OPENAI_API_VERSION }} AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} - run: | - cd integrations - task test:gateway + run: task integrations:gateway:test shell: bash run-tests-directory: + needs: [ set-kind-version ] runs-on: ubuntu-latest permissions: @@ -108,22 +117,16 @@ jobs: - name: Setup K8S Tools uses: ./.github/actions/setup-k8s with: - kind-version: ${{ inputs.kind-version }} + kind-version: ${{ needs.set-kind-version.outputs.kind-version }} - name: Create kind cluster - run: | - cd integrations - task kind:create + run: task integrations:kind:create shell: bash - name: Deploy agntcy dir - run: | - cd integrations - task test:env:directory:deploy + run: task integrations:directory:test-env:deploy shell: bash - name: Run agent build tests - run: | - cd integrations - task test:directory + run: task integrations:directory:test shell: bash diff --git a/.github/workflows/test-samples.yaml b/.github/workflows/test-samples.yaml index 63913e1..1ac18ab 100644 --- a/.github/workflows/test-samples.yaml +++ b/.github/workflows/test-samples.yaml @@ -27,7 +27,7 @@ jobs: uses: ./.github/actions/detect-changes id: detect-changes with: - dirs: $(find ./samples \( -name 'pyproject.toml' -o -name 'Taskfile.yaml' \) | xargs -n1 dirname | sort -u) + dirs: $(find ./samples -mindepth 2 \( -name 'pyproject.toml' -o -name 'Taskfile.yml' \) | xargs -n1 dirname | sort -u) test: name: Test on samples diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 0000000..c55f457 --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,19 @@ +# Copyright AGNTCY Contributors (https://github.com/agntcy) +# SPDX-License-Identifier: Apache-2.0 + +--- +version: '3' + +silent: true + +includes: + integrations: + taskfile: ./integrations/Taskfile.yml + dir: ./integrations + samples: + taskfile: ./samples/Taskfile.yml + dir: ./samples + +tasks: + default: + cmd: task -l diff --git a/integrations/Taskfile.yaml b/integrations/Taskfile.yaml deleted file mode 100644 index ce44ce0..0000000 --- a/integrations/Taskfile.yaml +++ /dev/null @@ -1,241 +0,0 @@ -# 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 diff --git a/integrations/Taskfile.yml b/integrations/Taskfile.yml new file mode 100644 index 0000000..e52dcde --- /dev/null +++ b/integrations/Taskfile.yml @@ -0,0 +1,35 @@ +# Copyright AGNTCY Contributors (https://github.com/agntcy) +# SPDX-License-Identifier: Apache-2.0 + +--- +version: '3' + +silent: true + +includes: + gateway: + taskfile: ./agntcy-agp/Taskfile.yml + dir: ./agntcy-agp + directory: + taskfile: ./agntcy-dir/Taskfile.yml + dir: ./agntcy-dir + +vars: + KIND_CLUSTER_NAME: '{{ .KIND_CLUSTER_NAME | default "agntcy-test" }}' + +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}} + + version: + desc: Get version + cmds: + - git describe --tags --match "v*" | cut -c 2- diff --git a/integrations/agntcy-agp/Taskfile.yml b/integrations/agntcy-agp/Taskfile.yml new file mode 100644 index 0000000..9bfe946 --- /dev/null +++ b/integrations/agntcy-agp/Taskfile.yml @@ -0,0 +1,108 @@ +# 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" }}' + + 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" }}' + +tasks: + k8s:port-forward:setup: + internal: true + cmds: + - kubectl port-forward svc/agntcy-agp -n {{ .HELM_NAMESPACE }} 46357 & + - sleep 1 + + k8s:port-forward:teardown: + internal: true + cmds: + - kill -9 $(ps aux | grep port-forward | grep agntcy-agp | awk '{print $2}') || true + + test-env:deploy: + desc: Deploy agntcy gateway test env + cmds: + - | + kubectl config use-context kind-{{ .KIND_CLUSTER_NAME }} && + helm dependency build ./components/helm + helm upgrade 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:cleanup: + desc: Remove agent gateway test env + cmds: + - kubectl config use-context kind-{{ .KIND_CLUSTER_NAME }} && + - helm delete --namespace {{ .HELM_NAMESPACE }} agntcy-agp + + build:agentic-apps: + desc: Build agentic containers + dir: ./agentic-apps + cmds: + - IMAGE_TAG={{ .TEST_APP_TAG }} docker buildx bake {{ .IMAGE_BAKE_OPTS }} --load + + 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: + desc: All gateway test + cmds: + - task: k8s:port-forward:setup + - defer: { task: k8s:port-forward:teardown } + - 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 ./tests -v -failfast -test.v -test.paniconexit0 -ginkgo.timeout 30m -timeout 30m -ginkgo.v diff --git a/integrations/agntcy-dir/Taskfile.yml b/integrations/agntcy-dir/Taskfile.yml new file mode 100644 index 0000000..24aae7c --- /dev/null +++ b/integrations/agntcy-dir/Taskfile.yml @@ -0,0 +1,141 @@ +# 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" }}' + DIRECTORY_IMAGE_TAG: '{{ .DIRECTORY_IMAGE_TAG | default "v0.2.0" }}' + + 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/tests/.bin + else + printf $DIRCTL_BIN_PATH + fi + DIRCTL_BIN_VERSION: '{{ .DIRCTL_BIN_VERSION | default "v0.2.0" }}' + +tasks: + k8s:port-forward:setup: + internal: true + cmds: + - kubectl port-forward svc/agntcy-dir-apiserver -n {{ .HELM_NAMESPACE }} 8888 & + - sleep 1 + + k8s:port-forward:teardown: + internal: true + cmds: + - kill -9 $(ps aux | grep port-forward | grep agntcy-dir-apiserver | awk '{print $2}') || true + + test-env:deploy: + desc: Deploy Agntcy directory test env + vars: + REGCRED_CREATE: '{{ .REGCRED_CREATE | default "false" }}' + cmds: + - | + kubectl config use-context kind-{{ .KIND_CLUSTER_NAME }} && + helm dependency build ./components/helm + helm upgrade 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:cleanup: + desc: Remove agntcy directory test env + cmds: + - kubectl config use-context kind-{{ .KIND_CLUSTER_NAME }} && + - helm delete --ignore-not-found --namespace {{ .HELM_NAMESPACE }} agntcy-dir + + test: + desc: All directory test + cmds: + - task: k8s:port-forward:setup + - defer: { task: k8s:port-forward:teardown } + - 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 ./tests -v -failfast -test.v -test.paniconexit0 -ginkgo.timeout 30m -timeout 30m -ginkgo.v + + test: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 ./tests -v -failfast -test.v -test.paniconexit0 -ginkgo.timeout 10m -timeout 10m -ginkgo.v -ginkgo.focus "agent compilation" + + test: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 ./tests -v -failfast -test.v -test.paniconexit0 -ginkgo.timeout 10m -timeout 10m -ginkgo.v -ginkgo.focus "Samples build test" + + test:push: + desc: Directory agent push test + cmds: + - task: k8s:port-forward:setup + - defer: { task: k8s:port-forward:teardown } + - 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 ./tests -v -failfast -test.v -test.paniconexit0 -ginkgo.timeout 30m -timeout 30m -ginkgo.v -ginkgo.focus "agent push and pull" + + test:list: + desc: Directory agent list test + cmds: + - task: k8s:port-forward:setup + - defer: { task: k8s:port-forward:teardown } + - 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 ./tests -v -failfast -test.v -test.paniconexit0 -ginkgo.timeout 30m -timeout 30m -ginkgo.v -ginkgo.focus "Agntcy agent list tests" + + 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 diff --git a/samples/Taskfile.yml b/samples/Taskfile.yml new file mode 100644 index 0000000..29d0ee6 --- /dev/null +++ b/samples/Taskfile.yml @@ -0,0 +1,40 @@ +# Copyright AGNTCY Contributors (https://github.com/agntcy) +# SPDX-License-Identifier: Apache-2.0 + +--- +version: '3' + +silent: true + +includes: + agents: + taskfile: ./agents/docker-env-cli-stdout/Taskfile.yml + dir: ./agents/docker-env-cli-stdout + autogen: + taskfile: ./autogen/semantic-router/Taskfile.yml + dir: ./autogen/semantic-router + crewai: + taskfile: ./crewai/simple_crew/Taskfile.yml + dir: ./crewai/simple_crew + evaluation: + taskfile: ./evaluation/Taskfile.yml + dir: ./evaluation + langgraph: + taskfile: ./langgraph/research/Taskfile.yml + dir: ./langgraph/research + llama-deploy: + taskfile: ./llama-deploy/llama-sum/Taskfile.yml + dir: ./llama-deploy/llama-sum + llama-index: + taskfile: ./llama-index/research/Taskfile.yml + dir: ./llama-index/research/ + +tasks: + run:test:all: + - task: agents:run:test + - task: autogen:run:test + - task: crewai:run:test + - task: evaluation:run:test + - task: langgraph:run:test + - task: llama-deploy:run:test + - task: llama-index:run:test diff --git a/samples/agents/docker-env-cli-stdout/Taskfile.yaml b/samples/agents/docker-env-cli-stdout/Taskfile.yml similarity index 77% rename from samples/agents/docker-env-cli-stdout/Taskfile.yaml rename to samples/agents/docker-env-cli-stdout/Taskfile.yml index 7d16a6d..2a2293f 100644 --- a/samples/agents/docker-env-cli-stdout/Taskfile.yaml +++ b/samples/agents/docker-env-cli-stdout/Taskfile.yml @@ -9,7 +9,7 @@ silent: true tasks: setup:docker-env-cli-stdout: desc: Create env file - dir: '{{.USER_WORKING_DIR}}' + internal: true status: - test -f .env cmds: @@ -17,21 +17,20 @@ tasks: test:docker-env-cli-stdout: desc: Run docker image - dir: '{{.USER_WORKING_DIR}}' + internal: true cmds: - docker run --env-file .env docker-env-cli-stdout "Hello, World" build: desc: Build images - dir: '{{.USER_WORKING_DIR}}' + internal: true cmds: - docker buildx bake --load run:test: desc: Run test - dir: '{{.USER_WORKING_DIR}}' deps: - setup:docker-env-cli-stdout - build cmds: - - task test:docker-env-cli-stdout + - task: test:docker-env-cli-stdout diff --git a/samples/autogen/Taskfile.yml b/samples/autogen/Taskfile.yml deleted file mode 100644 index a0a76e5..0000000 --- a/samples/autogen/Taskfile.yml +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright AGNTCY Contributors (https://github.com/agntcy) -# SPDX-License-Identifier: Apache-2.0 - ---- -version: '3' - -silent: true - -tasks: - dependencies: - desc: Install dependencies - dir: '{{.USER_WORKING_DIR}}' - cmds: - - poetry sync --no-root - - lint: - desc: Run lint with black - dir: '{{.USER_WORKING_DIR}}' - deps: - - dependencies - cmds: - - poetry run ruff check . - - fix-lint: - desc: Run lint with black - dir: '{{.USER_WORKING_DIR}}' - deps: - - dependencies - cmds: - - poetry run ruff check --fix . - - compose: - desc: 'Run docker-compose' - cmds: - - docker compose up --build -d - - kind: - desc: 'Run app in kind' - dir: '{{.USER_WORKING_DIR}}' - vars: - PARENT_DIR: - sh: basename ${PWD} - cmds: - - docker compose build - - kind create cluster --name {{.PARENT_DIR}} || true - - | - # For each image - images=($(yq '.services | keys | map("{{.PARENT_DIR}}-" + .) | join(" ")' docker-compose.yaml)) - kind load docker-image ${images[@]} --name {{.PARENT_DIR}} - - kubectl --context kind-{{.PARENT_DIR}} apply -k . diff --git a/samples/autogen/semantic-router/Taskfile.yml b/samples/autogen/semantic-router/Taskfile.yml index 7f84db7..a0a35b9 100644 --- a/samples/autogen/semantic-router/Taskfile.yml +++ b/samples/autogen/semantic-router/Taskfile.yml @@ -3,17 +3,51 @@ version: '3' -includes: - lib: - taskfile: ../Taskfile.yml - flatten: true - tasks: + dependencies: + desc: Install dependencies + internal: true + cmds: + - poetry sync --no-root + + lint: + desc: Run lint with black + deps: + - dependencies + cmds: + - poetry run ruff check . + + lint-fix: + desc: Run lint and autofix with black + deps: + - dependencies + cmds: + - poetry run ruff check --fix . + + compose: + desc: 'Run docker-compose' + internal: true + cmds: + - docker compose up --build -d + + kind: + desc: 'Run app in kind' + vars: + PARENT_DIR: + sh: basename ${PWD} + cmds: + - docker compose build + - kind create cluster --name {{.PARENT_DIR}} || true + - | + # For each image + images=($(yq '.services | keys | map("{{.PARENT_DIR}}-" + .) | join(" ")' docker-compose.yaml)) + kind load docker-image ${images[@]} --name {{.PARENT_DIR}} + - kubectl --context kind-{{.PARENT_DIR}} apply -k . + run:test: desc: Run tests deps: - compose - dir: '{{.USER_WORKING_DIR}}' cmds: - poetry sync --no-root - poetry run pytest diff --git a/samples/crewai/simple_crew/Taskfile.yaml b/samples/crewai/simple_crew/Taskfile.yml similarity index 83% rename from samples/crewai/simple_crew/Taskfile.yaml rename to samples/crewai/simple_crew/Taskfile.yml index dedd0c7..630d5ef 100644 --- a/samples/crewai/simple_crew/Taskfile.yaml +++ b/samples/crewai/simple_crew/Taskfile.yml @@ -10,13 +10,11 @@ tasks: dependencies: internal: true desc: Install dependencies - dir: '{{.USER_WORKING_DIR}}' cmds: - poetry install --no-root run:crew: desc: Run crew - dir: '{{.USER_WORKING_DIR}}' deps: - dependencies cmds: @@ -24,7 +22,6 @@ tasks: run:test: desc: Run crew - dir: '{{.USER_WORKING_DIR}}' deps: - dependencies cmds: diff --git a/samples/evaluation/Taskfile.yaml b/samples/evaluation/Taskfile.yml similarity index 78% rename from samples/evaluation/Taskfile.yaml rename to samples/evaluation/Taskfile.yml index b652e02..5ec8365 100644 --- a/samples/evaluation/Taskfile.yaml +++ b/samples/evaluation/Taskfile.yml @@ -10,13 +10,11 @@ tasks: dependencies: internal: true desc: Install dependencies - dir: '{{.USER_WORKING_DIR}}' cmds: - poetry install --no-root run:crew: desc: Run application main - dir: '{{.USER_WORKING_DIR}}' deps: - dependencies cmds: @@ -24,19 +22,15 @@ tasks: run:test-deepeval: internal: true - dir: '{{.USER_WORKING_DIR}}' cmds: - poetry run python -m tests._deepeval run:test-ragas: internal: true - dir: '{{.USER_WORKING_DIR}}' cmds: - poetry run python -m tests._ragas run:test: - desc: Run tests - dir: '{{.USER_WORKING_DIR}}' deps: - dependencies cmds: diff --git a/samples/langgraph/research/Taskfile.yaml b/samples/langgraph/research/Taskfile.yml similarity index 84% rename from samples/langgraph/research/Taskfile.yaml rename to samples/langgraph/research/Taskfile.yml index 4ec1efe..45e0605 100644 --- a/samples/langgraph/research/Taskfile.yaml +++ b/samples/langgraph/research/Taskfile.yml @@ -10,13 +10,11 @@ tasks: dependencies: internal: true desc: Install dependencies - dir: '{{.USER_WORKING_DIR}}' cmds: - poetry install --no-root run:test: desc: Run tests - dir: '{{.USER_WORKING_DIR}}' deps: - dependencies cmds: diff --git a/samples/llama-deploy/llama-sum/Taskfile.yaml b/samples/llama-deploy/llama-sum/Taskfile.yml similarity index 88% rename from samples/llama-deploy/llama-sum/Taskfile.yaml rename to samples/llama-deploy/llama-sum/Taskfile.yml index 56fb0e7..da1bc6f 100644 --- a/samples/llama-deploy/llama-sum/Taskfile.yaml +++ b/samples/llama-deploy/llama-sum/Taskfile.yml @@ -9,13 +9,13 @@ silent: true tasks: dependencies: desc: Install dependencies - dir: '{{.USER_WORKING_DIR}}' + internal: true cmds: - poetry install --no-root stack:up: - desc: Deploy all app components as indipendend processes - dir: '{{.USER_WORKING_DIR}}' + desc: Deploy all app components as independend processes + internal: true deps: - dependencies cmds: @@ -30,13 +30,14 @@ tasks: stack:down: desc: kill all processes run with deploy-processes - dir: '{{.USER_WORKING_DIR}}' + internal: true cmds: - | for pid in $(ps aux | grep llama_sum | grep deploy | awk '{print $2}'); do kill -9 $pid; done build-image: desc: build app image + internal: true cmds: - docker build -t sum --no-cache . @@ -44,6 +45,7 @@ tasks: desc: setup kind deps: - build-image + internal: true vars: PARENT_DIR: sh: basename ${PWD} @@ -54,6 +56,7 @@ tasks: kind:deploy: desc: deploy the application in kind + internal: true deps: - kind:setup cmds: @@ -62,12 +65,14 @@ tasks: kind:port-forward: desc: set port forward + internal: true cmds: - kubectl port-forward svc/control-plane -n llama-deploy-demo 8000:8000 & - sleep 1 kind:delete: desc: remove the application from kind + internal: true cmds: - kubectl delete -f k8s/ || true - kill -9 $(ps aux | grep port-forward | grep control-plane | awk '{print $2}') || true @@ -76,15 +81,15 @@ tasks: run:app: desc: Run application main - dir: '{{.USER_WORKING_DIR}}' deps: - dependencies + - stack:up cmds: - poetry run python -m llama_sum.run + - defer: stack:down run:test: desc: Run tests - dir: '{{.USER_WORKING_DIR}}' deps: - kind:deploy - dependencies @@ -92,3 +97,4 @@ tasks: - sleep 30 - task: kind:port-forward - poetry run python -m tests.test + - defer: kind:delete diff --git a/samples/llama-index/research/Taskfile.yaml b/samples/llama-index/research/Taskfile.yml similarity index 84% rename from samples/llama-index/research/Taskfile.yaml rename to samples/llama-index/research/Taskfile.yml index 4ec1efe..45e0605 100644 --- a/samples/llama-index/research/Taskfile.yaml +++ b/samples/llama-index/research/Taskfile.yml @@ -10,13 +10,11 @@ tasks: dependencies: internal: true desc: Install dependencies - dir: '{{.USER_WORKING_DIR}}' cmds: - poetry install --no-root run:test: desc: Run tests - dir: '{{.USER_WORKING_DIR}}' deps: - dependencies cmds: