Include clang-tidy check
authorColin Clark <colin.clark@cclark.uk>
Tue, 11 Jul 2023 15:53:16 +0000 (16:53 +0100)
committerColin Clark <colin.clark@cclark.uk>
Tue, 11 Jul 2023 15:53:16 +0000 (16:53 +0100)
- Initial check setup
- Separate log files for GitHub workflow runs

.clang-tidy [new file with mode: 0644]
.github/workflows/check-build-actions.yml
meson.build

diff --git a/.clang-tidy b/.clang-tidy
new file mode 100644 (file)
index 0000000..0a77b0e
--- /dev/null
@@ -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
index 8b69605..b3c4c28 100644 (file)
@@ -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
index b584a8b..96ce460 100644 (file)
@@ -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