Skip to content

Commit c282d8e

Browse files
Fix: add electrs health check to prevent CI race conditions
- Add health check for electrs service in docker-compose.yml - Add explicit wait for service health in CI workflow - Prevent connection errors in tests due to services not being fully initialized This addresses intermittent CI failures where Python tests would fail with "Connection reset by peer" errors because they ran before electrs was fully ready to accept requests.
1 parent 9c02f23 commit c282d8e

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

.github/workflows/kotlin.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ jobs:
4545
- name: Start bitcoind and electrs
4646
run: docker compose up -d
4747

48+
- name: Wait for services to be fully initialized
49+
run: |
50+
echo "Waiting for services to be ready..."
51+
timeout 90 bash -c 'until docker compose ps | grep -q "bitcoin.*healthy" && docker compose ps | grep -q "electrs.*healthy"; do sleep 5; done'
52+
echo "All services are healthy"
53+
4854
- name: Run ldk-node-jvm tests
4955
run: |
5056
cd $LDK_NODE_JVM_DIR

.github/workflows/python.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ jobs:
2424
- name: Start bitcoind and electrs
2525
run: docker compose up -d
2626

27+
- name: Wait for services to be fully initialized
28+
run: |
29+
echo "Waiting for services to be ready..."
30+
timeout 90 bash -c 'until docker compose ps | grep -q "bitcoin.*healthy" && docker compose ps | grep -q "electrs.*healthy"; do sleep 5; done'
31+
echo "All services are healthy"
32+
2733
- name: Install testing prerequisites
2834
run: |
2935
pip3 install requests

docker-compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ services:
4747
- "3002:3002"
4848
networks:
4949
- bitcoin-electrs
50+
healthcheck:
51+
test: [ "CMD", "curl", "-f", "http://localhost:3002/blocks/tip/hash" ]
52+
interval: 5s
53+
timeout: 10s
54+
retries: 5
5055

5156
networks:
5257
bitcoin-electrs:

0 commit comments

Comments
 (0)