From 9b82521e2481d3cba2fd841ec679933cc5f6467b Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Tue, 11 Jul 2023 16:53:16 +0100 Subject: [PATCH] Include clang-tidy check - Initial check setup - Separate log files for GitHub workflow runs --- .clang-tidy | 42 +++++++++++++++++++++++ .github/workflows/check-build-actions.yml | 4 +-- meson.build | 27 +++++++++++++++ 3 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 00000000..0a77b0e3 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,42 @@ +#/* +# * Copyright (C) 2023 The Geeqie Team +# * +# * Author: Colin Clark +# * +# * This program is free software; you can redistribute it and/or modify +# * it under the terms of the GNU General Public License as published by +# * the Free Software Foundation; either version 2 of the License, or +# * (at your option) any later version. +# * +# * This program is distributed in the hope that it will be useful, +# * but WITHOUT ANY WARRANTY; without even the implied warranty of +# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# * GNU General Public License for more details. +# * +# * You should have received a copy of the GNU General Public License along +# * with this program; if not, write to the Free Software Foundation, Inc., +# * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# */ + +Checks: > + -*, + bugprone-*, + misc-*, + modernize-*, + performance-*, + portability-*, + readability-*, + -bugprone-easily-swappable-parameters, + -misc-const-correctness, + -modernize-avoid-c-arrays, + -modernize-macro-to-enum, + -modernize-use-trailing-return-type, + -performance-no-int-to-ptr, + -readability-braces-around-statements, + -readability-else-after-return, + -readability-function-cognitive-complexity, + -readability-identifier-length, + -readability-implicit-bool-conversion, + -readability-isolate-declaration, + -readability-magic-numbers, + -readability-qualified-auto diff --git a/.github/workflows/check-build-actions.yml b/.github/workflows/check-build-actions.yml index 8b69605f..b3c4c281 100644 --- a/.github/workflows/check-build-actions.yml +++ b/.github/workflows/check-build-actions.yml @@ -22,7 +22,7 @@ jobs: uses: actions/upload-artifact@v2 if: always() with: - name: logs-all + name: logs-all-no-options path: /home/runner/work/geeqie/geeqie/build/meson-logs/*.txt retention-days: 5 @@ -63,6 +63,6 @@ jobs: uses: actions/upload-artifact@v2 if: always() with: - name: logs-all + name: logs-all-most-options path: /home/runner/work/geeqie/geeqie/build/meson-logs/*.txt retention-days: 5 diff --git a/meson.build b/meson.build index b584a8b8..96ce460a 100644 --- a/meson.build +++ b/meson.build @@ -728,3 +728,30 @@ if option.enabled() else summary({'Image tests' : ['Test runs:', false]}, section : 'Testing', bool_yn : true) endif + +# Code correctness checks +if running_from_git + clang_tidy_exe = find_program('clang-tidy', required : false) + if clang_tidy_exe.found() + git_exe = find_program('git', required : true) + modified_file_list = run_command(git_exe, 'diff', '--name-only', check: true) + modified_files = modified_file_list.stdout().strip().split('\n') + + foreach modified_file : modified_files + if modified_file.endswith('.cc') + modified_file_path = '@0@'.format(modified_file) + path_array = modified_file_path.split('/') + modified_file_name = path_array[path_array.length() - 1] + modified_file_full_path = join_paths(meson.project_source_root(), modified_file) + + test('Code Correctness_ ' + modified_file_name, clang_tidy_exe, args : ['-p', './build', '-quiet', modified_file_full_path], timeout : 100) + endif + endforeach + + summary({'Code Correctness' : ['Test runs:', true]}, section : 'Testing', bool_yn : true) + else + summary({'Code Correctness' : ['Test runs:', false]}, section : 'Testing', bool_yn : true) + endif +else + summary({'Code Correctness' : ['Test runs:', false]}, section : 'Testing', bool_yn : true) +endif -- 2.20.1