Skip to content

Commit 7c3a132

Browse files
committed
add: wait-for-epoch action timeout
1 parent ff1103e commit 7c3a132

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

.github/actions/tests/wait-for-epoch/action.yml

+26-3
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,36 @@ inputs:
1212
description: 'Node name'
1313
required: true
1414
environment:
15-
description: 'Environment (optional for kubernetes)'
15+
description: 'Environment (needed for kubernetes deployment: staging-preview, staging-preprod)'
1616
required: false
17+
timeout:
18+
description: 'Timeout in seconds'
19+
required: true
20+
default: '600'
21+
interval:
22+
description: 'Interval in seconds between checks'
23+
required: true
24+
default: '10'
1725

1826
runs:
1927
using: "composite"
2028
steps:
2129
- name: Wait for epoch
2230
shell: bash
2331
run: |
32+
interval=${{ inputs.interval }}
2433
if [ "${{ inputs.deployment }}" == "docker" ]; then
2534
epoch=$(docker exec ${{ inputs.node }} cardano-cli query tip --testnet-magic 42 | jq -r .epoch)
35+
timeout=${{ inputs.timeout }}
36+
elapsed=0
2637
while [ $epoch -lt ${{ inputs.epoch }} ]; do
2738
echo "Epoch: $epoch"
28-
sleep 10
39+
sleep $interval
40+
elapsed=$((elapsed + interval))
41+
if [ $elapsed -ge $timeout ]; then
42+
echo "Timeout reached: $timeout seconds"
43+
exit 1
44+
fi
2945
epoch=$(docker exec ${{ inputs.node }} cardano-cli query tip --testnet-magic 42 | jq -r .epoch)
3046
done
3147
echo "Epoch: $epoch"
@@ -41,9 +57,16 @@ runs:
4157
fi
4258
4359
epoch=$(kubectl exec ${{ inputs.node }} -c cardano-node -n ${{ inputs.environment }} -- cardano-cli query tip --testnet-magic $testnet_magic | jq -r .epoch)
60+
timeout=${{ inputs.timeout }}
61+
elapsed=0
4462
while [ $epoch -lt ${{ inputs.epoch }} ]; do
4563
echo "Epoch: $epoch"
46-
sleep 10
64+
sleep $interval
65+
elapsed=$((elapsed + interval))
66+
if [ $elapsed -ge $timeout ]; then
67+
echo "Timeout reached: $timeout seconds"
68+
exit 1
69+
fi
4770
epoch=$(kubectl exec ${{ inputs.node }} -c cardano-node -n ${{ inputs.environment }} -- cardano-cli query tip --testnet-magic $testnet_magic | jq -r .epoch)
4871
done
4972
echo "Epoch: $epoch"

.github/workflows/cd.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ jobs:
288288
deployment: kubernetes
289289
node: staging-preview-validator-1
290290
environment: staging-preview
291+
timeout: 10
291292

292293
run-all-tests-on-n1-epoch:
293294
permissions:
@@ -321,7 +322,7 @@ jobs:
321322
permissions:
322323
id-token: write
323324
contents: read
324-
needs: wait-for-n1-epoch
325+
needs: partner-chain-ready
325326
runs-on: eks
326327
steps:
327328
- name: Checkout
@@ -348,6 +349,7 @@ jobs:
348349
deployment: kubernetes
349350
node: staging-preview-validator-1
350351
environment: staging-preview
352+
timeout: 10
351353

352354
run-all-tests-on-n2-epoch:
353355
permissions:

0 commit comments

Comments
 (0)