Merge upstream dcSpark/shinkai-node v1.1.20 #16
This file contains hidden or 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
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [main] | |
| paths: | |
| - ".github/workflows/main-fast.yaml" | |
| - ".github/Dockerfile" | |
| - "Cargo.*" | |
| - "hanzo-libs/**" | |
| - "hanzo-bin/**" | |
| - "files/**" | |
| - "contracts/**" | |
| pull_request: | |
| branches: [main] | |
| types: [opened, reopened, synchronize, ready_for_review] | |
| paths: | |
| - ".github/workflows/main-fast.yaml" | |
| - ".github/Dockerfile" | |
| - "Cargo.*" | |
| - "hanzo-libs/**" | |
| - "hanzo-bin/**" | |
| - "files/**" | |
| - "contracts/**" | |
| name: Hanzo Fast Test Workflow | |
| concurrency: | |
| group: fast-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUST_BACKTRACE: 1 | |
| jobs: | |
| # ============================================================================= | |
| # Build Stage - Compile and push Docker image | |
| # ============================================================================= | |
| build: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| outputs: | |
| image: ghcr.io/${{ github.repository }}/hanzo-test:${{ github.sha }} | |
| steps: | |
| - name: Free disk space | |
| run: | | |
| sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache | |
| sudo rm -rf /usr/local/share/boost /usr/share/swift /usr/local/graalvm | |
| sudo rm -rf /opt/microsoft /opt/az /usr/local/julia* | |
| sudo rm -rf /home/runner/actions-runner/cached/_diag/*.log || true | |
| sudo apt-get clean || true | |
| sudo docker system prune -af | |
| df -h | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Download tools from store to pre-install folder | |
| run: | | |
| ./scripts/update_tools.sh | |
| - name: Build and push testing image | |
| run: | | |
| # Start background cleanup to prevent runner log disk full during build | |
| (while true; do sleep 30; sudo truncate -s 0 /home/runner/actions-runner/cached/_diag/*.log 2>/dev/null || true; done) & | |
| CLEANUP_PID=$! | |
| docker build -t ghcr.io/${{ github.repository }}/hanzo-test:${{ github.sha }} --build-arg COMMIT_SHA=${{ github.sha }} --build-arg AI_MODEL_CATALOG_BUILD=1 -f .github/Dockerfile . | |
| docker push ghcr.io/${{ github.repository }}/hanzo-test:${{ github.sha }} | |
| kill $CLEANUP_PID 2>/dev/null || true | |
| # ============================================================================= | |
| # Contract Tests - Run separately (no Docker needed) | |
| # ============================================================================= | |
| test-contracts: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Install Foundry | |
| uses: foundry-rs/foundry-toolchain@v1 | |
| - name: Run Foundry tests | |
| working-directory: contracts | |
| run: forge test -vvv | |
| # ============================================================================= | |
| # Pure Unit Tests - High Parallelization (no shared state) | |
| # These packages have pure functions, crypto ops, parsing - safe to parallelize | |
| # ============================================================================= | |
| test-unit-pure: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| needs: build | |
| if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} | |
| permissions: | |
| packages: read | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Group 1: Message & Identity (pure crypto/parsing) | |
| - name: messages-identity | |
| packages: "-p hanzo-messages -p hanzo-identity -p hanzo-did -p hanzo-pqc" | |
| threads: 8 | |
| # Group 2: Config & Format (pure parsing) | |
| - name: config-format | |
| packages: "-p hanzo-config -p hanzo-ai-format -p hanzo-models" | |
| threads: 8 | |
| # Group 3: WASM & Tools (isolated) | |
| - name: wasm-tools | |
| packages: "-p hanzo-wasm -p hanzo-wasm-runtime -p hanzo-tools" | |
| threads: 4 | |
| steps: | |
| - name: Free disk space | |
| run: | | |
| sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache | |
| sudo rm -rf /usr/local/share/boost /usr/share/swift /usr/local/graalvm | |
| sudo rm -rf /opt/microsoft /opt/az /usr/local/julia* | |
| sudo rm -rf /home/runner/actions-runner/cached/_diag/*.log || true | |
| sudo docker system prune -af | |
| df -h | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Run unit tests (${{ matrix.name }}) | |
| run: | | |
| # Start background cleanup to prevent runner log disk full during tests | |
| (while true; do sleep 30; sudo truncate -s 0 /home/runner/actions-runner/cached/_diag/*.log 2>/dev/null || true; done) & | |
| CLEANUP_PID=$! | |
| docker run --rm \ | |
| --name hanzo_unit_${{ matrix.name }}_${{ github.sha }} \ | |
| ghcr.io/${{ github.repository }}/hanzo-test:${{ github.sha }} \ | |
| /bin/bash -c "cd /app && cargo test ${{ matrix.packages }} -- --test-threads=${{ matrix.threads }} --nocapture" | |
| kill $CLEANUP_PID 2>/dev/null || true | |
| # ============================================================================= | |
| # Database Tests - Medium Parallelization (isolated temp DBs) | |
| # ============================================================================= | |
| test-database: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| needs: build | |
| if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} | |
| permissions: | |
| packages: read | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: sqlite | |
| packages: "-p hanzo-db-sqlite" | |
| threads: 4 | |
| - name: db-core | |
| packages: "-p hanzo-database -p hanzo-db" | |
| threads: 4 | |
| steps: | |
| - name: Free disk space | |
| run: | | |
| sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache | |
| sudo rm -rf /usr/local/share/boost /usr/share/swift /usr/local/graalvm | |
| sudo rm -rf /opt/microsoft /opt/az /usr/local/julia* | |
| sudo rm -rf /home/runner/actions-runner/cached/_diag/*.log || true | |
| sudo docker system prune -af | |
| df -h | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Run database tests (${{ matrix.name }}) | |
| run: | | |
| # Start background cleanup to prevent runner log disk full during tests | |
| (while true; do sleep 30; sudo truncate -s 0 /home/runner/actions-runner/cached/_diag/*.log 2>/dev/null || true; done) & | |
| CLEANUP_PID=$! | |
| docker run --rm \ | |
| --name hanzo_db_${{ matrix.name }}_${{ github.sha }} \ | |
| -e IS_TESTING=1 \ | |
| ghcr.io/${{ github.repository }}/hanzo-test:${{ github.sha }} \ | |
| /bin/bash -c "cd /app && cargo test ${{ matrix.packages }} -- --test-threads=${{ matrix.threads }} --nocapture" | |
| kill $CLEANUP_PID 2>/dev/null || true | |
| # ============================================================================= | |
| # API & Network Tests - Low Parallelization (port/network constraints) | |
| # ============================================================================= | |
| test-api: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| needs: build | |
| if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} | |
| permissions: | |
| packages: read | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: http-api | |
| packages: "-p hanzo-http-api -p hanzo-api" | |
| threads: 2 | |
| - name: llm-mcp | |
| packages: "-p hanzo-llm -p hanzo-mcp" | |
| threads: 2 | |
| - name: runtime | |
| packages: "-p hanzo-runtime -p hanzo-runtime-tests" | |
| threads: 2 | |
| # hanzo-runner requires serial execution to avoid deno binary race conditions | |
| # Docker tests are skipped at runtime when Docker daemon is unavailable | |
| - name: runner | |
| packages: "-p hanzo-runner" | |
| threads: 1 | |
| steps: | |
| - name: Free disk space | |
| run: | | |
| sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache | |
| sudo rm -rf /usr/local/share/boost /usr/share/swift /usr/local/graalvm | |
| sudo rm -rf /opt/microsoft /opt/az /usr/local/julia* | |
| sudo rm -rf /home/runner/actions-runner/cached/_diag/*.log || true | |
| sudo docker system prune -af | |
| df -h | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Run API tests (${{ matrix.name }}) | |
| env: | |
| X402_PAY_TO: ${{ secrets.X402_PAY_TO }} | |
| X402_PRIVATE_KEY: ${{ secrets.X402_PRIVATE_KEY }} | |
| run: | | |
| # Start background cleanup to prevent runner log disk full during tests | |
| (while true; do sleep 30; sudo truncate -s 0 /home/runner/actions-runner/cached/_diag/*.log 2>/dev/null || true; done) & | |
| CLEANUP_PID=$! | |
| docker run --rm \ | |
| --name hanzo_api_${{ matrix.name }}_${{ github.sha }} \ | |
| -e IS_TESTING=1 \ | |
| -e SKIP_IMPORT_FROM_DIRECTORY=true \ | |
| -e WELCOME_MESSAGE=false \ | |
| -e X402_PAY_TO="${{ secrets.X402_PAY_TO }}" \ | |
| -e X402_PRIVATE_KEY="${{ secrets.X402_PRIVATE_KEY }}" \ | |
| ghcr.io/${{ github.repository }}/hanzo-test:${{ github.sha }} \ | |
| /bin/bash -c "cd /app && cargo test ${{ matrix.packages }} -- --test-threads=${{ matrix.threads }} --nocapture" | |
| kill $CLEANUP_PID 2>/dev/null || true | |
| # ============================================================================= | |
| # Node Integration Tests - Serial (full node startup required) | |
| # ============================================================================= | |
| test-node: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| needs: build | |
| if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} | |
| environment: FROM_WALLET_PRIVATE_KEY | |
| permissions: | |
| packages: read | |
| steps: | |
| - name: Free disk space | |
| run: | | |
| sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache | |
| sudo rm -rf /usr/local/share/boost /usr/share/swift /usr/local/graalvm | |
| sudo rm -rf /opt/microsoft /opt/az /usr/local/julia* | |
| sudo rm -rf /home/runner/actions-runner/cached/_diag/*.log || true | |
| sudo docker system prune -af | |
| df -h | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Run node tests | |
| env: | |
| X402_PAY_TO: ${{ secrets.X402_PAY_TO }} | |
| X402_PRIVATE_KEY: ${{ secrets.X402_PRIVATE_KEY }} | |
| RESTORE_WALLET_MNEMONICS_NODE2: ${{ secrets.RESTORE_WALLET_MNEMONICS_NODE2 }} | |
| FROM_WALLET_PRIVATE_KEY: ${{ secrets.FROM_WALLET_PRIVATE_KEY }} | |
| run: | | |
| # Start background cleanup to prevent runner log disk full during test | |
| (while true; do sleep 30; sudo truncate -s 0 /home/runner/actions-runner/cached/_diag/*.log 2>/dev/null || true; done) & | |
| CLEANUP_PID=$! | |
| docker run --rm \ | |
| --name hanzo_node_tests_${{ github.sha }} \ | |
| -e IS_TESTING=1 \ | |
| -e SKIP_IMPORT_FROM_DIRECTORY=true \ | |
| -e WELCOME_MESSAGE=false \ | |
| -e X402_PAY_TO="${{ secrets.X402_PAY_TO }}" \ | |
| -e X402_PRIVATE_KEY="${{ secrets.X402_PRIVATE_KEY }}" \ | |
| -e RESTORE_WALLET_MNEMONICS_NODE2="${{ secrets.RESTORE_WALLET_MNEMONICS_NODE2 }}" \ | |
| -e FROM_WALLET_PRIVATE_KEY="${{ secrets.FROM_WALLET_PRIVATE_KEY }}" \ | |
| ghcr.io/${{ github.repository }}/hanzo-test:${{ github.sha }} \ | |
| /bin/bash -c "cd /app && cargo test -p hanzo-node -- --test-threads=1 --nocapture --skip node_integration_tests" | |
| kill $CLEANUP_PID 2>/dev/null || true | |
| # ============================================================================= | |
| # Network Integration Tests - Serial (requires network infrastructure) | |
| # ============================================================================= | |
| test-integration: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| needs: build | |
| if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} | |
| environment: FROM_WALLET_PRIVATE_KEY | |
| permissions: | |
| packages: read | |
| # Integration tests require full network infrastructure not available in CI | |
| continue-on-error: true | |
| steps: | |
| - name: Free disk space | |
| run: | | |
| sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache | |
| sudo rm -rf /usr/local/share/boost /usr/share/swift /usr/local/graalvm | |
| sudo rm -rf /opt/microsoft /opt/az /usr/local/julia* | |
| sudo rm -rf /home/runner/actions-runner/cached/_diag/*.log || true | |
| sudo docker system prune -af | |
| df -h | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Run integration tests | |
| env: | |
| X402_PAY_TO: ${{ secrets.X402_PAY_TO }} | |
| X402_PRIVATE_KEY: ${{ secrets.X402_PRIVATE_KEY }} | |
| RESTORE_WALLET_MNEMONICS_NODE2: ${{ secrets.RESTORE_WALLET_MNEMONICS_NODE2 }} | |
| FROM_WALLET_PRIVATE_KEY: ${{ secrets.FROM_WALLET_PRIVATE_KEY }} | |
| run: | | |
| # Start background cleanup to prevent runner log disk full during test | |
| (while true; do sleep 30; sudo truncate -s 0 /home/runner/actions-runner/cached/_diag/*.log 2>/dev/null || true; done) & | |
| CLEANUP_PID=$! | |
| docker run --rm --network host \ | |
| --name hanzo_integration_${{ github.sha }} \ | |
| -e IS_TESTING=1 \ | |
| -e SKIP_IMPORT_FROM_DIRECTORY=true \ | |
| -e WELCOME_MESSAGE=false \ | |
| -e X402_PAY_TO="${{ secrets.X402_PAY_TO }}" \ | |
| -e X402_PRIVATE_KEY="${{ secrets.X402_PRIVATE_KEY }}" \ | |
| -e RESTORE_WALLET_MNEMONICS_NODE2="${{ secrets.RESTORE_WALLET_MNEMONICS_NODE2 }}" \ | |
| -e FROM_WALLET_PRIVATE_KEY="${{ secrets.FROM_WALLET_PRIVATE_KEY }}" \ | |
| ghcr.io/${{ github.repository }}/hanzo-test:${{ github.sha }} \ | |
| /bin/bash -c "cd /app && cargo test -- --test-threads=1 --nocapture node_integration_tests a3_micropayment_flow_tests a4_micropayment_localhost_tests" | |
| kill $CLEANUP_PID 2>/dev/null || true | |
| # ============================================================================= | |
| # Other Library Tests - Medium Parallelization | |
| # ============================================================================= | |
| test-libs-other: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| needs: build | |
| if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} | |
| permissions: | |
| packages: read | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: fs-embed | |
| packages: "-p hanzo-fs -p hanzo-embed" | |
| threads: 4 | |
| - name: jobs | |
| packages: "-p hanzo-jobs -p hanzo-job-queue-manager" | |
| threads: 4 | |
| - name: network | |
| packages: "-p hanzo-libp2p -p hanzo-libp2p-relayer" | |
| threads: 2 | |
| - name: misc | |
| packages: "-p hanzo-compute -p hanzo-mining -p hanzo-model-discovery -p hanzo-baml" | |
| threads: 4 | |
| steps: | |
| - name: Free disk space | |
| run: | | |
| sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache | |
| sudo rm -rf /usr/local/share/boost /usr/share/swift /usr/local/graalvm | |
| sudo rm -rf /opt/microsoft /opt/az /usr/local/julia* | |
| sudo rm -rf /home/runner/actions-runner/cached/_diag/*.log || true | |
| sudo docker system prune -af | |
| df -h | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Run lib tests (${{ matrix.name }}) | |
| run: | | |
| # Start background cleanup to prevent runner log disk full during tests | |
| (while true; do sleep 30; sudo truncate -s 0 /home/runner/actions-runner/cached/_diag/*.log 2>/dev/null || true; done) & | |
| CLEANUP_PID=$! | |
| docker run --rm \ | |
| --name hanzo_libs_${{ matrix.name }}_${{ github.sha }} \ | |
| -e IS_TESTING=1 \ | |
| ghcr.io/${{ github.repository }}/hanzo-test:${{ github.sha }} \ | |
| /bin/bash -c "cd /app && cargo test ${{ matrix.packages }} -- --test-threads=${{ matrix.threads }} --nocapture" | |
| kill $CLEANUP_PID 2>/dev/null || true |