Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
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

- 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'
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
21 changes: 18 additions & 3 deletions scripts/test_rpc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "-----------------------------------"

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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