Skip to content
Merged
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
8 changes: 4 additions & 4 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
# The basic usage is,
# clang-format -i -style=file PATH/TO/SOURCE/CODE
#
# The -style=file implicit use ".clang-format" file located in one of
# parent directory.
# The -style=file implicit use ".clang-format" file located in one of
# parent directory.
# The -i means inplace change.
#
# The document of clang-format is
# The document of clang-format is
# http://clang.llvm.org/docs/ClangFormat.html
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
---
Expand All @@ -20,7 +20,7 @@ IndentWidth: 2
TabWidth: 2
ContinuationIndentWidth: 4
AccessModifierOffset: -1 # The private/protected/public has no indent in class
Standard: Cpp11
Standard: Cpp11
AllowAllParametersOfDeclarationOnNextLine: true
BinPackParameters: false
BinPackArguments: false
Expand Down
26 changes: 26 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# EditorConfig is a cross-editor configuration file
# that helps to unify code styles for multiple
# developers collaborative projects.
# See more at https://editorconfig.org/

root = true

[*]
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{c,cc,cxx,cpp,cu,cuh,h,hpp,hxx,kps,yml,yaml}]
indent_size = 2

[*.{py,pyi,java,r,toml}]
indent_size = 4

[Dockerfile.*]
indent_size = 4

[*.go]
indent_style = tab
indent_size = 4
22 changes: 0 additions & 22 deletions .flake8

This file was deleted.

47 changes: 47 additions & 0 deletions .github/workflows/check-bypass.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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: '["SigureMo", "BingooYang", "yongqiangma"]'
outputs:
can-skip: ${{ steps.check-bypass.outputs.can-skip }}
steps:
- 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 }}
}
]
}
55 changes: 55 additions & 0 deletions .github/workflows/codestyle-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: codestyle-check

on:
pull_request:
branches: ["master"]

jobs:
check-bypass:
name: Check bypass
uses: ./.github/workflows/check-bypass.yml
with:
workflow-name: "codestyle"
secrets:
github-token: ${{ secrets.GITHUB_TOKEN }}

pre-commit:
name: Run pre-commit checks
needs: check-bypass
if: ${{ github.repository_owner == 'PFCCLab' && needs.check-bypass.outputs.can-skip != 'true' }}
runs-on: ubuntu-latest
env:
PR_ID: ${{ github.event.pull_request.number }}

steps:
- name: Checkout base repo
uses: actions/checkout@v6
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@v7
with:
python-version: "3.14"
enable-cache: true

- name: Install dependencies
run: |
uv venv -p 3.14
source .venv/bin/activate
uv pip install cpplint==1.6.0 clang-format==13.0.0

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

