Skip to content

Commit 2ec36bb

Browse files
committed
feature: refactor to allow built image for setup nodes
1 parent 8d3718e commit 2ec36bb

File tree

2 files changed

+55
-27
lines changed

2 files changed

+55
-27
lines changed

.github/workflows/integ-tests.yml

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ jobs:
101101

102102
- name: Start 12-node stack (docker-compose)
103103
run: |
104-
bash setup_nodes.sh 12
104+
if [ "${{ github.event_name }}" = "pull_request" ]; then
105+
bash setup_nodes.sh 12 "trieve/threshold:pr-${{ github.event.pull_request.number }}"
106+
else
107+
bash setup_nodes.sh 12 "trieve/threshold:latest"
108+
fi
105109
106110
- name: Wait for gRPC endpoints
107111
run: |
@@ -173,22 +177,26 @@ jobs:
173177

174178
- name: Start 5-node stack (docker-compose)
175179
run: |
176-
docker compose -f docker-compose.yaml up -d
180+
if [ "${{ github.event_name }}" = "pull_request" ]; then
181+
bash setup_nodes.sh 5 "trieve/threshold:pr-${{ github.event.pull_request.number }}"
182+
else
183+
bash setup_nodes.sh 5 "trieve/threshold:latest"
184+
fi
177185
178186
- name: Wait for gRPC endpoint
179187
run: |
180-
echo "Waiting for node to expose port 50051..."
188+
echo "Waiting for node to expose port 50057-50062..."
181189
for i in {1..30}; do
182-
if nc -z localhost 50051; then
183-
echo "Port 50051 is open."
190+
if nc -z localhost {50057..50062}; then
191+
echo "Port 50057-50062 is open."
184192
break
185193
fi
186194
echo "Port not ready yet – retry #$i"
187195
sleep 5
188196
done
189197
190198
- name: Run end-to-end integration tests
191-
run: cargo run --bin integration-tests check-dkg --port-range 50051-50055
199+
run: cargo run --bin integration-tests check-dkg --port-range 50057-50062
192200

193201
end-to-end-deposit-withdrawl:
194202
runs-on: blacksmith-16vcpu-ubuntu-2204
@@ -237,14 +245,18 @@ jobs:
237245

238246
- name: Start 5-node stack (docker-compose)
239247
run: |
240-
docker compose -f docker-compose.yaml up -d
248+
if [ "${{ github.event_name }}" = "pull_request" ]; then
249+
bash setup_nodes.sh 5 "trieve/threshold:pr-${{ github.event.pull_request.number }}"
250+
else
251+
bash setup_nodes.sh 5 "trieve/threshold:latest"
252+
fi
241253
242254
- name: Wait for gRPC endpoint
243255
run: |
244-
echo "Waiting for node to expose port 50051..."
256+
echo "Waiting for node to expose port 50057-50062..."
245257
for i in {1..30}; do
246-
if nc -z localhost 50051; then
247-
echo "Port 50051 is open."
258+
if nc -z localhost {50057..50062}; then
259+
echo "Port 50057-50062 is open."
248260
break
249261
fi
250262
echo "Port not ready yet – retry #$i"
@@ -309,14 +321,18 @@ jobs:
309321

310322
- name: Start 5-node stack with network chaos
311323
run: |
312-
docker compose -f docker-compose.yaml -f docker-compose.chaos-network.yaml up -d
324+
if [ "${{ github.event_name }}" = "pull_request" ]; then
325+
bash setup_nodes.sh 5 "trieve/threshold:pr-${{ github.event.pull_request.number }}"
326+
else
327+
bash setup_nodes.sh 5 "trieve/threshold:latest"
328+
fi
313329
314330
- name: Wait for gRPC endpoint
315331
run: |
316-
echo "Waiting for node to expose port 50051..."
332+
echo "Waiting for node to expose port 50057-50062..."
317333
for i in {1..30}; do
318-
if nc -z localhost 50051; then
319-
echo "Port 50051 is open."
334+
if nc -z localhost {50057..50062}; then
335+
echo "Port 50057-50062 is open."
320336
break
321337
fi
322338
echo "Port not ready yet – retry #$i"
@@ -378,14 +394,18 @@ jobs:
378394

