1+ name : Test SDK
2+
3+ on : [pull_request]
4+
5+ jobs :
6+ test:
7+ runs-on: ubuntu-latest
8+ services :
9+ postgres:
10+ image: postgres
11+ env:
12+ POSTGRES_USER: graphnode
13+ POSTGRES_PASSWORD: password
14+ POSTGRES_DB: graphnode-db
15+ options: >-
16+ --health-cmd pg_isready
17+ --health-interval 10s
18+ --health-timeout 5s
19+ --health-retries 5
20+ command: ["postgres", "-c", "shared_preload_libraries=pg_stat_statements"]
21+ steps:
22+ - uses : actions/checkout@v4
23+
24+ - uses: actions/nodejs@v4
25+ with:
26+ node-version : '18'
27+
28+ - name : Prepare
29+ run : node test/scripts/prepare-test-env.js
30+
31+ - name : Test
32+ run : npm test
33+
34+ - name: Install Foundry
35+ uses: foundry-rs/foundry-toolchain@v1
36+ with:
37+ version : stable
38+ cache: true
39+
40+ - name: Start Anvil
41+ run: |
42+ anvil --host 0.0.0.0 --port 8545 --block-time 1 --hardfork berlin --fork-url $(cat local-stack-env/BELLECOUR_FORK_URL) --fork-block-number $(cat local-stack-env/BELLECOUR_FORK_BLOCK) --chain-id 134 --gas-limit 6700000 --gas-price 0 &
43+
44+ - name: Wait for Anvil to start
45+ run: |
46+ timeout=30
47+ interval=1
48+ echo "Waiting for Anvil to start..."
49+ for ((i=0; i<timeout; i++)); do
50+ if nc -z localhost 8545; then
51+ echo "Anvil is operational."
52+ exit 0
53+ fi
54+ echo "Attempt $((i+1)) of $timeout: Anvil is not ready, waiting ${interval}s..."
55+ sleep $interval
56+ done
57+ echo "Error: Anvil did not start within the timeout period."
58+ exit 1
59+
60+ - name: Start MongoDB
61+ uses: supercharge/[email protected] 62+ with:
63+ mongodb-version: '6.0'
64+
65+ - name: Start Redis
66+ uses: supercharge/[email protected] 67+ with:
68+ redis-version: '7'
69+
70+ - name: Start Graph Node # Find cleaner way to start graph node
71+ run: |
72+ docker run -d \
73+ --name graphnode \
74+ -p 8000:8000 \
75+ -p 8020:8020 \
76+ -e postgres_host=localhost \
77+ -e postgres_port=5432 \
78+ -e postgres_user=graphnode \
79+ -e postgres_pass=password \
80+ -e postgres_db=graphnode-db \
81+ -e ipfs=localhost:5001 \
82+ -e ethereum=bellecour:http://localhost:8545 \
83+ graphprotocol/graph-node:v0.27.0
84+
85+ export GRAPH_ETHEREUM_GENESIS_BLOCK_NUMBER=$(cat local-stack-env/BELLECOUR_FORK_BLOCK)
86+ echo $GRAPH_ETHEREUM_GENESIS_BLOCK_NUMBER
0 commit comments