diff --git a/.cmakelintrc b/.cmakelintrc new file mode 100644 index 000000000000..d70cdd7c9230 --- /dev/null +++ b/.cmakelintrc @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# build and install are separated so changes to build don't invalidate +# the whole docker cache for the image + +# --filter= options: https://pypi.org/project/cmakelint/ +# "-" disable option +# "+" enable option +filter=-convention/filename,-linelength,-package/consistency,-readability/logic,-readability/mixedcase,-readability/wonkycase,-syntax,-whitespace/eol,+whitespace/extra,-whitespace/indent,-whitespace/mismatch,-whitespace/newline,-whitespace/tabs diff --git a/ci/docker/install/requirements b/ci/docker/install/requirements index 21f10b92cba8..b034cb5d7483 100644 --- a/ci/docker/install/requirements +++ b/ci/docker/install/requirements @@ -55,6 +55,9 @@ h5py==2.10.0 # Array API Standardization requirements hypothesis==6.14.0 +# Static code checker for CMake files +cmakelint==1.4.1 + # Prospector - Python Static Analysis prospector==1.5.1 diff --git a/ci/docker/runtime_functions.sh b/ci/docker/runtime_functions.sh index 0f7913557935..b97b82387ec4 100755 --- a/ci/docker/runtime_functions.sh +++ b/ci/docker/runtime_functions.sh @@ -703,11 +703,18 @@ sanity_check() { set -ex sanity_clang sanity_license + sanity_cmakelint sanity_tutorial sanity_python_prospector sanity_cpp } +sanity_cmakelint() { + set -exu + + git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' '*CMakeLists.txt' | grep -E -z -v '^(3rdparty)|cmake/Modules/|cmake/upstream/' | xargs -0 cmakelint --config=.cmakelintrc --quiet +} + sanity_tutorial() { set -ex export DMLC_LOG_STACK_TRACE_DEPTH=100