Skip to content

ci: automated testing of API/RPC endpoints #4

ci: automated testing of API/RPC endpoints

ci: automated testing of API/RPC endpoints #4

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 "{ \"include\": $MATRIX }" > matrix.json
echo "::set-output name=matrix::$(cat matrix.json)"
test-endpoints:
needs: generate-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{fromJson(needs.generate-matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v2
- name: Test Endpoint
run: |
url="${{ matrix.url }}"
type="${{ matrix.type }}"
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"
echo "test_failed=true" >> $GITHUB_ENV
fi
- name: Check Test Results
if: ${{ env.test_failed == 'true' }}
run: exit 1