Skip to content

Commit 4b14474

Browse files
Merge branch 'develop' into fix1009
2 parents 2d1d1a3 + a6c6cf8 commit 4b14474

File tree

7 files changed

+124
-97
lines changed

7 files changed

+124
-97
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Paddle API Docs
2+
docs/api/paddle @jzhang533 @sunzhongkai588 @mattheliu

.github/workflows/check-bypass.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
workflow-name:
5+
required: true
6+
type: string
7+
secrets:
8+
github-token:
9+
required: true
10+
outputs:
11+
can-skip:
12+
description: "Whether the workflow can be skipped."
13+
value: ${{ jobs.check-bypass.outputs.can-skip }}
14+
15+
jobs:
16+
check-bypass:
17+
name: Check bypass
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
env:
22+
CI_TEAM_MEMBERS: '["tianshuo78520a", "swgu98", "risemeup1", "luotao1", "SigureMo", "ooooo-create"]'
23+
outputs:
24+
can-skip: ${{ steps.check-bypass.outputs.can-skip }}
25+
steps:
26+
- name: Cleanup
27+
run: |
28+
rm -rf * .[^.]*
29+
30+
- id: check-bypass
31+
name: Check Bypass
32+
uses: PFCCLab/ci-bypass@v2
33+
with:
34+
github-token: ${{ secrets.GITHUB_TOKEN }}
35+
non-pull-request-event-strategy: "never-skipped"
36+
type: "composite"
37+
composite-rule: |
38+
{
39+
"any": [
40+
{
41+
"type": "labeled",
42+
"label": ["skip-ci: ${{ inputs.workflow-name }}", "skip-ci: all"],
43+
"username": ${{ env.CI_TEAM_MEMBERS }}
44+
},
45+
{
46+
"type": "commented",
47+
"comment-pattern": [".*/skip-ci ${{ inputs.workflow-name }}.*", ".*/skip-ci all.*"],
48+
"username": ${{ env.CI_TEAM_MEMBERS }}
49+
}
50+
]
51+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Codestyle Check
2+
3+
on:
4+
pull_request:
5+
branches: ["develop"]
6+
7+
jobs:
8+
check-bypass:
9+
name: Check bypass
10+
if: ${{ inputs.can-skip != 'true' }}
11+
uses: ./.github/workflows/check-bypass.yml
12+
with:
13+
workflow-name: "codestyle"
14+
secrets:
15+
github-token: ${{ secrets.GITHUB_TOKEN }}
16+
17+
check-codestyle:
18+
name: Run codestyle check
19+
needs: check-bypass
20+
if: ${{ github.repository_owner == 'PaddlePaddle' && needs.check-bypass.outputs.can-skip != 'true' }}
21+
runs-on: ubuntu-latest
22+
env:
23+
PR_ID: ${{ github.event.pull_request.number }}
24+
BRANCH: develop
25+
26+
steps:
27+
- name: Cleanup
28+
run: |
29+
rm -rf * .[^.]*
30+
31+
- name: Checkout base repo
32+
uses: actions/checkout@v4
33+
with:
34+
ref: ${{ github.event.pull_request.base.ref }}
35+
fetch-depth: 200
36+
37+
- name: Merge PR to test branch
38+
run: |
39+
git fetch origin pull/${PR_ID}/merge
40+
git checkout -b test FETCH_HEAD
41+
42+
- name: Install uv
43+
uses: astral-sh/setup-uv@v6
44+
with:
45+
python-version: "3.13"
46+
enable-cache: true
47+
48+
- name: Install prek
49+
run: |
50+
uv tool install prek
51+
52+
- name: Run prek
53+
run: |
54+
set +e
55+
bash -x ci_scripts/check_code.sh;EXCODE=$?
56+
exit $EXCODE

ci_scripts/check_code.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,22 @@ set +x
2222
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
2323
cd $SCRIPT_DIR/..
2424

25-
# use pre-commit 2.17
26-
if ! [[ $(pre-commit --version) == *"2.17.0"* ]]; then
27-
pip install pre-commit==2.17.0 1>nul
28-
fi
29-
3025
diff_files=$(git diff --name-only --diff-filter=ACMR ${BRANCH})
3126
num_diff_files=$(echo "$diff_files" | wc -l)
3227
echo -e "diff files between pr and ${BRANCH}:\n${diff_files}"
3328

29+
PRE_COMMIT_EXE="pre-commit"
30+
# Use prek to replace pre-commit if prek is installed
31+
if command -v prek &> /dev/null
32+
then
33+
echo "Detected prek, use prek to check code style for better performance."
34+
PRE_COMMIT_EXE="prek"
35+
else
36+
echo "prek not found, use pre-commit to check code style."
37+
fi
38+
3439
echo "Checking code style by pre-commit ..."
35-
pre-commit run --files ${diff_files};check_error=$?
40+
$PRE_COMMIT_EXE run --files ${diff_files};check_error=$?
3641

3742
if test ! -z "$(git diff)"; then
3843
echo -e '\n************************************************************************************'
@@ -47,7 +52,7 @@ if [ ${check_error} != 0 ];then
4752
echo "Your PR code style check failed."
4853
echo "Please install pre-commit locally and set up git hook scripts:"
4954
echo ""
50-
echo " pip install pre-commit==2.17.0"
55+
echo " pip install pre-commit"
5156
echo " pre-commit install"
5257
echo ""
5358
if [[ $num_diff_files -le 100 ]];then

ci_scripts/check_pr_approval.py

Lines changed: 0 additions & 48 deletions
This file was deleted.

ci_scripts/checkapproval.sh

Lines changed: 0 additions & 27 deletions
This file was deleted.

ci_scripts/ci_start.sh

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,11 @@ else
102102
fi
103103

104104
EXIT_CODE=0
105-
# 3 check code style/format.
106-
ls ${DIR_PATH}
107-
/bin/bash -x ${DIR_PATH}/check_code.sh
108-
if [ $? -ne 0 ];then
109-
EXIT_CODE=1
110-
fi
111105

112106
git merge --no-edit upstream/${BRANCH}
113107
need_check_cn_doc_files=$(find_all_cn_api_files_modified_by_pr)
114108
echo $need_check_cn_doc_files
115-
# 4 Chinese api docs check
109+
# 3 Chinese api docs check
116110
if [ "${need_check_cn_doc_files}" = "" ] ; then
117111
echo "chinese api doc fileslist is empty, skip check."
118112
else
@@ -127,7 +121,7 @@ else
127121
fi
128122
fi
129123

130-
# 5 Chinese api_label check
124+
# 4 Chinese api_label check
131125
/bin/bash -x ${DIR_PATH}/check_api_label_cn.sh
132126
if [ $? -ne 0 ];then
133127
set +x
@@ -141,18 +135,12 @@ fi
141135
if [ ${EXIT_CODE} -ne 0 ]; then
142136
set +x
143137
echo "=========================================================================================="
144-
echo "Code style check or API Chinese doc check failed! Please check the error info above carefully."
138+
echo "API Chinese doc check failed! Please check the error info above carefully."
145139
echo "=========================================================================================="
146140
set -x
147141
exit ${EXIT_CODE}
148142
fi
149143

150-
# 6 Approval check
151-
/bin/bash ${DIR_PATH}/checkapproval.sh
152-
if [ $? -ne 0 ];then
153-
exit 1
154-
fi
155-
156144
echo "PADDLE_WHL=${PADDLE_WHL}"
157145
# print preview url
158146
echo "${PREVIEW_URL_PROMPT}"

0 commit comments

Comments
 (0)