Skip to content

Commit

Permalink
PM-1764 - Add daily Seed Synchronisation Check
Browse files Browse the repository at this point in the history
  • Loading branch information
kaozenn committed Jun 13, 2024
1 parent 38dee22 commit f8bfb34
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/sync-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Daily Seed Synchronization Check
on:
push:
branches: [PM-1764-create-daily-seed-synchronisation-check]
jobs:
parse-mainnet-seed-list:
runs-on: minafoundation-xlarge-runners
outputs:
seeds: ${{ steps.parse-mainnet-seed-list.outputs.seeds }}
steps:
- name: 📥 Checkout
uses: actions/[email protected]
- name: Parse Mainnet Seed List
id: parse-mainnet-seed-list
run: |
echo "Parsing Mainnet Seed List"
seeds=$(cat networks/mainnet.txt | jq -R -s -c 'split("\n") | map(select(. != ""))')
echo "seeds=$seeds" >> $GITHUB_OUTPUT
check-synchronization:
needs: parse-mainnet-seed-list
runs-on: minafoundation-xlarge-runners
if: needs.parse-mainnet-seed-list.outputs.seeds != '[]' && needs.parse-mainnet-seed-list.outputs.seeds != ''
strategy:
matrix:
seed: ${{ fromJson(needs.parse-mainnet-seed-list.outputs.seeds) }}
steps:
- name: Start Mina Daemon
run: |
docker run -d --restart always --name mina \
minaprotocol/mina-daemon:3.0.0-93e0279-bullseye-mainnet \
mina daemon \
--peer ${{ matrix.seed }}
- name: Wait for Daemon to Sync
run: |
check_sync_status() {
status=$(docker exec mina mina client status --json | jq -r .sync_status)
echo "Current sync status: $status"
}
# Number of attempts (12 attempts, 5 minutes apart, equals 1 hour)
max_attempts=12
attempt=0
# Loop to check sync status
while [ $attempt -lt $max_attempts ]; do
check_sync_status
if [ "$status" == "Synced" ]; then
echo "Mina client is synced."
exit 0
fi
attempt=$((attempt + 1))
echo "Mina client is not synced. Attempt $attempt/$max_attempts."
sleep 300 # Sleep for 5 minutes
done
echo "Mina client failed to sync within 1 hour."
exit 1
- name: Post to a Slack channel
id: slack
uses: slackapi/[email protected]
with:
channel-id: 'test-slack-api'
slack-message: "${{ matrix.seed }}"
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

0 comments on commit f8bfb34

Please sign in to comment.