test: Update python-package-conda.yml to enable automated testing of PRs #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Cerebrum-AIOS Integration Test | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Clone AIOS | |
- name: Git Clone AIOS | |
uses: actions/checkout@v4 | |
with: | |
repository: agiresearch/AIOS | |
path: aios_root | |
ref: main | |
# Verify AIOS clone | |
- name: Verify AIOS clone | |
run: | | |
echo "=== AIOS root directory contents ===" | |
ls -la aios_root/ | |
echo "=== Looking for setup files ===" | |
find aios_root/ -name "setup.py" -o -name "pyproject.toml" | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.10" | |
# Install AIOS dependencies | |
- name: Install AIOS dependencies | |
working-directory: aios_root | |
run: | | |
python -m pip install --upgrade pip | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
# Clone Cerebrum into AIOS directory | |
- name: Checkout Cerebrum | |
uses: actions/checkout@v4 | |
with: | |
path: aios_root/Cerebrum | |
ref: ${{ github.ref }} | |
# Install Cerebrum | |
- name: Install Cerebrum | |
run: | | |
python -m pip install -e aios_root/Cerebrum/ | |
# Run AIOS kernel | |
- name: Run AIOS kernel in background | |
env: | |
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY || 'AIzaSyCx0VNhObFu0ta95xDfBx4IKJuyiPTXqbQ' }} | |
run: | | |
# Check if using default test key | |
if [ "$GEMINI_API_KEY" = "AIzaSyCx0VNhObFu0ta95xDfBx4IKJuyiPTXqbQ" ]; then | |
echo "Notice: Using test API key - For testing purposes only" | |
fi | |
cd aios_root | |
bash runtime/launch_kernel.sh &>../kernel.log & | |
KERNEL_PID=$! | |
cd .. | |
# Set maximum wait time (10 seconds) | |
max_wait=10 | |
start_time=$SECONDS | |
# Dynamically check if the process is running until it succeeds or times out | |
while true; do | |
if ! ps -p $KERNEL_PID > /dev/null; then | |
echo "Kernel process died. Checking logs:" | |
cat kernel.log | |
exit 1 | |
fi | |
if nc -z localhost 8000; then | |
if curl -s http://localhost:8000/health; then | |
echo "Kernel successfully started and healthy" | |
break | |
fi | |
fi | |
# Check if timed out | |
elapsed=$((SECONDS - start_time)) | |
if [ $elapsed -ge $max_wait ]; then | |
echo "Timeout after ${max_wait} seconds. Kernel failed to start properly." | |
cat kernel.log | |
exit 1 | |
fi | |
echo "Waiting for kernel to start... (${elapsed}s elapsed)" | |
sleep 1 | |
done | |
# Run integration test | |
- name: Run integration test | |
env: | |
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY || 'AIzaSyCx0VNhObFu0ta95xDfBx4IKJuyiPTXqbQ' }} | |
run: | | |
# Check if using default test key | |
if [ "$GEMINI_API_KEY" = "AIzaSyCx0VNhObFu0ta95xDfBx4IKJuyiPTXqbQ" ]; then | |
echo "Notice: Using test API key - For testing purposes only" | |
fi | |
# Debug information | |
echo "Checking kernel status..." | |
curl -v http://localhost:8000/health || true | |
echo "Network status:" | |
netstat -tlpn | grep 8000 || true | |
# Run the test | |
run-agent \ | |
--llm_name gemini-1.5-flash \ | |
--llm_backend google \ | |
--agent_name_or_path demo_author/demo_agent \ | |
--task "Tell me what is core idea of AIOS" \ | |
--aios_kernel_url http://localhost:8000 \ | |
2>&1 | tee agent.log | |
# Check for error patterns | |
if grep -q "Failed to initialize client: 500 Server Error" agent.log; then | |
echo "Error: LLM initialization failed. Please check your API key configuration." | |
exit 1 | |
fi | |
# Check if completed successfully | |
if ! grep -q "Final Result:" agent.log; then | |
echo "Error: Agent did not complete successfully" | |
exit 1 | |
fi | |
# Upload logs | |
- name: Upload logs | |
if: always() | |
uses: actions/upload-artifact@v4.4.3 | |
with: | |
name: test-logs | |
path: | | |
kernel.log | |
agent.log | |
# Debug information | |
- name: Debug information | |
if: failure() | |
run: | | |
echo "=== Kernel log ===" | |
cat kernel.log | |
echo "=== Environment variables ===" | |
env | grep -i api_key || true | |
echo "=== Process status ===" | |
ps aux | grep kernel | |
echo "=== Directory structure ===" | |
tree aios_main || true |