Skip to content

Merge pull request #61 from getoptimum/docs/add-start-end-index-docum… #82

Merge pull request #61 from getoptimum/docs/add-start-end-index-docum…

Merge pull request #61 from getoptimum/docs/add-start-end-index-docum… #82

Workflow file for this run

name: CI
env:
go-version: "1.24.1"
lint-version: "v2.0.1"
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
# Required: allow read access to the content for analysis.
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
pull-requests: read
# Optional: allow write access to checks to allow the action to annotate code in the PR.
checks: write
jobs:
# Test the Go client implementations
test-go-clients:
name: Test Go Clients
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: ${{ env.go-version }}
cache: true
- uses: actions/checkout@v4
- name: Build Proxy Client
run: |
cd grpc_proxy_client
go build -o proxy-client ./proxy_client.go
- name: Build Key Generator
run: |
cd keygen
go build -o generate-p2p-key ./generate_p2p_key.go
- name: Test Key Generation
run: |
cd keygen
go run ./generate_p2p_key.go
# Lint Go code
golangci:
name: Lint Go Code
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: ${{ env.go-version }}
cache: true
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v7
with:
version: ${{ env.lint-version }}
args: --timeout 10m
only-new-issues: true
working-directory: ./
continue-on-error: true
# Test Docker Compose setup
test-docker-setup:
name: Test Docker Setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up Docker Compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
- name: Generate P2P Identity
run: |
chmod +x ./script/generate-identity.sh
# Generate identity and capture the BOOTSTRAP_PEER_ID
source ./script/generate-identity.sh
echo "BOOTSTRAP_PEER_ID=$BOOTSTRAP_PEER_ID" >> $GITHUB_ENV
echo "P2P identity generated successfully"
- name: Start Services
run: |
echo "Starting services with BOOTSTRAP_PEER_ID=$BOOTSTRAP_PEER_ID"
BOOTSTRAP_PEER_ID=$BOOTSTRAP_PEER_ID docker-compose -f docker-compose-optimum.yml up --build -d
echo "Services started successfully"
- name: Wait for Services
run: |
echo "Waiting for services to be ready..."
sleep 60
docker-compose -f docker-compose-optimum.yml ps
echo "Checking service logs..."
docker-compose -f docker-compose-optimum.yml logs --tail=30
- name: Health Check Services
run: |
echo "Waiting for services to be healthy..."
max_attempts=30
attempt=1
# Wait for proxy to be ready
while [ $attempt -le $max_attempts ]; do
if curl -f http://localhost:8081/api/v1/health >/dev/null 2>&1; then
echo "Proxy is ready (attempt $attempt)"
break
fi
echo "Waiting for proxy... (attempt $attempt/$max_attempts)"
sleep 10
attempt=$((attempt + 1))
done
if [ $attempt -gt $max_attempts ]; then
echo "Proxy failed to start after $max_attempts attempts"
docker-compose -f docker-compose-optimum.yml logs proxy-1
exit 1
fi
# Wait for P2P node to be ready
attempt=1
while [ $attempt -le $max_attempts ]; do
if curl -f http://localhost:9091/api/v1/health >/dev/null 2>&1; then
echo "P2P node is ready (attempt $attempt)"
break
fi
echo "Waiting for P2P node... (attempt $attempt/$max_attempts)"
sleep 10
attempt=$((attempt + 1))
done
if [ $attempt -gt $max_attempts ]; then
echo "P2P node failed to start after $max_attempts attempts"
docker-compose -f docker-compose-optimum.yml logs p2pnode-1
exit 1
fi
echo "All services are healthy and ready!"
- name: Run Test Suite
run: |
chmod +x ./test_suite.sh
./test_suite.sh
- name: Cleanup
if: always()
run: |
docker-compose -f docker-compose-optimum.yml down -v
echo "Cleanup completed"
# Test shell scripts
test-scripts:
name: Test Shell Scripts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Test Generate Identity Script
run: |
chmod +x ./script/generate-identity.sh
./script/generate-identity.sh
echo "Generate identity script test passed"
- name: Test Proxy Client Script
run: |
chmod +x ./script/proxy_client.sh
# Test help output
./script/proxy_client.sh || true
echo "Proxy client script test passed"
- name: Test Makefile
run: |
make help
echo "Makefile help test passed"
# Validate configuration files
validate-config:
name: Validate Configuration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
- name: Validate Docker Compose
run: |
docker-compose -f docker-compose-optimum.yml config
docker-compose -f docker-compose-gossipsub.yml config
echo "Docker Compose configurations are valid"
- name: Validate Go Modules
run: |
cd grpc_p2p_client && go mod verify
cd ../grpc_proxy_client && go mod verify
cd ../keygen && go mod verify
echo "All Go modules are valid"