[Tool] Add the limit on merging feature/enhancement prs on branches (#57278)
This commit is contained in:
parent
2787b44ddc
commit
90c5fc36dc
|
|
@ -31,9 +31,13 @@ jobs:
|
|||
REPO: ${{ github.repository }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
outputs:
|
||||
LABELS: ${{ steps.label_info.outputs.labels }}
|
||||
PR_NUMBER: ${{ steps.pr.outputs.PR_NUMBER }}
|
||||
HEAD_REF: ${{ steps.pr.outputs.HEAD_REF }}
|
||||
BASE_REF: ${{ steps.pr.outputs.BASE_REF }}
|
||||
TITLE: ${{ steps.pr_info.outputs.title }}
|
||||
LABELS: ${{ steps.pr_info.outputs.labels }}
|
||||
DIFF_LINES: ${{ steps.pr_info.outputs.diff_lines }}
|
||||
|
||||
|
||||
steps:
|
||||
- name: PR
|
||||
|
|
@ -44,24 +48,39 @@ jobs:
|
|||
else
|
||||
echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
|
||||
echo "HEAD_REF=${{ github.event.pull_request.head.ref }}" >> $GITHUB_OUTPUT
|
||||
echo "BASE_REF=${{ github.event.pull_request.base.ref }}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: LABELS
|
||||
id: label_info
|
||||
- name: INFO
|
||||
id: pr_info
|
||||
env:
|
||||
PR_NUMBER: ${{ steps.pr.outputs.PR_NUMBER }}
|
||||
run: |
|
||||
labels=$(gh pr view ${PR_NUMBER} -R ${REPO} --json labels -q '.labels[].name')
|
||||
pr_info=$(gh pr view ${PR_NUMBER} -R ${REPO} --json labels,title,files)
|
||||
labels=$(echo ${pr_info} | jq -r '.labels[].name')
|
||||
title=$(echo ${pr_info} | jq -r '.title')
|
||||
diff_lines=$(echo ${pr_info} | jq -r '([.files[].additions, .files[].deletions] | add)')
|
||||
|
||||
echo "diff_lines=${diff_lines}" >> $GITHUB_OUTPUT
|
||||
|
||||
echo "labels<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "$labels" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
|
||||
echo "title<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "${title}" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
|
||||
cat $GITHUB_OUTPUT
|
||||
|
||||
meta-review:
|
||||
needs: info
|
||||
runs-on: [ self-hosted, normal ]
|
||||
if: github.event_name == 'pull_request_review' && contains(needs.info.outputs.LABELS, 'META-REVIEW') && !contains(needs.info.outputs.LABELS, 'sync') && !startsWith(needs.info.outputs.HEAD_REF, 'mergify/')
|
||||
if: >
|
||||
github.event_name == 'pull_request_review' &&
|
||||
contains(needs.info.outputs.LABELS, 'META-REVIEW') &&
|
||||
!contains(needs.info.outputs.LABELS, 'sync') &&
|
||||
!startsWith(needs.info.outputs.HEAD_REF, 'mergify/')
|
||||
name: META-REVIEW
|
||||
|
||||
env:
|
||||
|
|
@ -79,7 +98,11 @@ jobs:
|
|||
proto-review:
|
||||
needs: info
|
||||
runs-on: [ self-hosted, normal ]
|
||||
if: github.event_name == 'pull_request_review' && contains(needs.info.outputs.LABELS, 'PROTO-REVIEW') && !contains(needs.info.outputs.LABELS, 'sync') && !startsWith(needs.info.outputs.HEAD_REF, 'mergify/')
|
||||
if: >
|
||||
github.event_name == 'pull_request_review' &&
|
||||
contains(needs.info.outputs.LABELS, 'PROTO-REVIEW') &&
|
||||
!contains(needs.info.outputs.LABELS, 'sync') &&
|
||||
!startsWith(needs.info.outputs.HEAD_REF, 'mergify/')
|
||||
name: PROTO-REVIEW
|
||||
|
||||
env:
|
||||
|
|
@ -93,3 +116,26 @@ 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
|
||||
|
|
|
|||
|
|
@ -64,7 +64,11 @@ jobs:
|
|||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: ${{ env.COMMIT_ID }}
|
||||
ref: ${{ env.BASE_REF }}
|
||||
|
||||
- name: checkout commit
|
||||
run: |
|
||||
git reset ${{ env.COMMIT_ID }} --hard
|
||||
|
||||
- name: Download BE UT XML
|
||||
id: download-ut-xml
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ jobs:
|
|||
title-check:
|
||||
runs-on: ubuntu-latest
|
||||
needs: sync-checker
|
||||
if: >
|
||||
!startsWith(github.event.pull_request.title, 'Revert ')
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
PR_NUMBER: ${{ github.event.number }}
|
||||
|
|
@ -85,9 +87,11 @@ jobs:
|
|||
|
||||
if [[ "${GITHUB_HEAD_REF}" == "mergify/bp/"* && "${BACKPORT_SOURCE_PR}" != "" ]]; then
|
||||
gh pr view ${BACKPORT_SOURCE_PR} -R ${REPO} --json body -q .body > source_body.txt
|
||||
sed -ie '/Bugfix cherry-pick branch check/,$d' source_body.txt
|
||||
cat source_body.txt > tmp_body.txt
|
||||
mv tmp_body.txt body.txt
|
||||
if grep -q 'Bugfix cherry-pick branch check'; then
|
||||
sed -ie '/Bugfix cherry-pick branch check/,$d' source_body.txt
|
||||
cat source_body.txt > tmp_body.txt
|
||||
mv tmp_body.txt body.txt
|
||||
fi
|
||||
fi
|
||||
|
||||
sed -i "s#\[ \] This is a backport pr#\[x\] This is a backport pr#g" body.txt
|
||||
|
|
@ -106,10 +110,9 @@ jobs:
|
|||
exit 1
|
||||
fi
|
||||
|
||||
- name: update body
|
||||
- name: check backport option
|
||||
if: >
|
||||
github.base_ref != 'main' && github.event.action != 'opened' &&
|
||||
!contains(github.event.pull_request.title, 'Revert') &&
|
||||
!contains(toJson(github.event.pull_request.body), '[x] This is a backport pr') &&
|
||||
!contains(toJson(github.event.pull_request.body), '[ ] This is a backport pr')
|
||||
|
||||
|
|
@ -121,12 +124,12 @@ jobs:
|
|||
needs: title-check
|
||||
runs-on: ubuntu-latest
|
||||
if: >
|
||||
(startsWith(github.event.pull_request.title, '[BugFix]') ||
|
||||
startsWith(github.event.pull_request.title, '[Enhancement]') ||
|
||||
startsWith(github.event.pull_request.title, '[Doc]') ||
|
||||
startsWith(github.event.pull_request.title, '[UT]')) &&
|
||||
!contains(github.event.pull_request.title, 'cherry-pick') &&
|
||||
!contains(github.event.pull_request.title, 'backport')
|
||||
(
|
||||
startsWith(github.event.pull_request.title, '[BugFix]') ||
|
||||
startsWith(github.event.pull_request.title, '[Enhancement]') ||
|
||||
startsWith(github.event.pull_request.title, '[Doc]') ||
|
||||
startsWith(github.event.pull_request.title, '[UT]')
|
||||
) && !contains(github.event.pull_request.title, 'cherry-pick') && !contains(github.event.pull_request.title, 'backport')
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
|
@ -164,6 +167,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
if: >
|
||||
!startsWith(github.event.pull_request.title, '[Doc]') &&
|
||||
!startsWith(github.event.pull_request.title, 'Revert ') &&
|
||||
(github.base_ref == 'main' || !startsWith(github.head_ref, 'mergify/bp/') || github.event.action != 'opened')
|
||||
steps:
|
||||
- name: Format Check
|
||||
|
|
@ -251,3 +255,20 @@ 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
|
||||
|
|
|
|||
Loading…
Reference in New Issue