Skip to content

Commit

Permalink
Create clang-tidy CI (microsoft#12653)
Browse files Browse the repository at this point in the history
Update clang-tidy config to prepare for creating a CI workflow to run
clang-tidy.
Added clangtidy check in CI

Co-authored-by: Edward Chen <[email protected]>
  • Loading branch information
justinchuby and edgchen1 authored Sep 30, 2022
1 parent 5f1bc8f commit 402e199
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 27 deletions.
84 changes: 57 additions & 27 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,30 +1,60 @@
---
# turn off readability-braces-around-statements to allow single line statement like 'if (x == y) doSomething();'
Checks: '-*,cppcoreguidelines-*,google-*,readability-*,modernize-*,-readability-braces-around-statements,-google-runtime-references,-cppcoreguidelines-pro-type-reinterpret-cast'
WarningsAsErrors: ''

# NOTE:
# The check is a multiline string here. Comment must not be moved into the string.
# Be sure to keep the disabled rules alphabetically sorted.
#
# Checks that are turned off:
#
# -cppcoreguidelines-macro-usage: There are a lot of false-positives like Function-like macro 'Foo' used; consider a 'constexpr' template function
# -cppcoreguidelines-pro-type-reinterpret-cast: Originally turned off.
# -google-readability-todo: Not enforced.
# -google-runtime-references: https://github.com/microsoft/onnxruntime/blob/main/docs/Coding_Conventions_and_Standards.md#c-code-style.
# -modernize-concat-nested-namespaces: We don't use it.
# -modernize-use-trailing-return-type: Stylistic preference we do not enforce.
# -readability-identifier-length: A lot of numerical code rely on short names to improve readability.
# -readability-uppercase-literal-suffix: We accept lowercase suffixes

Checks: >
-*,
cppcoreguidelines-*,
google-*,
readability-*,
modernize-*,
bugprone-*,
performance-*,
misc-*,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-pro-type-reinterpret-cast,
-google-readability-todo,
-google-runtime-references,
-modernize-concat-nested-namespaces,
-modernize-use-trailing-return-type,
-readability-identifier-length,
-readability-uppercase-literal-suffix,
WarningsAsErrors: ""
HeaderFilterRegex: '.*onnxruntime\/core\/.*'
AnalyzeTemporaryDtors: false
FormatStyle: none
CheckOptions:
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: google
- key: modernize-replace-auto-ptr.IncludeStyle
value: google
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
...

FormatStyle: none
CheckOptions:
- key: google-readability-braces-around-statements.ShortStatementLines
value: "1"
- key: google-readability-function-size.StatementThreshold
value: "800"
- key: google-readability-namespace-comments.ShortNamespaceLines
value: "10"
- key: google-readability-namespace-comments.SpacesBeforeComments
value: "2"
- key: modernize-loop-convert.MaxCopySize
value: "16"
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: google
- key: modernize-replace-auto-ptr.IncludeStyle
value: google
- key: modernize-use-nullptr.NullMacros
value: "NULL"
---
18 changes: 18 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,24 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install ninja
run: python -m pip install --upgrade ninja
- name: Generate compile_commands.json
run: |
python tools/ci_build/build.py \
--cmake_generator "Ninja" \
--build_dir build \
--update \
--cmake_extra_defines CMAKE_EXPORT_COMPILE_COMMANDS=ON
- name: Generate ONNX protobuf files
run: cmake --build build/Debug --config Debug --target onnx_proto
- name: Run clang-tidy
uses: ZedThree/clang-tidy-review@526cbfb043719639f1ebdeedae0cc1eacd219d8f
with:
token: ${{ secrets.github_token }}
build_dir: "build/Debug"
config_file: ".clang-tidy"
lgtm_comment_body: ""
- uses: reviewdog/action-cpplint@master
with:
github_token: ${{ secrets.github_token }}
Expand Down

0 comments on commit 402e199

Please sign in to comment.