name: Docker Integration Tests
on:
push:
branches: [ main, develop, 'feature/**' ]
pull_request:
branches: [ main, develop ]
workflow_dispatch:
jobs:
docker-integration-test:
name: Docker Integration Tests
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build all-in-one container
run: |
docker build -f integration-test/Dockerfile.all-in-one -t x402-all-in-one .
env:
DOCKER_BUILDKIT: 1
- name: Start all-in-one container
run: |
docker run -d \
--name x402-test \
-p 8545:8545 \
-p 6379:6379 \
-p 4020:4020 \
-p 4021:4021 \
x402-all-in-one
echo "Container started, waiting for services to be ready..."
- name: Wait for services health checks
run: |
echo "Waiting for all services to be healthy..."
# Wait for Redis to be ready
echo "Checking Redis..."
for i in {1..30}; do
if docker exec x402-test redis-cli ping > /dev/null 2>&1; then
echo "Redis is ready!"
break
fi
echo "Waiting for Redis... ($i/30)"
sleep 2
done
# Wait for Anvil RPC to be ready
echo "Checking Anvil..."
for i in {1..30}; do
if curl -f -X POST -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
http://localhost:8545 > /dev/null 2>&1; then
echo "Anvil is ready!"
break
fi
echo "Waiting for Anvil... ($i/30)"
sleep 2
done
# Wait for Facilitator to be ready
echo "Checking Facilitator..."
for i in {1..60}; do
if curl -f http://localhost:4020/health > /dev/null 2>&1; then
echo "Facilitator is ready!"
break
fi
echo "Waiting for Facilitator... ($i/60)"
sleep 2
done
# Wait for Backend to be ready
echo "Checking Backend..."
for i in {1..60}; do
if curl -f http://localhost:4021/health > /dev/null 2>&1; then
echo "Backend is ready!"
break
fi
echo "Waiting for Backend... ($i/60)"
sleep 2
done
# Final check - fail if services aren't ready
if ! docker exec x402-test redis-cli ping > /dev/null 2>&1; then
echo "Redis failed to become ready"
docker logs x402-test
exit 1
fi
if ! curl -f http://localhost:4021/health > /dev/null 2>&1 || \
! curl -f http://localhost:4020/health > /dev/null 2>&1; then
echo "Services failed to become healthy"
docker logs x402-test
exit 1
fi
echo "All services are healthy and ready!"
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Run Docker integration tests
env:
RUST_BACKTRACE: 1
RUST_LOG: debug
run: |
cargo test --test docker_integration_test --features axum,redis -- --nocapture --test-threads=1
continue-on-error: false
- name: Check container logs on failure
if: failure()
run: |
echo "=== Container logs ==="
docker logs x402-test || true
echo ""
echo "=== Container status ==="
docker ps -a | grep x402-test || true
echo ""
echo "=== Redis status ==="
docker exec x402-test redis-cli ping || true
echo ""
echo "=== Anvil RPC status ==="
curl -X POST -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
http://localhost:8545 || true
echo ""
echo "=== Service health checks ==="
curl -v http://localhost:4021/health || true
echo ""
curl -v http://localhost:4020/health || true
- name: Stop and remove container
if: always()
run: |
docker stop x402-test || true
docker rm x402-test || true