-
Notifications
You must be signed in to change notification settings - Fork 73
build: add support for Clang-Tidy tool. #263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d647905
build: add support for Clang-Tidy tool.
PiotrSikora f6f2db5
review: fix error that isn't present locally.
PiotrSikora e477bea
review: one more.
PiotrSikora 6c4851b
review: fix clang-tidy symlink?
PiotrSikora 7750dda
review: hardcode clang-tidy-12.
PiotrSikora bc82fdd
review: regen patch.
PiotrSikora 0ebdee2
review: fix WAVM build with clang-tidy.
PiotrSikora 8d5fc22
review: style.
PiotrSikora eeb424b
review: style to make it work with clang-tidy-12.
PiotrSikora d95dd62
review: split format jobs and enable cache for clang-tidy.
PiotrSikora f2e42d3
review: test cache (revert before merging).
PiotrSikora 5d8bd9a
Merge remote-tracking branch 'origin/master' into PiotrSikora/clang-tidy
PiotrSikora d8c600c
Revert "review: test cache (revert before merging)."
PiotrSikora 5d865d5
Merge remote-tracking branch 'origin/master' into PiotrSikora/clang-tidy
PiotrSikora 58617b1
review: Kick CI.
PiotrSikora 33fa7d0
review: remove unnecessary exclusion.
PiotrSikora cdeb493
review: fix readability-inconsistent-declaration-parameter-name.
PiotrSikora File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,25 @@ | ||
Checks: clang-*, | ||
-clang-analyzer-optin.portability.UnixAPI, | ||
-clang-analyzer-unix.Malloc, | ||
-clang-diagnostic-pragma-once-outside-header, | ||
cppcoreguidelines-pro-type-member-init, | ||
cppcoreguidelines-pro-type-static-cast-downcast, | ||
misc-*, | ||
-misc-non-private-member-variables-in-classes, | ||
modernize-*, | ||
-modernize-avoid-c-arrays, | ||
-modernize-return-braced-init-list, | ||
-modernize-use-trailing-return-type, | ||
llvm-include-order, | ||
performance-*, | ||
-performance-no-int-to-ptr, | ||
portability-*, | ||
readability-*, | ||
-readability-convert-member-functions-to-static, | ||
-readability-function-cognitive-complexity, | ||
-readability-inconsistent-declaration-parameter-name, | ||
-readability-magic-numbers, | ||
-readability-make-member-function-const, | ||
-readability-simplify-boolean-expr, | ||
|
||
WarningsAsErrors: '*' |
This file contains hidden or 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 |
---|---|---|
|
@@ -28,6 +28,9 @@ on: | |
- 'envoy-release/**' | ||
- 'istio-release/**' | ||
|
||
schedule: | ||
- cron: '0 0 * * *' | ||
|
||
jobs: | ||
|
||
addlicense: | ||
|
@@ -105,3 +108,61 @@ jobs: | |
run: | | ||
find . -name "*.h" -o -name "*.cc" -o -name "*.proto" | grep -v ".pb." | xargs -n1 clang-format-12 -i | ||
git diff --exit-code | ||
|
||
clang_tidy: | ||
name: check format with clang-tidy | ||
|
||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install dependencies (Linux) | ||
run: sudo apt-get install -y clang-tidy-12 | ||
|
||
- name: Bazel cache | ||
uses: PiotrSikora/[email protected] | ||
with: | ||
path: | | ||
~/.cache/bazel | ||
key: clang_tidy-${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion', 'bazel/dependencies.bzl', 'bazel/repositories.bzl', 'bazel/cargo/wasmsign/crates.bzl') }} | ||
|
||
- name: Bazel build | ||
run: > | ||
bazel build | ||
--config clang-tidy | ||
--define engine=multi | ||
--copt=-DPROXY_WASM_VERIFY_WITH_ED25519_PUBKEY=\"$(xxd -p -c 256 test/test_data/signature_key1.pub | cut -b9-)\" | ||
//... | ||
|
||
# - name: Skip Bazel cache update | ||
# if: ${{ github.ref != 'refs/heads/master' }} | ||
# run: echo "CACHE_SKIP_SAVE=true" >> $GITHUB_ENV | ||
|
||
- name: Cleanup Bazel cache | ||
# if: ${{ github.ref == 'refs/heads/master' }} | ||
run: | | ||
export OUTPUT=$(${{ matrix.run_under }} bazel info output_base) | ||
echo "===== BEFORE =====" | ||
du -s ${OUTPUT}/external/* $(dirname ${OUTPUT})/* | sort -rn | head -20 | ||
# BoringSSL's test data (90 MiB). | ||
rm -rf ${OUTPUT}/external/boringssl/crypto_test_data.cc | ||
rm -rf ${OUTPUT}/external/boringssl/src/crypto/*/test/ | ||
rm -rf ${OUTPUT}/external/boringssl/src/third_party/wycheproof_testvectors/ | ||
# LLVM's tests (500 MiB). | ||
rm -rf ${OUTPUT}/external/llvm*/test/ | ||
# V8's tests (100 MiB). | ||
if [ -d "${OUTPUT}/external/v8/test/torque" ]; then | ||
mv ${OUTPUT}/external/v8/test/torque ${OUTPUT}/external/v8/test_torque | ||
rm -rf ${OUTPUT}/external/v8/test/* | ||
mv ${OUTPUT}/external/v8/test_torque ${OUTPUT}/external/v8/test/torque | ||
fi | ||
# Unnecessary CMake tools (65 MiB). | ||
rm -rf ${OUTPUT}/external/cmake-*/bin/{ccmake,cmake-gui,cpack,ctest} | ||
# Distfiles for Rust toolchains (350 MiB). | ||
rm -rf ${OUTPUT}/external/rust_*/*.tar.gz | ||
# Bazel's repository cache (650-800 MiB) and install base (155 MiB). | ||
rm -rf ${OUTPUT}/../cache | ||
rm -rf ${OUTPUT}/../install | ||
echo "===== AFTER =====" | ||
du -s ${OUTPUT}/external/* $(dirname ${OUTPUT})/* | sort -rn | head -20 |
This file contains hidden or 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 hidden or 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,27 @@ | ||
# 1. Treat .h files as C++ headers. | ||
# 2. Hardcode clang-tidy-12. | ||
|
||
diff --git a/clang_tidy/clang_tidy.bzl b/clang_tidy/clang_tidy.bzl | ||
index 3a5ed07..5db5c6c 100644 | ||
--- a/clang_tidy/clang_tidy.bzl | ||
+++ b/clang_tidy/clang_tidy.bzl | ||
@@ -16,6 +16,9 @@ def _run_tidy(ctx, exe, flags, compilation_context, infile, discriminator): | ||
# add source to check | ||
args.add(infile.path) | ||
|
||
+ # treat .h files as C++ headers | ||
+ args.add("--extra-arg-before=-xc++") | ||
+ | ||
# start args passed to the compiler | ||
args.add("--") | ||
|
||
diff --git a/clang_tidy/run_clang_tidy.sh b/clang_tidy/run_clang_tidy.sh | ||
index 582bab1..b9ebb94 100755 | ||
--- a/clang_tidy/run_clang_tidy.sh | ||
+++ b/clang_tidy/run_clang_tidy.sh | ||
@@ -11,4 +11,4 @@ shift | ||
touch $OUTPUT | ||
truncate -s 0 $OUTPUT | ||
|
||
-clang-tidy "$@" | ||
+clang-tidy-12 "$@" |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: This list currently contains a lot of exclusion, because fixes for them require non-trivial changes in the code, and I didn't want to include them in this mass PR (in which 95% of changes is automatically applied suggestions from
clang-tidy
).