Skip to content
Open
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
80 changes: 80 additions & 0 deletions .github/workflows/codebuddy-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Copyright (c) 2026 Tencent Inc.
# SPDX-License-Identifier: Apache-2.0

name: codebuddy-integration

on:
pull_request:
paths:
- "examples/codebuddy-integration/**"
- "docs/**/integrations/codebuddy.md"
- ".github/workflows/codebuddy-integration.yml"
push:
branches: [master]

jobs:
static:
name: Static checks (compile + unit tests)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
working-directory: examples/codebuddy-integration
run: pip install -r requirements.txt

- name: Compile host driver scripts
working-directory: examples/codebuddy-integration
run: |
python3 -m py_compile env_utils.py _codebuddy_common.py \
run_codebuddy.py resume_codebuddy.py network_policy.py

- name: Run unit tests
working-directory: examples/codebuddy-integration
run: python3 -m pytest tests/ -v

- name: Smoke-check --help output
working-directory: examples/codebuddy-integration
run: |
python3 run_codebuddy.py --help
python3 resume_codebuddy.py --help
Comment thread
pei-pei45 marked this conversation as resolved.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical: CI test discovery silently skips 3 out of 4 test files

The CI uses python3 -m unittest discover which only discovers classes inheriting from unittest.TestCase. Three of the four test files use pytest-style classes (plain object base, bare assert, pytest fixtures) — they are silently skipped with no error or warning:

File Inherits TestCase? Discovered by unittest?
test_env_utils.py ✅ Yes ✅ Yes
test_codebuddy_common.py ❌ No (pytest-style, bare assert) Silently skipped
test_mcp_server.py ❌ No (pytest-style, free functions) Silently skipped
test_sandbox_exec.py ❌ No (pytest-style, bare assert) Silently skipped

Only ~752 lines of test_env_utils.py would run; ~948 lines in the other 3 files are dropped. A developer who checks CI after merging would see a green checkmark but nowhere near the advertised 166-test coverage.

Fix: Change to python3 -m pytest tests/ -v (and add pytest to a requirements file or install step), or convert the pytest-style classes to unittest.TestCase subclasses.

python3 network_policy.py --help

dockerfile:
name: Dockerfile builds cleanly
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Buildx
uses: docker/setup-buildx-action@v3

- name: Build (cache miss is fine; --load is just for smoke)
uses: docker/build-push-action@v6
with:
context: examples/codebuddy-integration
push: false
load: true
tags: codebuddy-cube:ci
cache-from: type=gha
cache-to: type=gha,mode=max

- name: codebuddy --version inside the image
run: |
cid=$(docker run -d --rm codebuddy-cube:ci)
docker exec "$cid" codebuddy --version
# envd /health reachable means the readiness probe will succeed;
# add a retry loop because envd may still be booting on cold cache.
for i in $(seq 30); do
if docker exec "$cid" curl -fsS -o /dev/null \
http://127.0.0.1:49983/health; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential orphan container on exec failure

If docker exec "$cid" codebuddy --version (or any later docker exec) returns a non-zero exit, the shell exits before reaching docker rm -f "$cid" on line 86. The --rm flag only removes the container after its main process exits, which won't happen for a daemon. Container stays alive until the runner reaps it.

Consider adding a trap at the top of this run: block:

cid=""
cleanup() { [ -n "$cid" ] && docker rm -f "$cid" 2>/dev/null || true; }
trap cleanup EXIT
cid=$(docker run -d --rm codebuddy-cube:ci)

This guarantees cleanup regardless of which command fails.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This job runs on GitHub-hosted ubuntu-latest runners, which are fully ephemeral — the VM is destroyed once the job finishes, so an orphaned container here doesn't persist or accumulate across runs. Since this is the only container operation in the static job, I'll leave it as-is for now, but agree the trap pattern would be worth adding if this ever moves to a self-hosted runner or if more container steps are added to this job later.

break
fi
sleep 1
done
docker rm -f "$cid"
Loading
Loading