1+ # This workflow runs a periodic rebase process, pulling in updates from an upstream repository
2+ # The workflow for rebasing a jito-solana branch to a solana labs branch locally is typically:
3+ # $ git checkout v1.17
4+ # $ git pull --rebase # --rebase needed locally
5+ # $ git branch -D lb/v1.17_rebase # deletes branch from last v1.17 rebase
6+ # $ git checkout -b lb/v1.17_rebase
7+ # $ git fetch upstream
8+ # $ git rebase upstream/v1.17 # rebase + fix merge conflicts
9+ # $ git rebase --continue
10+ # $ git push origin +lb/v1.17_rebase # force needed to overwrite remote. wait for CI, fix if any issues
11+ # $ git checkout v1.17
12+ # $ git reset --hard lb/v1.17_rebase
13+ # $ git push origin +v1.17
14+ #
15+ # This workflow automates this process, with periodic status updates over slack.
16+ # It will also run CI and wait for it to pass before performing the force push to v1.17.
17+ # In the event there's a failure in the process, it's reported to slack and the job stops.
18+
19+ name : " Rebase jito-solana from upstream anza-xyz/agave"
20+
21+ on :
22+ # push:
23+ schedule :
24+ - cron : " 30 18 * * 1-5"
25+
26+ jobs :
27+ rebase :
28+ runs-on : ubuntu-latest
29+ strategy :
30+ matrix :
31+ include :
32+ - branch : master
33+ rebase : upstream/master
34+ - branch : v1.18
35+ rebase : upstream/v1.18
36+ - branch : v1.17
37+ rebase : upstream/v1.17
38+ # note: this will always be a day behind because we're rebasing from the previous day's rebase
39+ # and NOT upstream
40+ - branch : v1.17-fast-replay
41+ rebase : origin/v1.17
42+ fail-fast : false
43+ steps :
44+ - uses : actions/checkout@v4
45+ with :
46+ ref : ${{ matrix.branch }}
47+ submodules : recursive
48+ fetch-depth : 0
49+ token : ${{ secrets.JITO_SOLANA_RELEASE_TOKEN }}
50+ - name : Add upstream
51+ run : git remote add upstream https://github.com/anza-xyz/agave.git
52+ - name : Fetch upstream
53+ run : git fetch upstream
54+ - name : Fetch origin
55+ run : git fetch origin
56+ - name : Set REBASE_BRANCH
57+ run : echo "REBASE_BRANCH=ci/nightly/${{ matrix.branch }}/$(date +'%Y-%m-%d-%H-%M')" >> $GITHUB_ENV
58+ - name : echo $REBASE_BRANCH
59+ run : echo $REBASE_BRANCH
60+ - name : Create rebase branch
61+ run : git checkout -b $REBASE_BRANCH
62+ - name : Setup email
63+ run : |
64+ git config --global user.email "[email protected] " 65+ git config --global user.name "Jito Infrastructure"
66+ - name : Rebase
67+ id : rebase
68+ run : git rebase ${{ matrix.rebase }}
69+ - name : Send warning for rebase error
70+ if : failure() && steps.rebase.outcome == 'failure'
71+ 72+ with :
73+ payload : |
74+ {
75+ "text": "Nightly rebase on branch ${{ matrix.branch }}\nStatus: Rebase failed to apply cleanly"
76+ }
77+ env :
78+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
79+ - name : Check if rebase applied
80+ id : check_rebase_applied
81+ run : |
82+ PRE_REBASE_SHA=$(git rev-parse ${{ matrix.branch }})
83+ POST_REBASE_SHA=$(git rev-parse HEAD)
84+ if [ "$PRE_REBASE_SHA" = "$POST_REBASE_SHA" ]; then
85+ echo "No rebase was applied, exiting..."
86+ exit 1
87+ else
88+ echo "Rebase applied successfully."
89+ fi
90+ - name : Send warning for rebase error
91+ if : failure() && steps.check_rebase_applied.outcome == 'failure'
92+ 93+ with :
94+ payload : |
95+ {
96+ "text": "Nightly rebase on branch ${{ matrix.branch }}\nStatus: Rebase not needed"
97+ }
98+ env :
99+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
100+ - name : Set REBASE_SHA
101+ run : echo "REBASE_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
102+ - name : Push changes
103+ uses : ad-m/github-push-action@master
104+ with :
105+ github_token : ${{ secrets.GITHUB_TOKEN }}
106+ branch : ${{ env.REBASE_BRANCH }}
107+ - name : Wait for buildkite to start build
108+ run : sleep 300
109+ - name : Wait for buildkite to finish
110+ id : wait_for_buildkite
111+ timeout-minutes : 300
112+ run : |
113+ while true; do
114+ response=$(curl -s -f -H "Authorization: Bearer ${{ secrets.BUILDKITE_TOKEN }}" "https://api.buildkite.com/v2/organizations/jito/pipelines/jito-solana/builds?commit=${{ env.REBASE_SHA }}")
115+ if [ $? -ne 0 ]; then
116+ echo "Curl request failed."
117+ exit 1
118+ fi
119+
120+ state=$(echo $response | jq --exit-status -r '.[0].state')
121+ echo "Current build state: $state"
122+
123+ # Check if the state is one of the finished states
124+ case $state in
125+ "passed"|"finished")
126+ echo "Build finished successfully."
127+ exit 0
128+ ;;
129+ "canceled"|"canceling"|"not_run")
130+ # ignoring "failing"|"failed" because flaky CI, can restart and hope it finishes or times out
131+ echo "Build failed or was cancelled."
132+ exit 2
133+ ;;
134+ esac
135+
136+ sleep 30
137+ done
138+ - name : Send failure update
139+ 140+ if : failure() && steps.wait_for_buildkite.outcome == 'failure'
141+ with :
142+ payload : |
143+ {
144+ "text": "Nightly rebase on branch ${{ matrix.branch }}\nStatus: CI failed\nBranch: ${{ env.REBASE_BRANCH}}\nBuild: https://buildkite.com/jito/jito-solana/builds?commit=${{ env.REBASE_SHA }}"
145+ }
146+ env :
147+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
148+ # check to see if different branch since CI build can take awhile and these steps are not atomic
149+ - name : Fetch the latest remote changes
150+ run : git fetch origin ${{ matrix.branch }}
151+ - name : Check if origin HEAD has changed from the beginning of the workflow
152+ run : |
153+ LOCAL_SHA=$(git rev-parse ${{ matrix.branch }})
154+ ORIGIN_SHA=$(git rev-parse origin/${{ matrix.branch }})
155+ if [ "$ORIGIN_SHA" != "$LOCAL_SHA" ]; then
156+ echo "The remote HEAD of ${{ matrix.branch }} does not match the local HEAD of ${{ matrix.branch }} at the beginning of CI."
157+ echo "origin sha: $ORIGIN_SHA"
158+ echo "local sha: $LOCAL_SHA"
159+ exit 1
160+ else
161+ echo "The remote HEAD matches the local REBASE_SHA at the beginning of CI. Proceeding."
162+ fi
163+ - name : Reset ${{ matrix.branch }} to ${{ env.REBASE_BRANCH }}
164+ run : |
165+ git checkout ${{ matrix.branch }}
166+ git reset --hard ${{ env.REBASE_BRANCH }}
167+ - name : Push rebased %{{ matrix.branch }}
168+ uses : ad-m/github-push-action@master
169+ with :
170+ github_token : ${{ secrets.JITO_SOLANA_RELEASE_TOKEN }}
171+ branch : ${{ matrix.branch }}
172+ force : true
173+ - name : Send success update
174+ 175+ with :
176+ payload : |
177+ {
178+ "text": "Nightly rebase on branch ${{ matrix.branch }}\nStatus: CI success, rebased, and pushed\nBranch: ${{ env.REBASE_BRANCH}}\nBuild: https://buildkite.com/jito/jito-solana/builds?commit=${{ env.REBASE_SHA }}"
179+ }
180+ env :
181+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
0 commit comments