Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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 <file>' 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')"
31 changes: 31 additions & 0 deletions .github/workflows/cla.yml
Original file line number Diff line number Diff line change
@@ -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'
28 changes: 22 additions & 6 deletions requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions tests/server/openclaw/agent/test__agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/server/openclaw/config/test__config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
MEMORY_FILE_NAME,
SOUL_FILE_NAME,
TOOL_FILE_NAME,
TRPC_AGENT_CLAW_CONFIG,
TRPC_CLAW_CONFIG,
USER_FILE_NAME,
)

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/server/openclaw/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<html>" in written
assert "<html" in written

def test_api_meta(self):
rt = _make_runtime()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@

def test_version():
"""Test the version module."""
assert __version__ == '0.1.0'
assert __version__ == '1.0.0'
Loading
Loading