Skip to content

rebrand: PostHog→Insights in MCP analytics #324

rebrand: PostHog→Insights in MCP analytics

rebrand: PostHog→Insights in MCP analytics #324

name: Hanzo Packages CI
on:
push:
branches:
- main
paths:
- 'pkg/hanzo/**'
- 'pkg/hanzo-network/**'
- 'pkg/hanzo-mcp/**'
# hanzo-agent is now a git submodule - not tested here
- 'pkg/hanzo-memory/**'
- 'pkg/hanzo-aci/**'
- 'pkg/hanzo-repl/**'
- 'pkg/hanzoai/**'
- '.github/workflows/hanzo-packages-ci.yml'
tags:
- 'v*'
- 'hanzo-*'
- 'hanzo-network-*'
- 'hanzo-mcp-*'
# hanzo-agents is now a git submodule
- 'hanzo-memory-*'
- 'hanzo-aci-*'
- 'hanzo-repl-*'
pull_request:
branches:
- main
paths:
- 'pkg/hanzo/**'
- 'pkg/hanzo-network/**'
- 'pkg/hanzo-mcp/**'
# hanzo-agent is now a git submodule - not tested here
- 'pkg/hanzo-memory/**'
- 'pkg/hanzo-aci/**'
- 'pkg/hanzo-repl/**'
- 'pkg/hanzoai/**'
- '.github/workflows/hanzo-packages-ci.yml'
jobs:
test-hanzo-network:
name: Test hanzo-network
runs-on: hanzo-build-linux-amd64
timeout-minutes: 5
defaults:
run:
working-directory: pkg/hanzo-network
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-asyncio pytest-xdist numpy
pip install -e .
- name: Run ALL tests
run: |
timeout 120 python -m pytest tests/ -v --tb=short -n 4 --maxfail=5 || true # Parallel with 2min timeout
test-hanzo-mcp:
name: Test hanzo-mcp
runs-on: hanzo-build-linux-amd64
timeout-minutes: 5
defaults:
run:
working-directory: pkg/hanzo-mcp
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-asyncio pytest-cov pytest-xdist numpy
pip install -e .
# Install hanzo dependencies from the monorepo
pip install -e ../hanzo-network
# hanzo-agents is now a PyPI package (git submodule)
pip install hanzo-agents || true
pip install -e ../hanzo-memory
- name: Run ALL tests
run: |
timeout 120 python -m pytest tests/ -v --tb=short --cov=hanzo_mcp --cov-report=term-missing -n 4 --dist loadgroup --maxfail=5 -m "not slow" || echo "Tests completed or timed out"
test-hanzo-aci:
name: Test hanzo-aci
runs-on: hanzo-build-linux-amd64
timeout-minutes: 5
defaults:
run:
working-directory: pkg/hanzo-aci
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-asyncio pytest-cov pytest-xdist
pip install -e .
- name: Run ALL tests
run: |
timeout 120 python -m pytest tests/ -v --tb=short --cov=dev_aci --cov-report=term-missing -n 4 --maxfail=5 || true # Parallel with 2min timeout
# test-hanzo-agents: REMOVED - hanzo-agent is now a git submodule at pkg/hanzo-agent
# Tests run in the original repository: https://github.com/hanzoai/agent
test-hanzo-memory:
name: Test hanzo-memory
runs-on: hanzo-build-linux-amd64
timeout-minutes: 5
defaults:
run:
working-directory: pkg/hanzo-memory
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-asyncio pytest-cov pytest-xdist polars httpx
pip install -e .[test]
- name: Run ALL tests
run: |
timeout 120 python -m pytest tests/ -v --tb=short --cov=hanzo_memory --cov-report=term-missing -n 4 --maxfail=5 -k "not TestInfinityClient" || true # Parallel with 2min timeout
integration-test:
name: Integration Test
needs: [test-hanzo-network, test-hanzo-mcp, test-hanzo-aci, test-hanzo-memory, test-hanzo, test-hanzo-repl]
runs-on: hanzo-build-linux-amd64
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install all packages
run: |
python -m pip install --upgrade pip
pip install pytest pytest-asyncio pytest-xdist numpy
cd pkg/hanzo && pip install -e . && cd ../..
cd pkg/hanzo-network && pip install -e . && cd ../..
cd pkg/hanzo-mcp && pip install -e . && cd ../..
# hanzo-agents is now a PyPI package (git submodule)
pip install hanzo-agents || true
cd pkg/hanzo-memory && pip install -e . && cd ../..
cd pkg/hanzo-aci && pip install -e . && cd ../..
cd pkg/hanzo-repl && pip install -e . && cd ../..
- name: Run integration tests
run: |
timeout 60 python -m pytest pkg/hanzo-mcp/tests/test_hanzo_mcp_integration.py -v -n 4 --maxfail=5 || true
lint:
name: Lint Hanzo Packages
runs-on: hanzo-build-linux-amd64
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install linting tools
run: |
python -m pip install --upgrade pip
pip install ruff mypy
- name: Lint hanzo-network
run: |
cd pkg/hanzo-network
ruff check . || true
mypy . --ignore-missing-imports || true
- name: Lint hanzo-mcp
run: |
cd pkg/hanzo-mcp
ruff check . || true
mypy . --ignore-missing-imports || true
# Lint hanzo-agents: SKIPPED - hanzo-agent is now a git submodule
- name: Lint hanzo-aci
run: |
cd pkg/hanzo-aci
ruff check . || true
mypy . --ignore-missing-imports || true
- name: Lint hanzo-memory
run: |
cd pkg/hanzo-memory
ruff check . || true
mypy . --ignore-missing-imports || true
- name: Lint hanzo
run: |
cd pkg/hanzo
ruff check . || true
mypy . --ignore-missing-imports || true
- name: Lint hanzo-repl
run: |
cd pkg/hanzo-repl
ruff check . || true
mypy . --ignore-missing-imports || true
test-hanzo:
name: Test hanzo (main package)
runs-on: hanzo-build-linux-amd64
timeout-minutes: 5
defaults:
run:
working-directory: pkg/hanzo
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-asyncio pytest-cov pytest-xdist
pip install -e .
- name: Run tests if available
run: |
if [ -d "tests" ]; then
timeout 120 python -m pytest tests/ -v --tb=short -n 4 --maxfail=5 || true
else
echo "No tests directory found, skipping tests"
fi
test-hanzo-repl:
name: Test hanzo-repl
runs-on: hanzo-build-linux-amd64
timeout-minutes: 5
defaults:
run:
working-directory: pkg/hanzo-repl
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-asyncio pytest-cov pytest-xdist
pip install -e .
# Install hanzo dependencies
pip install -e ../hanzo-mcp
- name: Run tests if available
run: |
if [ -d "tests" ]; then
timeout 120 python -m pytest tests/ -v --tb=short -n 4 --maxfail=5 || true
else
echo "No tests directory found, checking for test module"
python -c "from hanzo_repl import tests; print('Test module found')" || echo "No test module"
fi
# Auto-publish packages with new versions on push to main
auto-publish-new-versions:
name: Auto-Publish New Versions
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
needs: [test-hanzo-network, test-hanzo-mcp, test-hanzo-aci, test-hanzo-memory, test-hanzo, test-hanzo-repl, integration-test]
runs-on: hanzo-build-linux-amd64
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Check and publish new versions
env:
PYPI_TOKEN: ${{ secrets.HANZO_PYPI_TOKEN || secrets.PYPI_TOKEN }}
run: |
python ./bin/check-and-publish.py
# Publish packages to PyPI when a tag is pushed (for manual releases)
publish-to-pypi:
name: Publish to PyPI (Tag)
if: startsWith(github.ref, 'refs/tags/')
needs: [test-hanzo-network, test-hanzo-mcp, test-hanzo-aci, test-hanzo-memory, test-hanzo, test-hanzo-repl, integration-test]
runs-on: hanzo-build-linux-amd64
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Get tag name
id: get_tag
run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Determine package to publish
id: determine_package
run: |
TAG="${{ steps.get_tag.outputs.TAG }}"
PACKAGES=""
# Determine which package(s) to publish based on tag
# Note: hanzo-agents is now a separate repo (git submodule), not published from here
if [[ $TAG == hanzo-network-* ]]; then
PACKAGES="hanzo-network"
elif [[ $TAG == hanzo-mcp-* ]]; then
PACKAGES="hanzo-mcp"
elif [[ $TAG == hanzo-memory-* ]]; then
PACKAGES="hanzo-memory"
elif [[ $TAG == hanzo-aci-* ]]; then
PACKAGES="hanzo-aci"
elif [[ $TAG == hanzo-repl-* ]]; then
PACKAGES="hanzo-repl"
elif [[ $TAG == hanzo-* ]]; then
PACKAGES="hanzo"
elif [[ $TAG == v* ]]; then
# For general version tags, publish all packages (except hanzo-agents which is a submodule)
PACKAGES="hanzo hanzo-network hanzo-mcp hanzo-memory hanzo-aci hanzo-repl"
fi
echo "PACKAGES=$PACKAGES" >> $GITHUB_OUTPUT
echo "Publishing packages: $PACKAGES"
- name: Publish packages
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.HANZO_PYPI_TOKEN || secrets.PYPI_TOKEN }}
run: |
PACKAGES="${{ steps.determine_package.outputs.PACKAGES }}"
if [ -z "$PACKAGES" ]; then
echo "No packages to publish for tag ${{ steps.get_tag.outputs.TAG }}"
exit 0
fi
for package in $PACKAGES; do
echo "Publishing $package..."
cd "pkg/$package"
# Clean and build
rm -rf dist/ build/ *.egg-info
python -m build
# Upload to PyPI
python -m twine upload dist/* --skip-existing
cd ../..
done
- name: Create release summary
run: |
echo "## 🚀 Published to PyPI" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Tag: ${{ steps.get_tag.outputs.TAG }}" >> $GITHUB_STEP_SUMMARY
echo "Packages: ${{ steps.determine_package.outputs.PACKAGES }}" >> $GITHUB_STEP_SUMMARY