Skip to content

Commit

Permalink
fix: v2 pipelines (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
butonium authored Apr 25, 2024
1 parent 9f2700f commit 921e034
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 23 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/v2-apply-scoring.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,27 @@ on:
pull_request:
types: [closed]
branches:
- scoring-v2
- master

jobs:
apply_scoring_v2:
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'ds-scoring/'))
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'scoring/'))

steps:
- name: Checkout the repository
uses: actions/checkout@master
with:
ref: scoring-v2
fetch-depth: 20

- name: Load scoring details
run: |
set -ex
git fetch --all
scores_csv=$(git log -1 origin/scoring-v2 --name-only --pretty=format: --grep 'scoring run' | grep scores.csv | grep scoring-v2)
params_json=$(git log -1 origin/scoring-v2 --name-only --pretty=format: --grep 'scoring run' | grep params.json | grep scoring-v2)
scores_csv=$(git log -1 --name-only --pretty=format: --grep 'scoring run' | grep scores.csv | grep scoring-v2)
params_json=$(git log -1 --name-only --pretty=format: --grep 'scoring run' | grep params.json | grep scoring-v2)
scoring_run_ui_id=$(git log -1 origin/scoring-v2 --name-only --pretty=format: --grep 'scoring run' | grep scoring-v2 | head -6 | tail -1 | awk -F / '{print $2}')
scoring_run_ui_id=$(git log -1 --name-only --pretty=format: --grep 'scoring run' | grep scoring-v2 | head -6 | tail -1 | awk -F / '{print $2}')
epoch=$(<<<"$scoring_run_ui_id" awk -F . '{print $1}')
weightVoteCredits=$(jq '.weightVoteCredits' $params_json)
Expand Down Expand Up @@ -151,14 +150,13 @@ jobs:
# - name: Checkout the repository
# uses: actions/checkout@master
# with:
# ref: scoring-v2
# fetch-depth: 20

# - name: Load scoring details
# run: |
# set -ex
# unstake_hints_json=$(git log -1 --name-only --pretty=format: --grep 'scoring run' | grep unstake-hints.json)
# scoring_run_ui_id=$(git log -1 origin/scoring-v2 --name-only --pretty=format: --grep 'scoring run' | grep scoring-v2 | head -6 | tail -1 | awk -F / '{print $2}')
# scoring_run_ui_id=$(git log -1 --name-only --pretty=format: --grep 'scoring run' | grep scoring-v2 | head -6 | tail -1 | awk -F / '{print $2}')
# epoch=$(<<<"$scoring_run_ui_id" awk -F . '{print $1}')

# if [[ -z $unstake_hints_json ]]
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/v2-apply-unstakes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,23 @@ on:
pull_request:
types: [closed]
branches:
- scoring-v2
- master

jobs:
late_unstake:
if: startsWith(github.event.pull_request.head.ref, 'ds-unstakes') && github.event.pull_request.merged == true
if: startsWith(github.event.pull_request.head.ref, 'unstakes') && github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@master
with:
ref: scoring-v2
fetch-depth: 20

