forked from fruits-lab/vitaminc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a script for CI execution. This script is not intended for local user execution due to the following reasons: 1. `clang-tidy-diff` supports exit with a failure code when there are errors from version 17 or 18 onward. (The exact version is uncertain. For more details, please refer to llvm/llvm-project#65000.) 2. `bear` has different command line interfaces between version <= 2.4.x and onward. (For more details, please refer to https://github.com/rizsotto/Bear?tab=readme-ov-file#how-to-use.) The script may not function properly if any of these issues arise. In the CI environment, we ensure that the versions of these dependencies are up-to-date. Specifically, the version of `clang-tidy-diff` is specified as `18`, and the version of `Bear` on Ubuntu 22.04 is 3.0.x.
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 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
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 |
---|---|---|
|
@@ -58,3 +58,6 @@ venv.bak/ | |
|
||
# VS Code configs | ||
.vscode | ||
|
||
# Compilation database | ||
compile_commands.json |
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,33 @@ | ||
#!/usr/bin/env sh | ||
|
||
# | ||
# Runs clang-tidy on the diff between main and HEAD. | ||
# | ||
|
||
set -eu | ||
|
||
CLANG_TIDY_DIFF=${CLANG_TIDY_DIFF:-clang-tidy-diff.py} | ||
|
||
command -v bear >/dev/null 2>&1 || ( | ||
echo "error: bear is required to generate compile_commands.json; see https://github.com/rizsotto/Bear" | ||
exit 1 | ||
) | ||
|
||
# number of jobs to run | ||
NPROCS=1 | ||
# Find available processor numbers based on different OS. | ||
OS="$(uname -s)" | ||
case $OS in | ||
'Linux') | ||
NPROCS="$(grep -c ^processor /proc/cpuinfo)" | ||
;; | ||
'Darwin') | ||
NPROCS="$(sysctl -n hw.ncpu)" | ||
;; | ||
esac | ||
|
||
# Run a clean build to generate compile_commands.json. | ||
make clean | ||
bear -- make -j"${NPROCS}" | ||
git fetch origin main:refs/remotes/origin/main | ||
git diff -U0 main | ${CLANG_TIDY_DIFF} -p1 -j"${NPROCS}" |