[Tool] Optimize the approval strategy for branch merging (#59196)

Signed-off-by: AndyZiYe <yeziyu@starrocks.com>
This commit is contained in:
andyziye 2025-05-21 18:18:13 +08:00 committed by GitHub
parent 88ff064da2
commit 2aaebfac37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 35 additions and 48 deletions

View File

@ -116,26 +116,3 @@ jobs:
run: |
rm -rf ./ci-tool && cp -rf /var/lib/ci-tool ./ci-tool && cd ci-tool && git pull >/dev/null
./scripts/check-approve.sh
feature-enhancement-backport-review:
needs: info
runs-on: [ self-hosted, normal ]
if: >
github.event_name == 'pull_request_review' &&
needs.info.outputs.BASE_REF != 'main' &&
!contains(needs.info.outputs.LABELS, 'sync') &&
(startsWith(needs.info.outputs.TITLE, '[Feature]') || startsWith(needs.info.outputs.TITLE, '[Enhancement]')) &&
needs.info.outputs.DIFF_LINES > 100
name: FEATURE-ENHANCEMENT-BACKPORT-REVIEW
env:
PR_NUMBER: ${{ needs.info.outputs.PR_NUMBER }}
REPO: ${{ github.repository }}
TEAM: feature-reviewer
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: APPROVE-REVIEW
run: |
rm -rf ./ci-tool && cp -rf /var/lib/ci-tool ./ci-tool && cd ci-tool && git pull >/dev/null
./scripts/check-approve.sh

View File

@ -73,19 +73,24 @@ jobs:
esac
- name: Checkout code
id: checkout_code
if: github.base_ref != 'main'
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
ref: refs/pull/${{ github.event.pull_request.number }}/head
- name: Checkout PR
id: checkout_pr
if: steps.checkout_code.outcome == 'success'
run: |
git remote add upstream https://github.com/${{ github.event.pull_request.base.repo.full_name }}.git
git fetch upstream
git merge upstream/${{ github.event.pull_request.base.ref }} --no-edit
- name: Branch Access Check
id: branch_access_check
if: steps.checkout_pr.outcome =='success'
env:
PR_TITLE: ${{ steps.get_title.outputs.PR_TITLE }}
run: |
@ -101,9 +106,17 @@ jobs:
else
exit 0
fi
echo "check_res=false" >> $GITHUB_OUTPUT
echo "comment=${comment}" >> $GITHUB_OUTPUT
echo "::error::${comment}"
exit 1
- name: Check Approve
if: steps.branch_access_check.outputs.check_res == 'false'
env:
TEAM: feature-reviewer
PRE_COMMENT: ${{ steps.branch_access_check.outputs.comment }}
run: |
cd ci-tool
./scripts/check-approve.sh
be-checker:
runs-on: ubuntu-latest

View File

@ -87,19 +87,24 @@ jobs:
esac
- name: Checkout code
id: checkout_code
if: github.base_ref != 'main'
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
ref: refs/pull/${{ github.event.pull_request.number }}/head
- name: Checkout PR
id: checkout_pr
if: steps.checkout_code.outcome == 'success'
run: |
git remote add upstream https://github.com/${{ github.event.pull_request.base.repo.full_name }}.git
git fetch upstream
git merge upstream/${{ github.event.pull_request.base.ref }} --no-edit
- name: Branch Access Check
id: branch_access_check
if: steps.checkout_pr.outcome =='success'
env:
PR_TITLE: ${{ steps.get_title.outputs.PR_TITLE }}
run: |
@ -115,9 +120,18 @@ jobs:
else
exit 0
fi
echo "check_res=false" >> $GITHUB_OUTPUT
echo "comment=${comment}" >> $GITHUB_OUTPUT
echo "::error::${comment}"
exit 1
- name: Check Approve
if: steps.branch_access_check.outputs.check_res == 'false'
env:
REPO: ${{ github.repository }}
TEAM: feature-reviewer
PRE_COMMENT: ${{ steps.branch_access_check.outputs.comment }}
run: |
cd ci-tool
./scripts/check-approve.sh
be-checker:
runs-on: ubuntu-latest

View File

@ -255,20 +255,3 @@ jobs:
run: |
rm -rf ./ci-tool && cp -rf /var/lib/ci-tool ./ci-tool && cd ci-tool && git pull && source lib/init.sh
./bin/check-pr-changelist.sh
backport-feature-enhancement-check:
runs-on: [ self-hosted, normal ]
needs: sync-checker
if: >
github.event.action != 'synchronize' &&
github.base_ref != 'main' &&
(startsWith(github.event.pull_request.title, '[Feature]') || startsWith(github.event.pull_request.title, '[Enhancement]')) &&
!contains(github.event.pull_request.labels.*.name, 'backport_approval')
env:
PR_NUMBER: ${{ github.event.number }}
GH_TOKEN: ${{ secrets.PAT }}
steps:
- name: CHECK NECESSARY
run: |
rm -rf ./ci-tool && cp -rf /var/lib/ci-tool ./ci-tool && cd ci-tool && git pull && source lib/init.sh
./bin/check-pr-backport-review-necessary.sh