-
Notifications
You must be signed in to change notification settings - Fork 18
53 lines (47 loc) · 1.68 KB
/
api.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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