Node Tests #188
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
| name: Node Tests | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| schedule: | |
| - cron: '0 0 * * *' | |
| jobs: | |
| node_tests: | |
| name: Run Node Tests | |
| runs-on: ubuntu-latest-large | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| - name: Rust Cache | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Install Foundry | |
| uses: foundry-rs/foundry-toolchain@v1 | |
| with: | |
| version: nightly | |
| - name: Install RISC0 | |
| uses: ./.github/actions/install-risc0 | |
| with: | |
| version: 1.2.4 | |
| # Login to DockerHub with access token | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_TOKEN }} | |
| # Set up Docker and Docker Compose | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| # Try to pull cache images (with separate tags for cache) | |
| - name: Pull cache images | |
| continue-on-error: true # Continue even if images don't exist yet | |
| run: | | |
| docker pull elladic/ttc-prover-server:cache || true | |
| docker pull elladic/anvil-node:cache || true | |
| docker pull elladic/ttc-monitor-server:cache || true | |
| # Build with cache from pulled images | |
| - name: Build Docker images | |
| run: | | |
| # Pull cache images | |
| docker pull elladic/ttc-prover-server:cache || true | |
| docker pull elladic/anvil-node:cache || true | |
| docker pull elladic/ttc-monitor-server:cache || true | |
| # Build prover-server image | |
| echo "Building prover-server image..." | |
| DOCKER_BUILDKIT=1 docker build \ | |
| --target prover-server \ | |
| --tag elladic/ttc-prover-server:local \ | |
| --cache-from elladic/ttc-prover-server:cache \ | |
| --build-arg BUILDKIT_INLINE_CACHE=1 \ | |
| -f docker/servers/Dockerfile . | |
| # Build monitor-server image | |
| echo "Building monitor-server image..." | |
| DOCKER_BUILDKIT=1 docker build \ | |
| --target monitor-server \ | |
| --tag elladic/ttc-monitor-server:local \ | |
| --cache-from elladic/ttc-monitor-server:cache \ | |
| --build-arg BUILDKIT_INLINE_CACHE=1 \ | |
| -f docker/servers/Dockerfile . | |
| # Debug: List directory contents to locate Dockerfile | |
| echo "Contents of ./docker/anvil:" | |
| ls -la ./docker/anvil/ | |
| # Build anvil-node image | |
| echo "Building anvil-node image..." | |
| DOCKER_BUILDKIT=1 docker build \ | |
| --tag elladic/anvil-node:local \ | |
| --cache-from elladic/anvil-node:cache \ | |
| --build-arg BUILDKIT_INLINE_CACHE=1 \ | |
| -f ./docker/anvil/Dockerfile ./docker/anvil | |
| # Start services with docker compose using the built images | |
| echo "Creating .env file with image references..." | |
| echo "PROVER_SERVER_IMAGE=elladic/ttc-prover-server:local" > .env | |
| echo "ETHEREUM_NODE_IMAGE=elladic/anvil-node:local" >> .env | |
| echo "MONITOR_SERVER_IMAGE=elladic/ttc-monitor-server:local" >> .env | |
| echo "Contents of .env file:" | |
| cat .env | |
| # Run mock tests for regular pushes/PRs | |
| - name: Run node tests with mocks | |
| if: github.event_name != 'schedule' | |
| run: | | |
| mkdir -p /tmp/risc0-work-dir | |
| RISC0_DEV_MODE=true docker compose up -d | |
| make compile-contract-deps | |
| make fetch-image-id-contract > contract/src/ImageID.sol | |
| make compile-ttc-contract | |
| make create-schema | |
| export TTC_ADDRESS=$(make deploy-mock | tee /dev/tty | tail -n 1) | |
| TTC_ADDRESS="$TTC_ADDRESS" make run-node-tests | |
| # Run full tests for nightly builds | |
| - name: Run full node tests | |
| if: github.event_name == 'schedule' | |
| run: | | |
| mkdir -p /tmp/risc0-work-dir | |
| RISC0_DEV_MODE=false docker compose up -d | |
| make compile-contract-deps | |
| make fetch-image-id-contract > contract/src/ImageID.sol | |
| make compile-ttc-contract | |
| make create-schema | |
| export TTC_ADDRESS=$(make deploy | tee /dev/tty | tail -n 1) | |
| TTC_ADDRESS="$TTC_ADDRESS" NUM_ACTORS=3 PROVER_TIMEOUT=1200 make run-node-tests | |
| # Get short git SHA for tagging | |
| - name: Get short SHA | |
| id: short_sha | |
| run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
| # Push versioned and cache images | |
| - name: Push images | |
| if: github.ref == 'refs/heads/main' && (success() || failure()) | |
| continue-on-error: true | |
| run: | | |
| # Get short SHA | |
| SHA=$(git rev-parse --short HEAD) | |
| # Tag and push prover-server images with SHA and cache tags | |
| docker tag elladic/ttc-prover-server:local elladic/ttc-prover-server:$SHA | |
| docker push elladic/ttc-prover-server:$SHA | |
| docker tag elladic/ttc-prover-server:local elladic/ttc-prover-server:cache | |
| docker push elladic/ttc-prover-server:cache | |
| # Tag and push monitor-server images with SHA and cache tags | |
| docker tag elladic/ttc-monitor-server:local elladic/ttc-monitor-server:$SHA | |
| docker push elladic/ttc-monitor-server:$SHA | |
| docker tag elladic/ttc-monitor-server:local elladic/ttc-monitor-server:cache | |
| docker push elladic/ttc-monitor-server:cache | |
| # Tag and push ethereum-node images with SHA and cache tags | |
| docker tag elladic/anvil-node:local elladic/anvil-node:$SHA | |
| docker push elladic/anvil-node:$SHA | |
| docker tag elladic/anvil-node:local elladic/anvil-node:cache | |
| docker push elladic/anvil-node:cache | |
| # Push latest tag only on successful builds from main branch | |
| - name: Push latest tag | |
| if: github.ref == 'refs/heads/main' && success() | |
| run: | | |
| # Tag and push latest versions | |
| docker tag elladic/ttc-prover-server:local elladic/ttc-prover-server:latest | |
| docker push elladic/ttc-prover-server:latest | |
| docker tag elladic/ttc-monitor-server:local elladic/ttc-monitor-server:latest | |
| docker push elladic/ttc-monitor-server:latest | |
| docker tag elladic/anvil-node:local elladic/anvil-node:latest | |
| docker push elladic/anvil-node:latest | |
| # Cleanup | |
| - name: Cleanup | |
| if: always() | |
| run: docker compose down |