From 60e267f9424b779281f3becf4b133b90e4cfaf23 Mon Sep 17 00:00:00 2001 From: jasinluo Date: Wed, 8 Apr 2026 17:51:38 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=B5=8B=E8=AF=95workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 102 +++++++++++ .github/workflows/cla.yml | 31 ++++ requirements-test.txt | 28 ++- tests/server/openclaw/agent/test__agent.py | 4 +- tests/server/openclaw/config/test__config.py | 8 +- tests/server/openclaw/test_ui.py | 2 +- tests/test_version.py | 2 +- tests/utils/test_address_info.py | 173 ------------------ trpc_agent_sdk/knowledge/_knowledge.py | 1 + trpc_agent_sdk/server/openclaw/_cli.py | 2 - .../server/openclaw/agent/_agent.py | 2 - .../server/openclaw/skill/_utils.py | 1 - 12 files changed, 164 insertions(+), 192 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/cla.yml delete mode 100644 tests/utils/test_address_info.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c8fcd6e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,102 @@ +name: CI +on: + push: + branches: + - main + pull_request: + branches: + - main + schedule: + - cron: '0 17 * * *' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +permissions: + contents: read + pull-requests: read + +jobs: + lint: + runs-on: [self-hosted, trpc-agent-python-ci] + timeout-minutes: 15 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get changed Python files + id: changed + run: | + if [ "${{ github.event_name }}" = "pull_request" ]; then + FILES=$(git diff --name-only --diff-filter=ACM origin/${{ github.base_ref }}...HEAD -- '*.py' | grep '^trpc_agent_sdk/' || true) + else + FILES=$(git diff --name-only --diff-filter=ACM HEAD~1...HEAD -- '*.py' | grep '^trpc_agent_sdk/' || true) + fi + if [ -z "$FILES" ]; then + echo "has_files=false" >> "$GITHUB_OUTPUT" + else + echo "has_files=true" >> "$GITHUB_OUTPUT" + echo "$FILES" > "$RUNNER_TEMP/changed_py_files.txt" + echo "Changed Python files:" + echo "$FILES" + fi + + - name: Check formatting with YAPF + if: steps.changed.outputs.has_files == 'true' + run: | + FILES=$(cat "$RUNNER_TEMP/changed_py_files.txt" | tr '\n' ' ') + diff_output=$(yapf --diff $FILES) || true + if [ -n "$diff_output" ]; then + echo "$diff_output" + echo "::error::Code formatting check failed for changed files. Run 'yapf -i ' to fix." + exit 1 + fi + + - name: Lint with flake8 + if: steps.changed.outputs.has_files == 'true' + run: | + FILES=$(cat "$RUNNER_TEMP/changed_py_files.txt" | tr '\n' ' ') + flake8 $FILES + + test: + runs-on: [self-hosted, trpc-agent-python-ci] + timeout-minutes: 20 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install package and dependencies + run: | + pip install -r requirements-test.txt + + - name: Run tests with coverage + # run: pytest --cov=trpc_agent_sdk --cov-report=xml --cov-report=term tests/ + run: pytest --cov=trpc_agent_sdk --cov-report=xml --cov-report=term --cov-fail-under=80 tests/ + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + file: coverage.xml + + build: + runs-on: [self-hosted, trpc-agent-python-ci] + timeout-minutes: 15 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build package + run: | + pip install build + python -m build + + - name: Verify package + run: | + pip install dist/*.whl + python -c "import trpc_agent_sdk; print('Import OK')" diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml new file mode 100644 index 0000000..9b611a1 --- /dev/null +++ b/.github/workflows/cla.yml @@ -0,0 +1,31 @@ +name: "CLA Assistant" +on: + issue_comment: + types: [created] + pull_request_target: + types: [opened, synchronize, reopened] + +# explicitly configure permissions, in case your GITHUB_TOKEN workflow permissions are set to read-only in repository settings +permissions: + actions: write + contents: write + pull-requests: write + statuses: write + +jobs: + CLAAssistant: + runs-on: ubuntu-latest + steps: + - name: "CLA Assistant" + if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target' + uses: contributor-assistant/github-action@v2.3.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PERSONAL_ACCESS_TOKEN: ${{ secrets.CLA_DATABASE_ACCESS_TOKEN }} + with: + remote-organization-name: trpc-group + remote-repository-name: cla-database + path-to-signatures: 'signatures/${{ github.event.repository.name }}-${{ github.repository_id }}/cla.json' + path-to-document: 'https://github.com/trpc-group/cla-database/blob/main/Tencent-Contributor-License-Agreement.md' + # branch should not be protected + branch: 'main' diff --git a/requirements-test.txt b/requirements-test.txt index 15f84ba..f3b42ee 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -14,17 +14,33 @@ tabulate # Test DB greenlet aiosqlite +redis>=6.2.0 +langgraph +google-genai>=1.24.0 -# Test Optional dependencies +# Test Tools +rapidfuzz>=3.0.0 +docker + +# Test Langfuse +opentelemetry-sdk<2.0.0,>=1.28.0 +opentelemetry-exporter-otlp-proto-http<2.0.0,>=1.28.0 + +# Test Knowledge +langchain_community>=0.3.27 +langchain_huggingface>=0.1.0 +sentence-transformers + +# Test OpenClaw +nanobot-ai>=0.1.4.post5 +wecom-aibot-sdk-python>=0.1.5 + +# Test Core Dependencies a2a-sdk>=0.2.0 protobuf>=5.29.5 claude-agent-sdk>=0.1.3 cloudpickle>=2.0.0 ag-ui-protocol>=0.1.8 -nanobot-ai>=0.1.4.post5 aiofiles -wecom-aibot-sdk-python>=0.1.5 -langchain_community>=0.3.27 -langchain_huggingface>=0.1.0 mem0ai>=1.0.3 -sentence-transformers +fastapi diff --git a/tests/server/openclaw/agent/test__agent.py b/tests/server/openclaw/agent/test__agent.py index 2f5dc7e..ceae3c0 100644 --- a/tests/server/openclaw/agent/test__agent.py +++ b/tests/server/openclaw/agent/test__agent.py @@ -109,7 +109,7 @@ def test_returns_agent_with_tools( mock_llm_agent.assert_called_once() call_kwargs = mock_llm_agent.call_args - assert call_kwargs[1]["name"] == "trpc-claw-py_worker" + assert call_kwargs[1]["name"] == "trpc_claw_worker" assert len(call_kwargs[1]["tools"]) == 8 assert result is mock_llm_agent.return_value @@ -166,7 +166,7 @@ def test_returns_agent_with_tools( mock_llm_agent.assert_called_once() call_kwargs = mock_llm_agent.call_args[1] - assert call_kwargs["name"] == "trpc-claw-py" + assert call_kwargs["name"] == "trpc_claw" assert call_kwargs["sub_agents"] == [worker] assert call_kwargs["skill_repository"] is mock_skill_ts.repository assert result is mock_llm_agent.return_value diff --git a/tests/server/openclaw/config/test__config.py b/tests/server/openclaw/config/test__config.py index 5fa38d8..88537e3 100644 --- a/tests/server/openclaw/config/test__config.py +++ b/tests/server/openclaw/config/test__config.py @@ -23,7 +23,7 @@ MEMORY_FILE_NAME, SOUL_FILE_NAME, TOOL_FILE_NAME, - TRPC_AGENT_CLAW_CONFIG, + TRPC_CLAW_CONFIG, USER_FILE_NAME, ) @@ -234,15 +234,15 @@ def test_env_var_path(self, mock_set_config, tmp_path, monkeypatch): yaml.dump({"agent": {"workspace": str(ws), "api_key": "envkey"}}), encoding="utf-8", ) - monkeypatch.setenv(TRPC_AGENT_CLAW_CONFIG, str(cfg_path)) + monkeypatch.setenv(TRPC_CLAW_CONFIG, str(cfg_path)) cfg = load_config() assert cfg.model_api_key == "envkey" @patch("trpc_agent_sdk.server.openclaw.config._config.set_config_path") - @patch("trpc_agent_sdk.server.openclaw.config._config.DEFAULT_TRPC_AGENT_CLAW_DIR") + @patch("trpc_agent_sdk.server.openclaw.config._config.DEFAULT_TRPC_CLAW_DIR") @patch("trpc_agent_sdk.server.openclaw.config._config.DEFAULT_CONFIG_PATH") def test_default_path_fallback(self, mock_default_path, mock_default_dir, mock_set_config, tmp_path, monkeypatch): - monkeypatch.delenv(TRPC_AGENT_CLAW_CONFIG, raising=False) + monkeypatch.delenv(TRPC_CLAW_CONFIG, raising=False) default_dir = tmp_path / ".trpc_agent_claw" default_dir.mkdir() mock_default_dir.exists.return_value = True diff --git a/tests/server/openclaw/test_ui.py b/tests/server/openclaw/test_ui.py index 34ea8f7..5fc866a 100644 --- a/tests/server/openclaw/test_ui.py +++ b/tests/server/openclaw/test_ui.py @@ -648,7 +648,7 @@ def test_root_serves_html(self): handler = self._get_handler("/") handler.do_GET() written = handler.wfile.getvalue().decode("utf-8") - assert "" in written + assert " LLMModel: return model - - def create_worker_agent( config: ClawConfig, model: LLMModel, diff --git a/trpc_agent_sdk/server/openclaw/skill/_utils.py b/trpc_agent_sdk/server/openclaw/skill/_utils.py index 00dbf8d..5435f87 100644 --- a/trpc_agent_sdk/server/openclaw/skill/_utils.py +++ b/trpc_agent_sdk/server/openclaw/skill/_utils.py @@ -3,7 +3,6 @@ # Copyright (C) 2026 Tencent. All rights reserved. # # tRPC-Agent-Python is licensed under Apache-2.0. - """Utils for trpc_claw skill.""" import re