- name: Load scoring details
run: |
set -ex
unstake_hints_json=$(git log -1 --name-only --pretty=format: --grep 'emergency unstakes' | grep unstake-hints.json)
scoring_run_ui_id=$(git log -1 origin/scoring-v2 --name-only --pretty=format: --grep 'emergency unstakes' | grep scoring-v2 | head -3 | tail -1 | awk -F / '{print $2}')
scoring_run_ui_id=$(git log -1 --name-only --pretty=format: --grep 'emergency unstakes' | grep scoring-v2 | head -3 | tail -1 | awk -F / '{print $2}')
epoch=$(<<<"$scoring_run_ui_id" awk -F . '{print $1}')
if [[ -z $unstake_hints_json ]]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/v2-prepare-scoring.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
- name: Make a Pull Request
run: |
scoring_id="${{ env.scoring_id }}"
scoring_branch="ds-scoring/$scoring_id"
scoring_branch="scoring/$scoring_id"
cp /tmp/snapshot/* "${{ env.scoring_path }}/"
gzip -c "${{ env.scoring_path }}/validators.json" > "${{ env.scoring_path }}/validators.json.gz"
rm "${{ env.scoring_path }}/validators.json"
Expand All @@ -81,7 +81,7 @@ jobs:
git add scoring-v2
[[ -n "$(git status --porcelain)" ]] && git commit -m "scoring run $scoring_id" && git push -u origin "$scoring_branch" || echo "No changes to be committed"
pr_url=$(gh pr create -B scoring-v2 -H "$scoring_branch" --title "Publish V2 Scoring Results ($scoring_id)" --body-file "${{ env.scoring_path }}/summary.md")
pr_url=$(gh pr create -B scoring -H "$scoring_branch" --title "Publish V2 Scoring Results ($scoring_id)" --body-file "${{ env.scoring_path }}/summary.md")
echo "pr_url=$pr_url" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/v2-prepare-unstakes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ jobs:
- name: Checkout the repository
uses: actions/checkout@master
with:
ref: scoring-v2
fetch-depth: 20

- name: Load scoring unstakes details
run: |
set -ex
unstake_hints_json=$(git log -1 origin/scoring-v2 --name-only --pretty=format: --grep 'scoring run' | grep scoring-v2 | grep unstake-hints.json)
scoring_run_ui_id=$(git log -1 origin/scoring-v2 --name-only --pretty=format: --grep 'scoring run' | grep scoring-v2 | head -6 | tail -1 | awk -F / '{print $2}')
unstake_hints_json=$(git log -1 --name-only --pretty=format: --grep 'scoring run' | grep scoring-v2 | grep unstake-hints.json)
scoring_run_ui_id=$(git log -1 --name-only --pretty=format: --grep 'scoring run' | grep scoring-v2 | head -6 | tail -1 | awk -F / '{print $2}')
epoch=$(<<<"$scoring_run_ui_id" awk -F . '{print $1}')
if [[ -z $unstake_hints_json ]]
Expand Down Expand Up @@ -119,7 +118,7 @@ jobs:
- name: Make a Pull Request
run: |
scoring_id="${{ env.scoring_id }}"
scoring_branch="ds-unstakes/$scoring_id"
scoring_branch="unstakes/$scoring_id"
total_marinade_stake="${{ env.total_marinade_stake }}"
validators_count="${{ env.validators_count }}"
git config --global user.name 'Autonomous Scoring Pipeline'
Expand All @@ -128,7 +127,7 @@ jobs:
git add scoring-v2
[[ -n "$(git status --porcelain)" ]] && git commit -m "emergency unstakes for scoring run $scoring_id" && git push -u origin "$scoring_branch" || echo "No changes to be committed"
pr_body=$(cat unstakes.md)
pr_url=$(gh pr create -B scoring-v2 -H "$scoring_branch" --title "Publish V2 Emergency Unstakes ($scoring_id)" --body "$pr_body")
pr_url=$(gh pr create -B scoring -H "$scoring_branch" --title "Publish V2 Emergency Unstakes ($scoring_id)" --body "$pr_body")
echo "pr_url=$pr_url" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/v2-schedule-scoring.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jobs:
- name: Checkout the repository
uses: actions/checkout@master
with:
ref: scoring-v2
fetch-depth: 20
- name: Check epoch timing
run: |
Expand All @@ -21,7 +20,7 @@ jobs:
slot_index=$(<<<"$epoch_info" jq '.result.slotIndex' -r)
last_v2_scoring_epoch_from_dir=$(find scoring-v2 -type d | sort -n | tail -1 | cut -d/ -f2 | cut -d. -f1)
last_v2_scoring_epoch_from_git=$(gh pr list --state open --json headRefName,isCrossRepository --jq '.[] | select(.isCrossRepository == false) | .headRefName' | grep ds-scoring/ | sort -n | tail -1 | cut -d/ -f2| cut -d. -f1)
last_v2_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 V2 scoring epoch (git): $last_v2_scoring_epoch_from_git"
echo "Last V2 scoring epoch (dir): $last_v2_scoring_epoch_from_dir"
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/v2-schedule-unstakes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jobs:
- name: Checkout the repository
uses: actions/checkout@master
with:
ref: scoring-v2
fetch-depth: 20
- name: Check epoch timing
run: |
Expand All @@ -21,7 +20,7 @@ jobs:
slot_index=$(<<<"$epoch_info" jq '.result.slotIndex' -r)
last_v2_scoring_epoch_from_dir=$(find scoring-v2 -type d | sort -n | tail -1 | cut -d/ -f2 | cut -d. -f1)
last_v2_scoring_epoch_from_git=$(gh pr list --state open --json headRefName,isCrossRepository --jq '.[] | select(.isCrossRepository == false) | .headRefName' | grep ds-unstakes/ | sort -n | tail -1 | cut -d/ -f2| cut -d. -f1)
last_v2_scoring_epoch_from_git=$(gh pr list --state open --json headRefName,isCrossRepository --jq '.[] | select(.isCrossRepository == false) | .headRefName' | grep unstakes/ | sort -n | tail -1 | cut -d/ -f2| cut -d. -f1)
echo "Last V2 scoring epoch (git): $last_v2_scoring_epoch_from_git"
echo "Last V2 scoring epoch (dir): $last_v2_scoring_epoch_from_dir"
Expand Down

0 comments on commit 921e034

Please sign in to comment.