From 54676b376752cdd22bf762d1d8beb406cca29dd8 Mon Sep 17 00:00:00 2001 From: mmd-afegbua Date: Mon, 9 Feb 2026 18:17:41 +0100 Subject: [PATCH 1/3] added build and push workflow --- .github/workflows/docker-build.yml | 89 ++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 .github/workflows/docker-build.yml diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..38d7154 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,89 @@ +name: Docker Build + +on: + push: + branches: [ "dev" ] + pull_request: + branches: [ "dev" ] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-test: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to the Container registry + if: github.event_name == 'push' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=sha + + # 1. Build and Load to Docker Daemon for Testing + - name: Build and load Docker image + uses: docker/build-push-action@v5 + with: + context: . + load: true + tags: super-rpc:test + cache-from: type=gha + cache-to: type=gha,mode=max + + # 2. Run Tests + - name: Start services and Test + run: | + # Create data directory permissions + mkdir -p data + chmod 777 data + + # Prepare config + cp config.example.yaml config.yaml + + # Start using the image we just built (tagged super-rpc:test) + # We need to override the build in docker-compose to use our pre-built image + # OR just rely on compose building it again (it's fast with layer cache) + # Let's use compose to ensure environment consistency + docker compose up -d --build + + echo "Waiting for service to be healthy..." + sleep 10 + curl --retry 5 --retry-connrefused http://localhost:4500/health + + echo "Running Integration Tests..." + chmod +x ./scripts/test_rpc.sh + ./scripts/test_rpc.sh + + # 3. Push to Registry (Only on Push event) + - name: Build and push Docker image + if: github.event_name == 'push' + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max From 3656d829d3dd61cfdc6fea90903b6d4c60287c27 Mon Sep 17 00:00:00 2001 From: mmd-afegbua Date: Mon, 9 Feb 2026 18:31:22 +0100 Subject: [PATCH 2/3] track test failure --- scripts/test_rpc.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/scripts/test_rpc.sh b/scripts/test_rpc.sh index 76f0603..78bddc3 100755 --- a/scripts/test_rpc.sh +++ b/scripts/test_rpc.sh @@ -9,6 +9,9 @@ RED='\033[0;31m' BLUE='\033[0;34m' NC='\033[0m' +# Track failures +FAILURES=0 + echo "Testing Super RPC at $BASE_URL" echo "-----------------------------------" @@ -24,9 +27,14 @@ make_rpc_call() { "$BASE_URL/$NETWORK") # Simple check for error vs result - if [[ $RESPONSE == *"error"* ]]; then + # check for "error" property in JSON, or potential curl failures (empty response) + if [[ -z "$RESPONSE" ]]; then + echo -e "${RED}FAILED (No Response)${NC}" + FAILURES=$((FAILURES+1)) + elif [[ $RESPONSE == *"\"error\""* ]]; then echo -e "${RED}ERROR${NC}" echo " -> $RESPONSE" + FAILURES=$((FAILURES+1)) else echo -e "${GREEN}OK${NC}" # Print a snippet of the result to keep it clean, max 100 chars @@ -49,11 +57,12 @@ test_network() { make_rpc_call "$NETWORK" "eth_getBalance" "[\"0x0000000000000000000000000000000000000000\", \"latest\"]" 4 # 4. Fallback / Archival Test (Block 15,000,000 -> 0xE4E1C0) + # Note: Ensure this block exists on the network being tested! echo -e " ${BLUE}[Archival Test]${NC} eth_getBalance (Block 15M): " make_rpc_call "$NETWORK" "eth_getBalance" "[\"0x0000000000000000000000000000000000000000\", \"0xE4E1C0\"]" 5 # 5. eth_getLogs Test (Standard 10M range) - echo -e " ${BLUE}[GetLogs Test]${NC} eth_getLogs (10M -> 10M+1): " + echo -e " ${BLUE}[GetLogs Test]${NC} eth_getLogs: " make_rpc_call "$NETWORK" "eth_getLogs" "[{\"fromBlock\":\"0x989680\",\"toBlock\":\"0x989681\", \"address\": \"0x0000000000000000000000000000000000000000\"}]" 6 # 6. Immutable eth_call Test (Block 15M) - Simple call to 0x0...0 @@ -67,4 +76,10 @@ test_network "base-mainnet" test_network "optimism-sepolia" echo -e "\n-----------------------------------" -echo "Done." +if [ $FAILURES -eq 0 ]; then + echo -e "${GREEN}All tests passed.${NC}" + exit 0 +else + echo -e "${RED}$FAILURES tests failed.${NC}" + exit 1 +fi From 6e4b8eee148da0f24e05de84c2dafea12da9294b Mon Sep 17 00:00:00 2001 From: mmd-afegbua Date: Mon, 9 Feb 2026 18:38:04 +0100 Subject: [PATCH 3/3] show test logs --- .github/workflows/docker-build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 38d7154..2e1c60d 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -76,6 +76,10 @@ jobs: chmod +x ./scripts/test_rpc.sh ./scripts/test_rpc.sh + - name: Show Container Logs + if: always() + run: docker compose logs + # 3. Push to Registry (Only on Push event) - name: Build and push Docker image if: github.event_name == 'push'