Refactor testing structure and update Makefile for clarity
- Rename test folders and commands in the Makefile for consistency, changing references from AI to Agent tests. - Update GitHub Actions workflows to reflect the new naming conventions for agent and robot tests, ensuring clarity in CI processes. - Modify test cases to improve readability and maintainability, including renaming test functions for better understanding of their purpose. - Enhance comments in the Makefile and workflows to provide clearer context on the testing processes and requirements.
This commit is contained in:
parent
bc4787f857
commit
67ab9350e8
4 changed files with 39 additions and 40 deletions
28
.github/workflows/pr-test.yml
vendored
28
.github/workflows/pr-test.yml
vendored
|
|
@ -361,9 +361,9 @@ jobs:
|
||||||
});
|
});
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# AI Tests (agent, aigc) - Run once with SQLite
|
# Agent Tests (agent, aigc) - Run once with SQLite
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
AITest:
|
AgentTest:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
qdrant:
|
qdrant:
|
||||||
|
|
@ -448,7 +448,7 @@ jobs:
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
issue_number: issue_number,
|
issue_number: issue_number,
|
||||||
body: '🤖 AI Tests (agent, aigc) running with SQLite...'
|
body: '🤖 Agent Tests (agent, aigc) running with SQLite...'
|
||||||
});
|
});
|
||||||
|
|
||||||
- name: Checkout Kun
|
- name: Checkout Kun
|
||||||
|
|
@ -550,20 +550,20 @@ jobs:
|
||||||
docker pull yaoapp/sandbox-base:latest || true
|
docker pull yaoapp/sandbox-base:latest || true
|
||||||
docker pull yaoapp/sandbox-claude:latest || true
|
docker pull yaoapp/sandbox-claude:latest || true
|
||||||
|
|
||||||
- name: Run AI Tests (agent, aigc)
|
- name: Run Agent Tests (agent, aigc)
|
||||||
env:
|
env:
|
||||||
YAO_SANDBOX_WORKSPACE: ${{ runner.temp }}/sandbox/workspace
|
YAO_SANDBOX_WORKSPACE: ${{ runner.temp }}/sandbox/workspace
|
||||||
YAO_SANDBOX_IPC: ${{ runner.temp }}/sandbox/ipc
|
YAO_SANDBOX_IPC: ${{ runner.temp }}/sandbox/ipc
|
||||||
run: |
|
run: |
|
||||||
export YAO_SANDBOX_CONTAINER_USER="$(id -u):$(id -g)"
|
export YAO_SANDBOX_CONTAINER_USER="$(id -u):$(id -g)"
|
||||||
make unit-test-ai
|
make unit-test-agent
|
||||||
|
|
||||||
- name: Codecov Report
|
- name: Codecov Report
|
||||||
uses: codecov/codecov-action@v4
|
uses: codecov/codecov-action@v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|
||||||
- name: "Comment on PR - AI Tests Done"
|
- name: "Comment on PR - Agent Tests Done"
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
@ -574,13 +574,13 @@ jobs:
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
issue_number: issue_number,
|
issue_number: issue_number,
|
||||||
body: '✅ AI Tests (agent, aigc) passed!'
|
body: '✅ Agent Tests (agent, aigc) passed!'
|
||||||
});
|
});
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Robot E2E Tests (agent/robot/api) - Run TestE2E* with real LLM calls
|
# Robot Tests (all agent/robot/... packages) - Unit + E2E with real LLM calls
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
RobotE2ETest:
|
RobotTest:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
mcp-everything:
|
mcp-everything:
|
||||||
|
|
@ -645,7 +645,7 @@ jobs:
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
issue_number: issue_number,
|
issue_number: issue_number,
|
||||||
body: '🤖 Robot E2E Tests running with SQLite...'
|
body: '🤖 Robot Tests (Unit + E2E) running with SQLite...'
|
||||||
});
|
});
|
||||||
|
|
||||||
- name: Checkout Kun
|
- name: Checkout Kun
|
||||||
|
|
@ -725,15 +725,15 @@ jobs:
|
||||||
echo "YAO_DB_DRIVER=sqlite3" >> $GITHUB_ENV
|
echo "YAO_DB_DRIVER=sqlite3" >> $GITHUB_ENV
|
||||||
echo "YAO_DB_PRIMARY=${{ github.WORKSPACE }}/../app/db/yao.db" >> $GITHUB_ENV
|
echo "YAO_DB_PRIMARY=${{ github.WORKSPACE }}/../app/db/yao.db" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Run Robot E2E Tests
|
- name: Run Robot Tests (Unit + E2E)
|
||||||
run: make unit-test-robot-e2e
|
run: make unit-test-robot
|
||||||
|
|
||||||
- name: Codecov Report
|
- name: Codecov Report
|
||||||
uses: codecov/codecov-action@v4
|
uses: codecov/codecov-action@v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|
||||||
- name: "Comment on PR - Robot E2E Tests Done"
|
- name: "Comment on PR - Robot Tests Done"
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
@ -744,7 +744,7 @@ jobs:
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
issue_number: issue_number,
|
issue_number: issue_number,
|
||||||
body: '✅ Robot E2E Tests passed!'
|
body: '✅ Robot Tests (Unit + E2E) passed!'
|
||||||
});
|
});
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
|
||||||
16
.github/workflows/unit-test.yml
vendored
16
.github/workflows/unit-test.yml
vendored
|
|
@ -303,9 +303,9 @@ jobs:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# AI Tests (agent, aigc) - Run once with SQLite
|
# Agent Tests (agent, aigc) - Run once with SQLite
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
ai-test:
|
agent-test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
qdrant:
|
qdrant:
|
||||||
|
|
@ -444,13 +444,13 @@ jobs:
|
||||||
docker pull yaoapp/sandbox-base:latest || true
|
docker pull yaoapp/sandbox-base:latest || true
|
||||||
docker pull yaoapp/sandbox-claude:latest || true
|
docker pull yaoapp/sandbox-claude:latest || true
|
||||||
|
|
||||||
- name: Run AI Tests (agent, aigc)
|
- name: Run Agent Tests (agent, aigc)
|
||||||
env:
|
env:
|
||||||
YAO_SANDBOX_WORKSPACE: ${{ runner.temp }}/sandbox/workspace
|
YAO_SANDBOX_WORKSPACE: ${{ runner.temp }}/sandbox/workspace
|
||||||
YAO_SANDBOX_IPC: ${{ runner.temp }}/sandbox/ipc
|
YAO_SANDBOX_IPC: ${{ runner.temp }}/sandbox/ipc
|
||||||
run: |
|
run: |
|
||||||
export YAO_SANDBOX_CONTAINER_USER="$(id -u):$(id -g)"
|
export YAO_SANDBOX_CONTAINER_USER="$(id -u):$(id -g)"
|
||||||
make unit-test-ai
|
make unit-test-agent
|
||||||
|
|
||||||
- name: Codecov Report
|
- name: Codecov Report
|
||||||
uses: codecov/codecov-action@v4
|
uses: codecov/codecov-action@v4
|
||||||
|
|
@ -458,9 +458,9 @@ jobs:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Robot E2E Tests (agent/robot/api) - Run TestE2E* with real LLM calls
|
# Robot Tests (all agent/robot/... packages) - Unit + E2E with real LLM calls
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
robot-e2e-test:
|
robot-test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
mcp-everything:
|
mcp-everything:
|
||||||
|
|
@ -557,8 +557,8 @@ jobs:
|
||||||
echo "YAO_DB_DRIVER=sqlite3" >> $GITHUB_ENV
|
echo "YAO_DB_DRIVER=sqlite3" >> $GITHUB_ENV
|
||||||
echo "YAO_DB_PRIMARY=${{ github.WORKSPACE }}/../app/db/yao.db" >> $GITHUB_ENV
|
echo "YAO_DB_PRIMARY=${{ github.WORKSPACE }}/../app/db/yao.db" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Run Robot E2E Tests
|
- name: Run Robot Tests (Unit + E2E)
|
||||||
run: make unit-test-robot-e2e
|
run: make unit-test-robot
|
||||||
|
|
||||||
- name: Codecov Report
|
- name: Codecov Report
|
||||||
uses: codecov/codecov-action@v4
|
uses: codecov/codecov-action@v4
|
||||||
|
|
|
||||||
28
Makefile
28
Makefile
|
|
@ -13,12 +13,12 @@ OS := $(shell uname)
|
||||||
TESTFOLDER := $(shell $(GO) list ./... | grep -vE 'examples|openai|aigc|neo|twilio|share*' | awk '!/\/tests\// || /openapi\/tests/')
|
TESTFOLDER := $(shell $(GO) list ./... | grep -vE 'examples|openai|aigc|neo|twilio|share*' | awk '!/\/tests\// || /openapi\/tests/')
|
||||||
# Core tests (exclude AI-related: agent, aigc, openai, KB, and sandbox which requires Docker)
|
# Core tests (exclude AI-related: agent, aigc, openai, KB, and sandbox which requires Docker)
|
||||||
TESTFOLDER_CORE := $(shell $(GO) list ./... | grep -vE 'examples|openai|aigc|neo|twilio|share*|agent|kb|sandbox' | awk '!/\/tests\// || /openapi\/tests/')
|
TESTFOLDER_CORE := $(shell $(GO) list ./... | grep -vE 'examples|openai|aigc|neo|twilio|share*|agent|kb|sandbox' | awk '!/\/tests\// || /openapi\/tests/')
|
||||||
# AI tests (agent, aigc) - exclude agent/search/handlers/web (requires external API keys) and robot/api E2E tests
|
# Agent tests (agent, aigc) - exclude agent/search/handlers/web (requires external API keys) and robot packages (tested in robot job)
|
||||||
TESTFOLDER_AI := $(shell $(GO) list ./agent/... ./aigc/... | grep -v 'agent/search/handlers/web')
|
TESTFOLDER_AGENT := $(shell $(GO) list ./agent/... ./aigc/... | grep -vE 'agent/search/handlers/web|agent/robot/')
|
||||||
# KB tests (kb)
|
# KB tests (kb)
|
||||||
TESTFOLDER_KB := $(shell $(GO) list ./kb/...)
|
TESTFOLDER_KB := $(shell $(GO) list ./kb/...)
|
||||||
# Robot E2E tests (agent/robot/api) - runs TestE2E* tests with real LLM calls
|
# Robot tests (all agent/robot/... packages) - runs ALL tests (unit + E2E) with real LLM calls
|
||||||
TESTFOLDER_ROBOT_E2E := $(shell $(GO) list ./agent/robot/api/...)
|
TESTFOLDER_ROBOT := $(shell $(GO) list ./agent/robot/...)
|
||||||
# Sandbox tests (requires Docker)
|
# Sandbox tests (requires Docker)
|
||||||
TESTFOLDER_SANDBOX := $(shell $(GO) list ./sandbox/...)
|
TESTFOLDER_SANDBOX := $(shell $(GO) list ./sandbox/...)
|
||||||
TESTTAGS ?= ""
|
TESTTAGS ?= ""
|
||||||
|
|
@ -77,12 +77,12 @@ unit-test-core:
|
||||||
fi; \
|
fi; \
|
||||||
done
|
done
|
||||||
|
|
||||||
# AI Unit Test (agent, aigc) - excludes TestE2E* (run separately in unit-test-robot-e2e)
|
# Agent Unit Test (agent, aigc) - excludes robot packages (tested in unit-test-robot) and TestE2E*
|
||||||
.PHONY: unit-test-ai
|
.PHONY: unit-test-agent
|
||||||
unit-test-ai:
|
unit-test-agent:
|
||||||
echo "mode: count" > coverage.out
|
echo "mode: count" > coverage.out
|
||||||
for d in $(TESTFOLDER_AI); do \
|
for d in $(TESTFOLDER_AGENT); do \
|
||||||
$(GO) test -tags $(TESTTAGS) -v -timeout=20m -covermode=count -coverprofile=profile.out -coverpkg=$$(echo $$d | sed "s/\/test$$//g") -skip='TestMemoryLeak|TestIsolateDisposal|TestE2E' $$d > tmp.out; \
|
$(GO) test -tags $(TESTTAGS) -v -timeout=50m -covermode=count -coverprofile=profile.out -coverpkg=$$(echo $$d | sed "s/\/test$$//g") -skip='TestMemoryLeak|TestIsolateDisposal|TestE2E' $$d > tmp.out; \
|
||||||
cat tmp.out; \
|
cat tmp.out; \
|
||||||
if grep -q "^--- FAIL" tmp.out; then \
|
if grep -q "^--- FAIL" tmp.out; then \
|
||||||
rm tmp.out; \
|
rm tmp.out; \
|
||||||
|
|
@ -141,13 +141,13 @@ unit-test-kb:
|
||||||
fi; \
|
fi; \
|
||||||
done
|
done
|
||||||
|
|
||||||
# Robot E2E Test (agent/robot/api) - runs TestE2E* tests with real LLM calls
|
# Robot Test (all agent/robot/... packages) - runs ALL tests (unit + E2E) with real LLM calls
|
||||||
# These tests require: LLM API keys, database, and longer timeout
|
# These tests require: LLM API keys, database, and longer timeout
|
||||||
.PHONY: unit-test-robot-e2e
|
.PHONY: unit-test-robot
|
||||||
unit-test-robot-e2e:
|
unit-test-robot:
|
||||||
echo "mode: count" > coverage.out
|
echo "mode: count" > coverage.out
|
||||||
for d in $(TESTFOLDER_ROBOT_E2E); do \
|
for d in $(TESTFOLDER_ROBOT); do \
|
||||||
$(GO) test -tags $(TESTTAGS) -v -timeout=30m -covermode=count -coverprofile=profile.out -coverpkg=$$(echo $$d | sed "s/\/test$$//g") -run='TestE2E' $$d > tmp.out; \
|
$(GO) test -tags $(TESTTAGS) -v -timeout=50m -covermode=count -coverprofile=profile.out -coverpkg=$$(echo $$d | sed "s/\/test$$//g") -skip='TestMemoryLeak|TestIsolateDisposal' $$d > tmp.out; \
|
||||||
cat tmp.out; \
|
cat tmp.out; \
|
||||||
if grep -q "^--- FAIL" tmp.out; then \
|
if grep -q "^--- FAIL" tmp.out; then \
|
||||||
rm tmp.out; \
|
rm tmp.out; \
|
||||||
|
|
|
||||||
|
|
@ -78,13 +78,12 @@ func TestDetectNeedMoreInfo(t *testing.T) {
|
||||||
assert.Empty(t, question)
|
assert.Empty(t, question)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("handles nested data structure in Next", func(t *testing.T) {
|
t.Run("unwraps data envelope from Next hook", func(t *testing.T) {
|
||||||
result := &CallResult{
|
result := &CallResult{
|
||||||
Next: map[string]interface{}{
|
Next: map[string]interface{}{
|
||||||
|
"data": map[string]interface{}{
|
||||||
"status": "need_input",
|
"status": "need_input",
|
||||||
"question": "Which database should I query?",
|
"question": "Which database should I query?",
|
||||||
"data": map[string]interface{}{
|
|
||||||
"options": []interface{}{"db1", "db2"},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue