Skip to content

Commit 9470e43

Browse files
committed
ci: add GitHub Actions workflow
1 parent 48ae860 commit 9470e43

File tree

2 files changed

+91
-1
lines changed

2 files changed

+91
-1
lines changed

.github/workflows/main.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,8 @@ utils/**
3636
errors/**
3737

3838
# env
39-
.env
39+
.env
40+
41+
# IDE
42+
.idea
43+
.vscode

0 commit comments

Comments
 (0)