Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Paddle API Docs
docs/api/paddle @jzhang533 @sunzhongkai588 @mattheliu
51 changes: 51 additions & 0 deletions .github/workflows/check-bypass.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
on:
workflow_call:
inputs:
workflow-name:
required: true
type: string
secrets:
github-token:
required: true
outputs:
can-skip:
description: "Whether the workflow can be skipped."
value: ${{ jobs.check-bypass.outputs.can-skip }}

jobs:
check-bypass:
name: Check bypass
runs-on: ubuntu-latest
permissions:
contents: read
env:
CI_TEAM_MEMBERS: '["tianshuo78520a", "swgu98", "risemeup1", "XieYunshen", "luotao1"]'
outputs:
can-skip: ${{ steps.check-bypass.outputs.can-skip }}
steps:
- name: Cleanup
run: |
rm -rf * .[^.]*

- id: check-bypass
name: Check Bypass
uses: PFCCLab/ci-bypass@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
non-pull-request-event-strategy: "never-skipped"
type: "composite"
composite-rule: |
{
"any": [
{
"type": "labeled",
"label": ["skip-ci: ${{ inputs.workflow-name }}", "skip-ci: all"],
"username": ${{ env.CI_TEAM_MEMBERS }}
},
{
"type": "commented",
"comment-pattern": [".*/skip-ci ${{ inputs.workflow-name }}.*", ".*/skip-ci all.*"],
"username": ${{ env.CI_TEAM_MEMBERS }}
}
]
}
56 changes: 56 additions & 0 deletions .github/workflows/codestyle-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Codestyle Check

on:
pull_request:
branches: ["develop"]

jobs:
check-bypass:
name: Check bypass
if: ${{ inputs.can-skip != 'true' }}
uses: ./.github/workflows/check-bypass.yml
with:
workflow-name: "codestyle"
secrets:
github-token: ${{ secrets.GITHUB_TOKEN }}

check-codestyle:
name: Run codestyle check
needs: check-bypass
if: ${{ github.repository_owner == 'PaddlePaddle' && needs.check-bypass.outputs.can-skip != 'true' }}
runs-on: ubuntu-latest
env:
PR_ID: ${{ github.event.pull_request.number }}
BRANCH: develop

steps:
- name: Cleanup
run: |
rm -rf * .[^.]*

- name: Checkout base repo
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.ref }}
fetch-depth: 200

- name: Merge PR to test branch
run: |
git fetch origin pull/${PR_ID}/merge
git checkout -b test FETCH_HEAD

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
python-version: "3.13"
enable-cache: true

- name: Install prek
run: |
uv tool install prek

- name: Run prek
run: |
set +e
bash -x ci_scripts/check_code.sh;EXCODE=$?
exit $EXCODE
19 changes: 12 additions & 7 deletions ci_scripts/check_code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,22 @@ set +x
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
cd $SCRIPT_DIR/..

# use pre-commit 2.17
if ! [[ $(pre-commit --version) == *"2.17.0"* ]]; then
pip install pre-commit==2.17.0 1>nul
fi

diff_files=$(git diff --name-only --diff-filter=ACMR ${BRANCH})
num_diff_files=$(echo "$diff_files" | wc -l)
echo -e "diff files between pr and ${BRANCH}:\n${diff_files}"

PRE_COMMIT_EXE="pre-commit"
# Use prek to replace pre-commit if prek is installed
if command -v prek &> /dev/null
then
echo "Detected prek, use prek to check code style for better performance."
PRE_COMMIT_EXE="prek"
else
echo "prek not found, use pre-commit to check code style."
fi

echo "Checking code style by pre-commit ..."
pre-commit run --files ${diff_files};check_error=$?
$PRE_COMMIT_EXE run --files ${diff_files};check_error=$?

if test ! -z "$(git diff)"; then
echo -e '\n************************************************************************************'
Expand All @@ -47,7 +52,7 @@ if [ ${check_error} != 0 ];then
echo "Your PR code style check failed."
echo "Please install pre-commit locally and set up git hook scripts:"
echo ""
echo " pip install pre-commit==2.17.0"
echo " pip install pre-commit"
echo " pre-commit install"
echo ""
if [[ $num_diff_files -le 100 ]];then
Expand Down
27 changes: 0 additions & 27 deletions ci_scripts/checkapproval.sh

This file was deleted.

18 changes: 3 additions & 15 deletions ci_scripts/ci_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,11 @@ else
fi

EXIT_CODE=0
# 3 check code style/format.
ls ${DIR_PATH}
/bin/bash -x ${DIR_PATH}/check_code.sh
if [ $? -ne 0 ];then
EXIT_CODE=1
fi

git merge --no-edit upstream/${BRANCH}
need_check_cn_doc_files=$(find_all_cn_api_files_modified_by_pr)
echo $need_check_cn_doc_files
# 4 Chinese api docs check
# 3 Chinese api docs check
if [ "${need_check_cn_doc_files}" = "" ] ; then
echo "chinese api doc fileslist is empty, skip check."
else
Expand All @@ -127,7 +121,7 @@ else
fi
fi

# 5 Chinese api_label check
# 4 Chinese api_label check
/bin/bash -x ${DIR_PATH}/check_api_label_cn.sh
if [ $? -ne 0 ];then
set +x
Expand All @@ -141,18 +135,12 @@ fi
if [ ${EXIT_CODE} -ne 0 ]; then
set +x
echo "=========================================================================================="
echo "Code style check or API Chinese doc check failed! Please check the error info above carefully."
echo "API Chinese doc check failed! Please check the error info above carefully."
echo "=========================================================================================="
set -x
exit ${EXIT_CODE}
fi

# 6 Approval check
/bin/bash ${DIR_PATH}/checkapproval.sh
if [ $? -ne 0 ];then
exit 1
fi

echo "PADDLE_WHL=${PADDLE_WHL}"
# print preview url
echo "${PREVIEW_URL_PROMPT}"
Expand Down
Loading