Rebase helius from upstream anza-xyz/agave #25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow runs a periodic rebase process, pulling in updates from an upstream repository | |
# The workflow for rebasing a helius branch to an agave branch locally is typically: | |
# $ git checkout v1.17 | |
# $ git pull --rebase # --rebase needed locally | |
# $ git branch -D lb/v1.17_rebase # deletes branch from last v1.17 rebase | |
# $ git checkout -b lb/v1.17_rebase | |
# $ git fetch upstream | |
# $ git rebase upstream/v1.17 # rebase + fix merge conflicts | |
# $ git rebase --continue | |
# $ git push origin +lb/v1.17_rebase # force needed to overwrite remote. wait for CI, fix if any issues | |
# $ git checkout v1.17 | |
# $ git reset --hard lb/v1.17_rebase | |
# $ git push origin +v1.17 | |
# | |
# This workflow automates this process, with periodic status updates over slack. | |
# It will also run CI and wait for it to pass before performing the force push to v1.17. | |
# In the event there's a failure in the process, it's reported to slack and the job stops. | |
name: "Rebase helius from upstream anza-xyz/agave" | |
on: | |
# push: | |
schedule: | |
- cron: "00 19 * * 1-5" | |
workflow_dispatch: | |
jobs: | |
rebase: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- branch: master | |
upstream_branch: master | |
upstream_repo: https://github.com/anza-xyz/agave.git | |
- branch: v2.0 | |
upstream_branch: v2.0 | |
upstream_repo: https://github.com/anza-xyz/agave.git | |
- branch: v2.1 | |
upstream_branch: v2.1 | |
upstream_repo: https://github.com/anza-xyz/agave.git | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ matrix.branch }} | |
submodules: recursive | |
fetch-depth: 0 | |
- name: Add upstream | |
run: git remote add upstream ${{ matrix.upstream_repo }} | |
- name: Fetch upstream | |
run: git fetch upstream | |
- name: Fetch origin | |
run: git fetch origin | |
- name: Set REBASE_BRANCH | |
run: echo "REBASE_BRANCH=ci/nightly/${{ matrix.branch }}/$(date +'%Y-%m-%d-%H-%M')" >> $GITHUB_ENV | |
- name: echo $REBASE_BRANCH | |
run: echo $REBASE_BRANCH | |
- name: Create rebase branch | |
run: git checkout -b $REBASE_BRANCH | |
- name: Setup email | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "Helius Infrastructure" | |
- name: Rebase | |
id: rebase | |
run: git rebase upstream/${{ matrix.upstream_branch }} | |
- name: Check if rebase applied | |
id: check_rebase_applied | |
continue-on-error: true | |
run: | | |
PRE_REBASE_SHA=$(git rev-parse ${{ matrix.branch }}) | |
POST_REBASE_SHA=$(git rev-parse HEAD) | |
if [ "$PRE_REBASE_SHA" = "$POST_REBASE_SHA" ]; then | |
echo "NEEDS_REBASE=false" >> $GITHUB_ENV | |
echo "No rebase needed, skipping remaining steps..." | |
else | |
echo "NEEDS_REBASE=true" >> $GITHUB_ENV | |
echo "Rebase applied successfully." | |
fi | |
- name: Set REBASE_SHA | |
if: env.NEEDS_REBASE == 'true' | |
run: echo "REBASE_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV | |
- name: Push changes | |
if: env.NEEDS_REBASE == 'true' | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ env.REBASE_BRANCH }} | |
- name: Fetch the latest remote changes | |
if: env.NEEDS_REBASE == 'true' | |
run: git fetch origin ${{ matrix.branch }} | |
- name: Check if origin HEAD has changed | |
if: env.NEEDS_REBASE == 'true' | |
run: | | |
LOCAL_SHA=$(git rev-parse ${{ matrix.branch }}) | |
ORIGIN_SHA=$(git rev-parse origin/${{ matrix.branch }}) | |
if [ "$ORIGIN_SHA" != "$LOCAL_SHA" ]; then | |
echo "The remote HEAD of ${{ matrix.branch }} does not match the local HEAD of ${{ matrix.branch }} at the beginning of CI." | |
echo "origin sha: $ORIGIN_SHA" | |
echo "local sha: $LOCAL_SHA" | |
exit 1 | |
else | |
echo "The remote HEAD matches the local REBASE_SHA at the beginning of CI. Proceeding." | |
fi | |
- name: Reset ${{ matrix.branch }} to ${{ env.REBASE_BRANCH }} | |
if: env.NEEDS_REBASE == 'true' | |
run: | | |
git checkout ${{ matrix.branch }} | |
git reset --hard ${{ env.REBASE_BRANCH }} | |
- name: Push rebased ${{ matrix.branch }} | |
if: env.NEEDS_REBASE == 'true' | |
uses: ad-m/github-push-action@master | |
with: | |
branch: ${{ matrix.branch }} | |
force: true |