-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): Add clang-tidy checks and ensure they pass (#639)
This PR adds a `clang-tidy` check to CI and fixes several issues that it identified (including a few from other repos like ADBC and cudf). A reboot of #538; closes #537.
- Loading branch information
1 parent
e52ff0d
commit b1ba426
Showing
16 changed files
with
201 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# 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. | ||
--- | ||
# Disable valist, it's buggy: https://github.com/llvm/llvm-project/issues/40656 | ||
# Disable DeprecatedOrUnsafeBufferHandling because it suggests we replace | ||
# memset and memcpy with memset_s() and memcpy_s() if compiled with C11. Because | ||
# we also support C99, we can't blindly replace those calls. | ||
Checks: '-clang-analyzer-valist.Uninitialized,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling' | ||
FormatStyle: google |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# 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. | ||
|
||
name: clang-tidy | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- 'CMakeLists.txt' | ||
- '.github/workflows/clang-tidy.yaml' | ||
- 'src/nanoarrow/**' | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
clang-tidy: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
name: ${{ matrix.config.label }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Cache Arrow C++ Build | ||
id: cache-arrow-build | ||
uses: actions/cache@v4 | ||
with: | ||
path: arrow | ||
# Bump the number at the end of this line to force a new Arrow C++ build | ||
key: arrow-${{ runner.os }}-${{ runner.arch }}-1 | ||
|
||
- name: Build Arrow C++ | ||
if: steps.cache-arrow-build.outputs.cache-hit != 'true' | ||
shell: bash | ||
run: | | ||
ci/scripts/build-arrow-cpp-minimal.sh 15.0.2 arrow | ||
- name: Build nanoarrow | ||
run: | | ||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/dist/lib | ||
sudo ldconfig | ||
ARROW_PATH="$(pwd)/arrow" | ||
mkdir build | ||
cd build | ||
cmake .. -DNANOARROW_DEVICE=ON -DNANOARROW_IPC=ON \ | ||
-DNANOARROW_BUILD_TESTS=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ | ||
-DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ | ||
-DCMAKE_PREFIX_PATH="${ARROW_PATH}" | ||
cmake --build . | ||
- name: Run clang-tidy | ||
run: | | ||
ci/scripts/run-clang-tidy.sh . build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# 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. | ||
|
||
set -e | ||
|
||
main() { | ||
local -r source_dir="${1}" | ||
local -r build_dir="${2}" | ||
|
||
if [ $(uname) = "Darwin" ]; then | ||
local -r jobs=$(sysctl -n hw.ncpu) | ||
else | ||
local -r jobs=$(nproc) | ||
fi | ||
|
||
set -x | ||
|
||
run-clang-tidy -p "${build_dir}" -j$jobs \ | ||
-extra-arg=-Wno-unknown-warning-option | \ | ||
tee "${build_dir}/clang-tidy-output.txt" | ||
|
||
if grep -e "warning:" -e "error:" "${build_dir}/clang-tidy-output.txt"; then | ||
echo "Warnings or errors found!" | ||
exit 1 | ||
else | ||
echo "No warnings or errors found!" | ||
fi | ||
|
||
set +x | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.