diff --git a/.github/workflows/cli_test.yaml b/.github/workflows/cli_test.yaml new file mode 100644 index 0000000..22efbf9 --- /dev/null +++ b/.github/workflows/cli_test.yaml @@ -0,0 +1,69 @@ +name: Build and Test KubeAGI CLI Server + +on: + pull_request: + branches: [main] + workflow_dispatch: + +env: + PYTHON_INDEX_URL: https://pypi.org/simple + PACKAGE_REGISTRY: deb.debian.org + + +jobs: + build-and-test: + runs-on: ubuntu-latest + steps: + - name: Maximize build space + uses: easimon/maximize-build-space@master + with: + overprovision-lvm: true + remove-dotnet: 'true' + remove-android: 'true' + remove-haskell: 'true' + remove-codeql: 'true' + remove-docker-images: 'true' + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + buildkitd-flags: --debug + config-inline: | + [worker.oci] + max-parallelism = 1 + + - name: Set up GCC + uses: egor-tensin/setup-gcc@v1 + with: + version: latest + platform: x64 + - name: Build core library cli image + id: build-worker + uses: docker/build-push-action@v5 + with: + context: . + file: docker/Dockerfile + load: true + push: false + tags: test-image + build-args: | + PACKAGE_REGISTRY=${{ env.PACKAGE_REGISTRY }} + PYTHON_INDEX_URL=${{ env.PYTHON_INDEX_URL }} + - name: Run Docker Container + run: | + docker run -d --name cli-container test-image + docker ps + - name: Run test script + run: | + docker logs cli-container + docker cp tests/example_test.sh cli-container:/tmp/example_test.sh + docker exec cli-container bash /tmp/example_test.sh + - name: Stop and Remove Container + if: always() + run: | + docker stop cli-container + docker rm cli-container \ No newline at end of file diff --git a/.github/workflows/image_build_test.yml b/.github/workflows/image_build_test.yml index 688fefa..1a695fc 100644 --- a/.github/workflows/image_build_test.yml +++ b/.github/workflows/image_build_test.yml @@ -12,6 +12,15 @@ jobs: test_image_build: runs-on: ubuntu-latest steps: + - name: Maximize build space + uses: easimon/maximize-build-space@master + with: + overprovision-lvm: true + remove-dotnet: 'true' + remove-android: 'true' + remove-haskell: 'true' + remove-codeql: 'true' + remove-docker-images: 'true' - uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/tests/example_test.sh b/tests/example_test.sh new file mode 100644 index 0000000..9e0a462 --- /dev/null +++ b/tests/example_test.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +# Install curl +apt-get install -y curl + +# Test GET /api/v1/health +echo "---------------------------------------" +echo "Sleeping for 20 seconds..." +sleep 20 + +echo "Testing GET /api/v1/health" +response=$(curl -s -X GET http://localhost:8000/api/v1/health) +expected='{"Health":true}' + +if [ "$response" = "$expected" ]; then + echo "GET /api/v1/health passed" +else + echo "GET /api/v1/health failed. Expected $expected, got $response" + exit 1 +fi + +echo "---------------------------------------" + +# Test POST /api/v1/reranking +echo "Testing POST /api/v1/reranking" +data='{"question": "How are you today?", "answers": ["I am fine now, thank you.", "I was doing my business."]}' +response=$(curl -s -X POST -H "Content-Type: application/json" -H 'accept: application/json' -d "$data" http://localhost:8000/api/v1/reranking) + +if [ -z "$response" ]; then + echo "POST /api/v1/reranking failed to get a response" + exit 1 +else + echo "Reranking results: $response" +fi + +echo "All tests passed" \ No newline at end of file