379395
- name: Start 5-node stack with node chaos
380396
run: |
381-
docker compose -f docker-compose.yaml -f docker-compose.chaos-nodes.yaml up -d
397+
if [ "${{ github.event_name }}" = "pull_request" ]; then
398+
bash setup_nodes.sh 5 "trieve/threshold:pr-${{ github.event.pull_request.number }}"
399+
else
400+
bash setup_nodes.sh 5 "trieve/threshold:latest"
401+
fi
382402
383403
- name: Wait for gRPC endpoint
384404
run: |
385-
echo "Waiting for node to expose port 50051..."
405+
echo "Waiting for node to expose port 50057-50062..."
386406
for i in {1..30}; do
387-
if nc -z localhost 50051; then
388-
echo "Port 50051 is open."
407+
if nc -z localhost {50057..50062}; then
408+
echo "Port 50057-50062 is open."
389409
break
390410
fi
391411
echo "Port not ready yet – retry #$i"
@@ -450,14 +470,18 @@ jobs:
450470

451471
- name: Start 5-node stack with network chaos
452472
run: |
453-
docker compose -f docker-compose.yaml -f docker-compose.chaos-network.yaml up -d
473+
if [ "${{ github.event_name }}" = "pull_request" ]; then
474+
bash setup_nodes.sh 5 "trieve/threshold:pr-${{ github.event.pull_request.number }}"
475+
else
476+
bash setup_nodes.sh 5 "trieve/threshold:latest"
477+
fi
454478
455479
- name: Wait for gRPC endpoint
456480
run: |
457-
echo "Waiting for node to expose port 50051..."
481+
echo "Waiting for node to expose port 50057-50062..."
458482
for i in {1..30}; do
459-
if nc -z localhost 50051; then
460-
echo "Port 50051 is open."
483+
if nc -z localhost {50057..50062}; then
484+
echo "Port 50057-50062 is open."
461485
break
462486
fi
463487
echo "Port not ready yet – retry #$i"
@@ -523,10 +547,10 @@ jobs:
523547
524548
- name: Wait for gRPC endpoint
525549
run: |
526-
echo "Waiting for node to expose port 50051..."
550+
echo "Waiting for node to expose port 50057-50062..."
527551
for i in {1..30}; do
528-
if nc -z localhost 50051; then
529-
echo "Port 50051 is open."
552+
if nc -z localhost {50057..50062}; then
553+
echo "Port 50057-50062 is open."
530554
break
531555
fi
532556
echo "Port not ready yet – retry #$i"

setup_nodes.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ set -euo pipefail
1616

1717
# --------------------------- Configuration -----------------------------------
1818
NUM_NODES=${1:-5}
19+
IMAGE_TAG=${2:-trieve/threshold:latest}
1920
BASE_DIR="test_artifacts/"
2021

2122
CLI_CMD=(cargo run --quiet --bin cli)
@@ -137,7 +138,7 @@ for i in $(seq 1 "$NUM_NODES"); do
137138

138139
cat >> "$BASE_DIR/test_${NUM_NODES}_nodes/$DOCKER_COMPOSE_FILE" <<EOL
139140
node${i}:
140-
image: threshold-node
141+
image: $IMAGE_TAG
141142
environment:
142143
- KEY_PASSWORD=${KEY_PASSWORD}
143144
- IS_TESTNET=true
@@ -167,7 +168,10 @@ echo "Successfully generated '$BASE_DIR/test_${NUM_NODES}_nodes/$DOCKER_COMPOSE_
167168
echo -e "\nBuilding Docker image..."
168169

169170
cd "$BASE_DIR/test_${NUM_NODES}_nodes"
170-
docker build -t threshold-node -f ../../Dockerfile ../..
171+
172+
if [ -z "$2" ]; then
173+
docker build -t threshold-node -f ../../Dockerfile ../..
174+
fi
171175

172176
# ------------------- Start Docker Compose ----------------------------
173177
echo -e "\nStarting Docker Compose for $NUM_NODES nodes..."

0 commit comments

Comments
 (0)