- name: Run prek
run: |
source .venv/bin/activate
prek run --all-files
123 changes: 55 additions & 68 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,90 +1,77 @@
repos:
# Common hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
# Common hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-merge-conflict
- id: check-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: trailing-whitespace
files: (.*\.(py|bzl|md|rst|c|cc|cxx|cpp|cu|h|hpp|hxx|xpu|kps|cmake|yaml|yml|hook|scpp)|BUILD|.*\.BUILD|WORKSPACE|CMakeLists\.txt)$
- repo: https://github.com/Lucas-C/pre-commit-hooks.git
rev: v1.1.14
- id: check-added-large-files
- id: check-merge-conflict
- id: check-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: sort-simple-yaml
files: (ops|backward|op_[a-z_]+)\.yaml$
- id: trailing-whitespace
- repo: https://github.com/Lucas-C/pre-commit-hooks.git
rev: v1.5.1
hooks:
- id: remove-crlf
- id: remove-tabs
- id: remove-crlf
- id: remove-tabs
name: Tabs remover (C++)
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|xpu|kps)$
files: \.(c|cc|cxx|cpp|cu|h|cuh|hpp|hxx|xpu|kps)$
args: [--whitespaces-count, '2']
- id: remove-tabs
- id: remove-tabs
name: Tabs remover (Python)
files: (.*\.(py|bzl)|BUILD|.*\.BUILD|WORKSPACE)$
args: [--whitespaces-count, '4']
# For Python files
- repo: https://github.com/psf/black.git
rev: 22.8.0
# For Python files
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.4
hooks:
- id: black
files: (.*\.(py|pyi|bzl)|BUILD|.*\.BUILD|WORKSPACE)$
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
- id: ruff-check
args: [--fix, --exit-non-zero-on-fix, --no-cache]
- id: ruff-format
# For C++ files
- repo: local
hooks:
- id: flake8
- repo: https://github.com/PyCQA/autoflake
rev: v1.7.7
hooks:
- id: autoflake
args:
- --in-place
- --remove-all-unused-imports
- --ignore-pass-after-docstring
- --ignore-init-module-imports
- --exclude=python/paddle/fluid/[!t]**,python/paddle/fluid/tra**
- repo: local
hooks:
- id: pylint-doc-string
name: pylint
description: Check python docstring style using docstring_checker.
entry: bash ./tools/codestyle/pylint_pre_commit.hook
language: system
files: \.(py)$
# For C++ files
- repo: local
hooks:
- id: clang-format
- id: clang-format
name: clang-format
description: Format files with ClangFormat.
entry: bash ./tools/codestyle/clang_format.hook -i
entry: bash ./tools/codestyle/clang_format.sh -i
language: system
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|xpu|kps|mm|m|scpp)$
- repo: local
files: \.(c|cc|cxx|cpp|cu|h|cuh|hpp|hxx|xpu|kps)$
- repo: local
hooks:
- id: cpplint-cpp-source
- id: cpplint-cpp-source
name: cpplint
description: Check C++ code style using cpplint.py.
entry: bash ./tools/codestyle/cpplint_pre_commit.hook
entry: bash ./tools/codestyle/cpplint_pre_commit.sh
language: system
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|scpp)$
files: \.(cc|cxx|cpp|cu|h|hpp|hxx)$
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an inconsistency in file patterns between clang-format and cpplint. The clang-format hook (line 41) includes '.c' and '.kps' files in its pattern, but cpplint (line 49) excludes them. Additionally, cpplint's extension arguments (line 51) include 'kps' but the file pattern doesn't match '.kps' files. Consider aligning these patterns to ensure consistent code style checking.

Suggested change
files: \.(cc|cxx|cpp|cu|h|hpp|hxx)$
files: \.(c|cc|cxx|cpp|cu|cuh|h|hpp|hxx|kps)$

Copilot uses AI. Check for mistakes.
args:
- --extensions=c,cc,cxx,cpp,cu,cuh,h,hpp,hxx,kps
- --filter=-readability/fn_size,-build/include_what_you_use,-build/c++11,-whitespace/parens,-legal/copyright
- --quiet
# For CMake files
- repo: local
hooks:
- id: auto-generate-cmakelists
name: auto-generate-cmakelists
entry: bash ./tools/gen_ut_cmakelists.hook
language: system
files: testslist.csv$
- repo: https://github.com/cheshirekow/cmake-format-precommit
- --extensions=cc,cxx,cpp,cu,cuh,h,hpp,hxx,kps
- --filter=-readability/fn_size,-build/include_what_you_use,-build/c++11,-whitespace/parens,-legal/copyright
- --quiet
# For CMake files
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
- repo: https://github.com/cmake-lint/cmake-lint
rev: 1.4.2
- id: cmake-format
- repo: https://github.com/PFCCLab/cmake-lint-paddle
rev: v1.5.1
hooks:
- id: cmakelint
- id: cmakelint
args: [--config=./tools/codestyle/.cmakelintrc]
# For YAML files
- repo: https://github.com/PFCCLab/yamlfmt-pre-commit-mirror.git
rev: v0.16.0
hooks:
- id: yamlfmt
files: |
(?x)^(
\.github/.+\.(yaml|yml)|
\.pre-commit-config\.yaml|
\.yamlfmt|
sgconfig\.yml|
ci/rules/.+\.yml|
ci/rule-tests/.+\.yml
)
3 changes: 0 additions & 3 deletions .style.yapf

This file was deleted.

5 changes: 5 additions & 0 deletions .yamlfmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
formatter:
indent: 2
type: basic
retain_line_breaks: true
scan_folded_as_literal: true
Loading