Skip to content

Commit

Permalink
add: wait-for-epoch action timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
rsporny committed Oct 23, 2024
1 parent ff1103e commit 7c3a132
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
29 changes: 26 additions & 3 deletions .github/actions/tests/wait-for-epoch/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,36 @@ inputs:
description: 'Node name'
required: true
environment:
description: 'Environment (optional for kubernetes)'
description: 'Environment (needed for kubernetes deployment: staging-preview, staging-preprod)'
required: false
timeout:
description: 'Timeout in seconds'
required: true
default: '600'
interval:
description: 'Interval in seconds between checks'
required: true
default: '10'

runs:
using: "composite"
steps:
- name: Wait for epoch
shell: bash
run: |
interval=${{ inputs.interval }}
if [ "${{ inputs.deployment }}" == "docker" ]; then
epoch=$(docker exec ${{ inputs.node }} cardano-cli query tip --testnet-magic 42 | jq -r .epoch)
timeout=${{ inputs.timeout }}
elapsed=0
while [ $epoch -lt ${{ inputs.epoch }} ]; do
echo "Epoch: $epoch"
sleep 10
sleep $interval
elapsed=$((elapsed + interval))
if [ $elapsed -ge $timeout ]; then
echo "Timeout reached: $timeout seconds"
exit 1
fi
epoch=$(docker exec ${{ inputs.node }} cardano-cli query tip --testnet-magic 42 | jq -r .epoch)
done
echo "Epoch: $epoch"
Expand All @@ -41,9 +57,16 @@ runs:
fi
epoch=$(kubectl exec ${{ inputs.node }} -c cardano-node -n ${{ inputs.environment }} -- cardano-cli query tip --testnet-magic $testnet_magic | jq -r .epoch)
timeout=${{ inputs.timeout }}
elapsed=0
while [ $epoch -lt ${{ inputs.epoch }} ]; do
echo "Epoch: $epoch"
sleep 10
sleep $interval
elapsed=$((elapsed + interval))
if [ $elapsed -ge $timeout ]; then
echo "Timeout reached: $timeout seconds"
exit 1
fi
epoch=$(kubectl exec ${{ inputs.node }} -c cardano-node -n ${{ inputs.environment }} -- cardano-cli query tip --testnet-magic $testnet_magic | jq -r .epoch)
done
echo "Epoch: $epoch"
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ jobs:
deployment: kubernetes
node: staging-preview-validator-1
environment: staging-preview
timeout: 10

run-all-tests-on-n1-epoch:
permissions:
Expand Down Expand Up @@ -321,7 +322,7 @@ jobs:
permissions:
id-token: write
contents: read
needs: wait-for-n1-epoch
needs: partner-chain-ready
runs-on: eks
steps:
- name: Checkout
Expand All @@ -348,6 +349,7 @@ jobs:
deployment: kubernetes
node: staging-preview-validator-1
environment: staging-preview
timeout: 10

run-all-tests-on-n2-epoch:
permissions:
Expand Down

0 comments on commit 7c3a132

Please sign in to comment.