Skip to content

ci: automated testing of API/RPC endpoints #2

ci: automated testing of API/RPC endpoints

ci: automated testing of API/RPC endpoints #2

Workflow file for this run

name: Test API Endpoints
on: [push, pull_request]
jobs:
generate-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- name: Install jq
run: sudo apt-get install jq
- name: Generate matrix
id: set-matrix
run: |
MATRIX=$(jq -c '[.[] | .api[] | {url: .url, type: .type}]' data/networks.json)
echo "::set-output name=matrix::{\"include\":$MATRIX}"
test-endpoints:
needs: generate-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{fromJson(needs.generate-matrix.outputs.matrix)}}
outputs:
test-success: ${{ steps.test-endpoint.outputs.test-success }}
steps:
- uses: actions/checkout@v2
- name: Test Endpoint
id: test-endpoint
run: |
url="${{ matrix.url }}"
type="${{ matrix.type }}"
test_success="true"
if [ "$type" = "evm" ]; then
response=$(curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' "$url")
if echo "$response" | jq -e .id &> /dev/null; then
echo "✅ $url - Successful"
else
echo "❌ $url - Failed"
test_success="false"
fi
fi
# Add more logic here for different types if needed
echo "test-success=$test_success" >> $GITHUB_ENV
echo "::set-output name=test-success::$test_success"
- name: Check Test Results
if: ${{ needs.test-endpoints.outputs.test-success != 'true' }}
run: exit 1