Feat/balancer swap #3228
This file contains hidden or 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
| name: Require Clean Merges | |
| on: | |
| pull_request: | |
| branches: | |
| - devnet-ready | |
| - devnet | |
| - testnet | |
| jobs: | |
| assert-clean-merges: | |
| runs-on: [self-hosted, type-ccx13] | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Ensures we get all branches for merging | |
| - name: Determine Target Branch and Set Merge List | |
| id: set-merge-branches | |
| run: | | |
| TARGET_BRANCH="${{ github.event.pull_request.base.ref }}" | |
| PR_BRANCH="${{ github.event.pull_request.head.ref }}" | |
| echo "PR_BRANCH=$PR_BRANCH" >> $GITHUB_ENV | |
| if [[ "$TARGET_BRANCH" == "devnet-ready" ]]; then | |
| echo "MERGE_BRANCHES=devnet testnet main" >> $GITHUB_ENV | |
| elif [[ "$TARGET_BRANCH" == "devnet" ]]; then | |
| echo "MERGE_BRANCHES=testnet main" >> $GITHUB_ENV | |
| elif [[ "$TARGET_BRANCH" == "testnet" ]]; then | |
| echo "MERGE_BRANCHES=main" >> $GITHUB_ENV | |
| elif [[ "$TARGET_BRANCH" == "main" ]]; then | |
| echo "MERGE_BRANCHES=" >> $GITHUB_ENV # No need to merge anything into main | |
| else | |
| echo "MERGE_BRANCHES=devnet-ready devnet testnet main" >> $GITHUB_ENV | |
| fi | |
| - name: Add Fork Remote and Fetch PR Branch | |
| if: github.event.pull_request.head.repo.fork == true | |
| run: | | |
| PR_BRANCH="${{ github.event.pull_request.head.ref }}" | |
| PR_FORK="${{ github.event.pull_request.head.repo.clone_url }}" | |
| git remote add fork $PR_FORK | |
| git fetch --no-tags --prune fork $PR_BRANCH | |
| - name: Check Merge Cleanliness | |
| run: | | |
| TARGET_BRANCH="${{ github.event.pull_request.base.ref }}" | |
| PR_BRANCH="${{ github.event.pull_request.head.ref }}" | |
| echo "Fetching all branches..." | |
| git fetch --all --prune | |
| if [[ "${{github.event.pull_request.head.repo.fork}}" == "true" ]]; then | |
| PR_BRANCH_REF="fork/$PR_BRANCH" | |
| echo "Using fork reference: $PR_BRANCH_REF" | |
| else | |
| PR_BRANCH_REF="origin/$PR_BRANCH" | |
| echo "Using origin reference: $PR_BRANCH_REF" | |
| fi | |
| echo "Checking out PR branch: $PR_BRANCH" | |
| git checkout $PR_BRANCH_REF | |
| git reset --hard $PR_BRANCH_REF | |
| # Configure a temporary Git identity to allow merging | |
| git config --local user.email "[email protected]" | |
| git config --local user.name "GitHub Actions" | |
| for branch in $MERGE_BRANCHES; do | |
| echo "Checking merge from $branch into $PR_BRANCH_REF..." | |
| # Ensure PR branch is up to date | |
| git reset --hard $PR_BRANCH_REF | |
| # Merge without committing to check for conflicts | |
| if git merge --no-commit --no-ff origin/$branch; then | |
| echo "✅ Merge from $branch into $PR_BRANCH_REF is clean." | |
| else | |
| echo "❌ Merge conflict detected when merging $branch into $PR_BRANCH_REF" | |
| exit 1 | |
| fi | |
| # Abort merge if one was started, suppressing errors if no merge happened | |
| git merge --abort 2>/dev/null || true | |
| done |