Skip to content

Sync with upstream #214

Sync with upstream

Sync with upstream #214

Workflow file for this run

on:
schedule:
# 1:05 past midnight UTC
- cron: "5 1 * * *"
name: "Sync with upstream"
jobs:
sync:
name: "Sync"
runs-on: "ubuntu-latest"
env:
DEFAULT_BRANCH: "main"
steps:
# https://github.com/actions/runner-images/issues/2840#issuecomment-790492173
- name: "Free up disk space"
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: "Checkout source code"
uses: "actions/checkout@v3"
with:
# Subsequent actions are not triggered unless using PAT
token: "${{ secrets.GH_PAT }}"
fetch-depth: 0
submodules: true
- name: "Setup Rust toolchain"
uses: "actions-rs/toolchain@v1"
with:
toolchain: "stable"
profile: "minimal"
- name: "Setup Golang toolchain"
uses: "actions/setup-go@v4"
with:
go-version: "1.21"
- name: "Config Git"
run: |
git config user.name "Jonathan LEI"
git config user.email "[email protected]"
- name: "Update branch"
run: |
git fetch origin
git remote add upstream https://github.com/NethermindEth/juno
git fetch upstream --no-tags
MERGE_BASE=$(git merge-base origin/$DEFAULT_BRANCH upstream/$DEFAULT_BRANCH)
# Don't force push unnecessarily unless changes are detected
if [[ $(git rev-list $MERGE_BASE..upstream/$DEFAULT_BRANCH | wc -l) -ne 0 ]]; then
# Brings files from `home` to default branch
git checkout $DEFAULT_BRANCH
git reset --hard upstream/$DEFAULT_BRANCH
git checkout origin/home .
# Remove unwanted workflows
rm ./.github/workflows/docker-image-build-push.yml
rm ./.github/workflows/build-and-deploy.yml
rm ./.github/workflows/sync_first_100_blocks_smoke_test.yml
git add .
git commit -m "chore: README and CI changes"
# Here, we pick commits on the default branch except the first one. We do this instead
# of a naive rebase because the `home` branch might have changed, causing merge
# conflicts.
COMMIT_COUNT=$(git rev-list $MERGE_BASE..origin/$DEFAULT_BRANCH | wc -l)
git cherry-pick origin/$DEFAULT_BRANCH~$(($COMMIT_COUNT-1))..origin/$DEFAULT_BRANCH
# Install build dependency
sudo apt-get update
sudo apt-get install -y libjemalloc-dev
# Makes sure the updated local branch builds
make juno
# Push updated branch
git push --force-with-lease
else
echo "No changes detected on upstream $DEFAULT_BRANCH"
fi