Skip to content

Commit 0c2d2fa

Browse files
Rook1exjasinluo
authored andcommitted
docs: 测试workflow (#39)
Co-authored-by: jasinluo <jasinluo@tencent.com>
1 parent 1f28c9f commit 0c2d2fa

12 files changed

Lines changed: 164 additions & 192 deletions

File tree

.github/workflows/ci.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
schedule:
10+
- cron: '0 17 * * *'
11+
workflow_dispatch:
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
16+
17+
permissions:
18+
contents: read
19+
pull-requests: read
20+
21+
jobs:
22+
lint:
23+
runs-on: [self-hosted, trpc-agent-python-ci]
24+
timeout-minutes: 15
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
31+
- name: Get changed Python files
32+
id: changed
33+
run: |
34+
if [ "${{ github.event_name }}" = "pull_request" ]; then
35+
FILES=$(git diff --name-only --diff-filter=ACM origin/${{ github.base_ref }}...HEAD -- '*.py' | grep '^trpc_agent_sdk/' || true)
36+
else
37+
FILES=$(git diff --name-only --diff-filter=ACM HEAD~1...HEAD -- '*.py' | grep '^trpc_agent_sdk/' || true)
38+
fi
39+
if [ -z "$FILES" ]; then
40+
echo "has_files=false" >> "$GITHUB_OUTPUT"
41+
else
42+
echo "has_files=true" >> "$GITHUB_OUTPUT"
43+
echo "$FILES" > "$RUNNER_TEMP/changed_py_files.txt"
44+
echo "Changed Python files:"
45+
echo "$FILES"
46+
fi
47+
48+
- name: Check formatting with YAPF
49+
if: steps.changed.outputs.has_files == 'true'
50+
run: |
51+
FILES=$(cat "$RUNNER_TEMP/changed_py_files.txt" | tr '\n' ' ')
52+
diff_output=$(yapf --diff $FILES) || true
53+
if [ -n "$diff_output" ]; then
54+
echo "$diff_output"
55+
echo "::error::Code formatting check failed for changed files. Run 'yapf -i <file>' to fix."
56+
exit 1
57+
fi
58+
59+
- name: Lint with flake8
60+
if: steps.changed.outputs.has_files == 'true'
61+
run: |
62+
FILES=$(cat "$RUNNER_TEMP/changed_py_files.txt" | tr '\n' ' ')
63+
flake8 $FILES
64+
65+
test:
66+
runs-on: [self-hosted, trpc-agent-python-ci]
67+
timeout-minutes: 20
68+
steps:
69+
- name: Checkout
70+
uses: actions/checkout@v4
71+
72+
- name: Install package and dependencies
73+
run: |
74+
pip install -r requirements-test.txt
75+
76+
- name: Run tests with coverage
77+
# run: pytest --cov=trpc_agent_sdk --cov-report=xml --cov-report=term tests/
78+
run: pytest --cov=trpc_agent_sdk --cov-report=xml --cov-report=term --cov-fail-under=80 tests/
79+
80+
- name: Upload coverage reports to Codecov
81+
uses: codecov/codecov-action@v4
82+
env:
83+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
84+
with:
85+
file: coverage.xml
86+
87+
build:
88+
runs-on: [self-hosted, trpc-agent-python-ci]
89+
timeout-minutes: 15
90+
steps:
91+
- name: Checkout
92+
uses: actions/checkout@v4
93+
94+
- name: Build package
95+
run: |
96+
pip install build
97+
python -m build
98+
99+
- name: Verify package
100+
run: |
101+
pip install dist/*.whl
102+
python -c "import trpc_agent_sdk; print('Import OK')"

.github/workflows/cla.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: "CLA Assistant"
2+
on:
3+
issue_comment:
4+
types: [created]
5+
pull_request_target:
6+
types: [opened, synchronize, reopened]
7+
8+
# explicitly configure permissions, in case your GITHUB_TOKEN workflow permissions are set to read-only in repository settings
9+
permissions:
10+
actions: write
11+
contents: write
12+
pull-requests: write
13+
statuses: write
14+
15+
jobs:
16+
CLAAssistant:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: "CLA Assistant"
20+
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'
21+
uses: contributor-assistant/github-action@v2.3.1
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
PERSONAL_ACCESS_TOKEN: ${{ secrets.CLA_DATABASE_ACCESS_TOKEN }}
25+
with:
26+
remote-organization-name: trpc-group
27+
remote-repository-name: cla-database
28+
path-to-signatures: 'signatures/${{ github.event.repository.name }}-${{ github.repository_id }}/cla.json'
29+
path-to-document: 'https://github.com/trpc-group/cla-database/blob/main/Tencent-Contributor-License-Agreement.md'
30+
# branch should not be protected
31+
branch: 'main'

requirements-test.txt

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,33 @@ tabulate
1414
# Test DB
1515
greenlet
1616
aiosqlite
17+
redis>=6.2.0
18+
langgraph
19+
google-genai>=1.24.0
1720

18-
# Test Optional dependencies
21+
# Test Tools
22+
rapidfuzz>=3.0.0
23+
docker
24+
25+
# Test Langfuse
26+
opentelemetry-sdk<2.0.0,>=1.28.0
27+
opentelemetry-exporter-otlp-proto-http<2.0.0,>=1.28.0
28+
29+
# Test Knowledge
30+
langchain_community>=0.3.27
31+
langchain_huggingface>=0.1.0
32+
sentence-transformers
33+
34+
# Test OpenClaw
35+
nanobot-ai>=0.1.4.post5
36+
wecom-aibot-sdk-python>=0.1.5
37+
38+
# Test Core Dependencies
1939
a2a-sdk>=0.2.0
2040
protobuf>=5.29.5
2141
claude-agent-sdk>=0.1.3
2242
cloudpickle>=2.0.0
2343
ag-ui-protocol>=0.1.8
24-
nanobot-ai>=0.1.4.post5
2544
aiofiles
26-
wecom-aibot-sdk-python>=0.1.5
27-
langchain_community>=0.3.27
28-
langchain_huggingface>=0.1.0
2945
mem0ai>=1.0.3
30-
sentence-transformers
46+
fastapi

tests/server/openclaw/agent/test__agent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def test_returns_agent_with_tools(
109109

110110
mock_llm_agent.assert_called_once()
111111
call_kwargs = mock_llm_agent.call_args
112-
assert call_kwargs[1]["name"] == "trpc-claw-py_worker"
112+
assert call_kwargs[1]["name"] == "trpc_claw_worker"
113113
assert len(call_kwargs[1]["tools"]) == 8
114114
assert result is mock_llm_agent.return_value
115115

@@ -166,7 +166,7 @@ def test_returns_agent_with_tools(
166166

167167
mock_llm_agent.assert_called_once()
168168
call_kwargs = mock_llm_agent.call_args[1]
169-
assert call_kwargs["name"] == "trpc-claw-py"
169+
assert call_kwargs["name"] == "trpc_claw"
170170
assert call_kwargs["sub_agents"] == [worker]
171171
assert call_kwargs["skill_repository"] is mock_skill_ts.repository
172172
assert result is mock_llm_agent.return_value

tests/server/openclaw/config/test__config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
MEMORY_FILE_NAME,
2424
SOUL_FILE_NAME,
2525
TOOL_FILE_NAME,
26-
TRPC_AGENT_CLAW_CONFIG,
26+
TRPC_CLAW_CONFIG,
2727
USER_FILE_NAME,
2828
)
2929

@@ -234,15 +234,15 @@ def test_env_var_path(self, mock_set_config, tmp_path, monkeypatch):
234234
yaml.dump({"agent": {"workspace": str(ws), "api_key": "envkey"}}),
235235
encoding="utf-8",
236236
)
237-
monkeypatch.setenv(TRPC_AGENT_CLAW_CONFIG, str(cfg_path))
237+
monkeypatch.setenv(TRPC_CLAW_CONFIG, str(cfg_path))
238238
cfg = load_config()
239239
assert cfg.model_api_key == "envkey"
240240

241241
@patch("trpc_agent_sdk.server.openclaw.config._config.set_config_path")
242-
@patch("trpc_agent_sdk.server.openclaw.config._config.DEFAULT_TRPC_AGENT_CLAW_DIR")
242+
@patch("trpc_agent_sdk.server.openclaw.config._config.DEFAULT_TRPC_CLAW_DIR")
243243
@patch("trpc_agent_sdk.server.openclaw.config._config.DEFAULT_CONFIG_PATH")
244244
def test_default_path_fallback(self, mock_default_path, mock_default_dir, mock_set_config, tmp_path, monkeypatch):
245-
monkeypatch.delenv(TRPC_AGENT_CLAW_CONFIG, raising=False)
245+
monkeypatch.delenv(TRPC_CLAW_CONFIG, raising=False)
246246
default_dir = tmp_path / ".trpc_agent_claw"
247247
default_dir.mkdir()
248248
mock_default_dir.exists.return_value = True

tests/server/openclaw/test_ui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ def test_root_serves_html(self):
648648
handler = self._get_handler("/")
649649
handler.do_GET()
650650
written = handler.wfile.getvalue().decode("utf-8")
651-
assert "<html>" in written
651+
assert "<html" in written
652652

653653
def test_api_meta(self):
654654
rt = _make_runtime()

tests/test_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111

1212
def test_version():
1313
"""Test the version module."""
14-
assert __version__ == '0.1.0'
14+
assert __version__ == '1.0.0'

0 commit comments

Comments
 (0)