Skip to content

Schedule Scoring

Schedule Scoring #9891

Workflow file for this run

name: Schedule Scoring
on:
workflow_dispatch:
schedule:
- cron: '50 0/1 * * *'
jobs:
trigger_scoring_if_needed:
name: Schedule Scoring
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@master
- name: Check epoch timing
run: |
epoch_info=$(curl -sfLS "http://api.mainnet-beta.solana.com" -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1, "method":"getEpochInfo"}')
current_epoch=$(<<<"$epoch_info" jq '.result.epoch' -r)
slot_index=$(<<<"$epoch_info" jq '.result.slotIndex' -r)
last_scoring_epoch_from_dir=$(find scoring -type d | sort -n | tail -1 | cut -d/ -f2 | cut -d. -f1)
last_scoring_epoch_from_git=$(gh pr list --state open --json headRefName,isCrossRepository --jq '.[] | select(.isCrossRepository == false) | .headRefName' | grep scoring/ | sort -n | tail -1 | cut -d/ -f2| cut -d. -f1)
echo "Last scoring epoch (git): $last_scoring_epoch_from_git"
echo "Last scoring epoch (dir): $last_scoring_epoch_from_dir"
echo "Current epoch: $current_epoch"
echo "Current slot: $slot_index"
if (( slot_index < 216000 ))
then
echo "Too early in the epoch!"
exit 0
fi
if ! [[ -z $last_scoring_epoch_from_dir ]] && (( last_scoring_epoch_from_dir == current_epoch ))
then
echo "Scoring already run and merged!"
exit 0
fi
if ! [[ -z $last_scoring_epoch_from_git ]] && (( last_scoring_epoch_from_git == current_epoch ))
then
echo "Scoring already in PR!"
exit 0
fi
curl -sLfS "https://validators-api-dev.marinade.finance/admin/metrics?job_scheduled=true" -X POST \
-H "Authorization: ${{ secrets.VALIDATORS_API_ADMIN_TOKEN }}"
echo "Triggering the scoring pipeline..."
gh workflow run prepare-scoring.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}