1name: Check mergeability of ghstack PR 2 3on: 4 pull_request: 5 types: [opened, synchronize, reopened] 6 branches: [gh/**/base] 7 8jobs: 9 ghstack-mergeability-check: 10 runs-on: ubuntu-latest 11 steps: 12 - uses: actions/checkout@v4 13 with: 14 fetch-depth: 0 15 16 - name: Setup git 17 shell: bash 18 run: | 19 git config --global user.email "pytorchmergebot@users.noreply.github.com" 20 git config --global user.name "PyTorch MergeBot" 21 git fetch origin main:main 22 23 - name: Wait for orig branch 24 shell: bash 25 run: | 26 BRANCH="${{ github.base_ref }}" 27 echo "$BRANCH" 28 BRANCH="${BRANCH%/base}/orig" 29 echo "$BRANCH" 30 31 WAIT_SECONDS=300 32 END_WAIT=$((SECONDS+WAIT_SECONDS)) 33 BRANCH_EXISTS=0 34 35 while [ $SECONDS -lt $END_WAIT ]; do 36 git fetch --prune origin "${BRANCH}" || true 37 if git rev-parse --verify "origin/${BRANCH}"; then 38 BRANCH_EXISTS=1 39 break 40 fi 41 echo "Waiting for branch ${BRANCH} to exist..." 42 sleep 30 # Wait for 30 seconds before retrying 43 done 44 45 if [ $BRANCH_EXISTS -eq 0 ]; then 46 echo "Branch ${BRANCH} not found after ${WAIT_SECONDS} seconds." 47 echo "Mergeability check failed for infrastructure reasons." 48 exit 1 49 fi 50 51 - name: Setup Python 52 uses: actions/setup-python@v4 53 with: 54 python-version: '3.8' 55 cache: pip 56 architecture: x64 57 58 - run: pip install pyyaml==6.0 rockset==1.0.3 59 shell: bash 60 61 - name: Verify mergeability 62 shell: bash 63 env: 64 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 65 PR_NUM: ${{ github.event.pull_request.number }} 66 run: | 67 set -ex 68 python3 .github/scripts/trymerge.py --check-mergeability "${PR_NUM}" 69 70 - name: Print debug info 71 if: failure() 72 shell: bash 73 env: 74 PR_NUM: ${{ github.event.pull_request.number }} 75 run: | 76 { 77 echo "# PR $PR_NUM is not mergeable into main" 78 echo "To debug, run the diagnostic workflow:" 79 echo "https://github.com/pytorch/test-infra/actions/workflows/pr-dependencies-check.yml" 80 } >> "$GITHUB_STEP_SUMMARY" 81 82 83concurrency: 84 group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }} 85 cancel-in-progress: true