Răsfoiți Sursa

ci: export clang-tidy fixes as an artifact

Kyle Edwards 3 ani în urmă
părinte
comite
1f0c28c840

+ 3 - 0
.gitignore

@@ -32,3 +32,6 @@
 /.vs/
 # Visual Studio build directory
 /out/
+
+# clang-tidy output
+/clang-tidy-fixes.patch

+ 1 - 0
.gitlab-ci.yml

@@ -112,6 +112,7 @@ l:tidy-fedora39:
     extends:
         - .fedora39_tidy
         - .cmake_build_linux
+        - .cmake_tidy_artifacts
         - .linux_x86_64_tags
         - .cmake_cdash_artifacts
         - .run_automatically

+ 2 - 0
.gitlab/.gitignore

@@ -19,3 +19,5 @@
 /unstable-jom*
 /watcom
 /wix*
+/clang-tidy-fixes
+/num_warnings.txt

+ 7 - 0
.gitlab/artifacts.yml

@@ -153,3 +153,10 @@
             - ${CMAKE_CI_BUILD_DIR}/html
         exclude:
             - ${CMAKE_CI_BUILD_DIR}/html/.buildinfo
+
+.cmake_tidy_artifacts:
+    artifacts:
+        expire_in: 1d
+        when: always
+        paths:
+            - clang-tidy-fixes.patch

+ 1 - 0
.gitlab/ci/configure_fedora39_tidy.cmake

@@ -1,5 +1,6 @@
 set(CMake_RUN_CLANG_TIDY ON CACHE BOOL "")
 set(CMake_USE_CLANG_TIDY_MODULE ON CACHE BOOL "")
 set(CMake_CLANG_TIDY_MODULE "$ENV{CI_PROJECT_DIR}/Utilities/ClangTidyModule/build/libcmake-clang-tidy-module.so" CACHE FILEPATH "")
+set(CMake_CLANG_TIDY_EXPORT_FIXES_DIR "$ENV{CI_PROJECT_DIR}/.gitlab/clang-tidy-fixes" CACHE PATH "")
 
 include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora39_common.cmake")

+ 1 - 0
.gitlab/ci/ctest_build.cmake

@@ -65,6 +65,7 @@ if ("$ENV{CTEST_NO_WARNINGS_ALLOWED}" AND num_warnings GREATER 0)
   message(FATAL_ERROR
     "Found ${num_warnings} warnings (treating as fatal).")
 endif ()
+file(WRITE "$ENV{CI_PROJECT_DIR}/.gitlab/num_warnings.txt" "${num_warnings}\n")
 
 if (ctest_build_args)
   message(FATAL_ERROR

+ 21 - 0
.gitlab/ci/post_build_fedora39_tidy.sh

@@ -0,0 +1,21 @@
+git config user.name "Kitware Robot"
+git config user.email "[email protected]"
+
+clang-apply-replacements --style=file .gitlab/clang-tidy-fixes
+git add .
+
+if [ -n "$(git status --porcelain)" ]; then
+  quietly git commit --file=- <<EOF
+WIP: clang-tidy: <SHORT DESCRIPTION OF CHANGE HERE>
+
+<LONGER DESCRIPTION OF CHANGE HERE.>
+EOF
+  git format-patch --output=clang-tidy-fixes.patch -1 -N
+  echo "Patch from clang-tidy available, check artifacts of this CI job." >&2
+fi
+
+readonly num_warnings="$(cat .gitlab/num_warnings.txt)"
+if [ "$num_warnings" -ne 0 ]; then
+  echo "Found $num_warnings warnings (treating as fatal)." >&2
+  exit 1
+fi

+ 0 - 1
.gitlab/os-linux.yml

@@ -82,7 +82,6 @@
 
     variables:
         CMAKE_CONFIGURATION: fedora39_tidy
-        CTEST_NO_WARNINGS_ALLOWED: 1
         CMAKE_CI_NO_INSTALL: 1
 
 .fedora39_clang_analyzer: