[clang] [llvm] [clang-format] Add CI check confirming ClangFormatStyleOptions.rst is up-to-date. (PR #111513)

Iuri Chaer via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 9 06:44:15 PST 2024


https://github.com/ichaer updated https://github.com/llvm/llvm-project/pull/111513

>From 7db80ba448fe4f434362de505330f504b9362844 Mon Sep 17 00:00:00 2001
From: Iuri Chaer <ichaer at splunk.com>
Date: Tue, 8 Oct 2024 10:52:13 +0100
Subject: [PATCH 1/7] [clang-format] Add CI check confirming
 ClangFormatStyleOptions.rst is up-to-date.

As discussed in https://github.com/llvm/llvm-project/pull/96804#discussion_r1718407404
---
 .github/workflows/docs.yml | 12 ++++++++++++
 clang/docs/CMakeLists.txt  |  6 ++++++
 2 files changed, 18 insertions(+)

diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index 800e9291573533..25eff4dcabc4a2 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -75,6 +75,9 @@ jobs:
               - 'clang/include/clang/Basic/AttrDocs.td'
               - 'clang/include/clang/Driver/ClangOptionDocs.td'
               - 'clang/include/clang/Basic/DiagnosticDocs.td'
+            clang-format_style-headers:
+              - 'clang/include/clang/Format/Format.h'
+              - 'clang/include/clang/Tooling/Inclusions/IncludeStyle.h'
             clang-tools-extra:
               - 'clang-tools-extra/docs/**'
             lldb:
@@ -122,6 +125,15 @@ jobs:
         run: |
           cmake -B clang-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_SPHINX=ON ./llvm
           TZ=UTC ninja -C clang-build docs-clang-html docs-clang-man
+      - name: Confirm ClangFormatStyleOptions.rst is up-to-date
+        if: steps.docs-changed-subprojects.outputs.clang-format_style-headers_any_changed == 'true'
+        run: |
+          cmake -B clang-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_SPHINX=ON ./llvm
+          TZ=UTC ninja -C clang-build clang-format-style-options
+          GIT_STATUS="$(git status --porcelain=v1 clang/docs/ClangFormatStyleOptions.rst)"
+          if [ ! -z "${GIT_STATUS}" ]; then
+            echo "Error: you must build the 'clang-format-style-options' target and commit any changes to 'clang/docs/ClangFormatStyleOptions.rst'"
+          fi
       - name: Build clang-tools-extra docs
         if: steps.docs-changed-subprojects.outputs.clang-tools-extra_any_changed == 'true'
         run: |
diff --git a/clang/docs/CMakeLists.txt b/clang/docs/CMakeLists.txt
index 51e9db29f887f3..cdc65e4455f87b 100644
--- a/clang/docs/CMakeLists.txt
+++ b/clang/docs/CMakeLists.txt
@@ -1,3 +1,9 @@
+add_custom_target(clang-format-style-options
+    COMMAND "${Python3_EXECUTABLE}" dump_format_style.py
+    WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/tools"
+    DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/../include/clang/Format/Format.h"
+            "${CMAKE_CURRENT_SOURCE_DIR}/../include/clang/Tooling/Inclusions/IncludeStyle.h")
+add_dependencies(clang-format clang-format-style-options)
 
 if (DOXYGEN_FOUND)
 if (LLVM_ENABLE_DOXYGEN)

>From 584828b05034cffd28a87778e5c70c8575d81a5b Mon Sep 17 00:00:00 2001
From: Iuri Chaer <ichaer at splunk.com>
Date: Tue, 8 Oct 2024 10:57:02 +0100
Subject: [PATCH 2/7] REVERT BEFORE MERGING

Add a change to clang/include/clang/Format/Format.h so we can see the new CI check working.
---
 clang/include/clang/Format/Format.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index ef6c76a070bfaa..546b971a2ab35a 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -3791,7 +3791,7 @@ struct FormatStyle {
   enum ReferenceAlignmentStyle : int8_t {
     /// Align reference like ``PointerAlignment``.
     RAS_Pointer,
-    /// Align reference to the left.
+    /// Align reference to the left FOOBAR CHANGE TO VALIDATE NEW CI CHECK.
     /// \code
     ///   int& a;
     /// \endcode

>From e269710fb69b691aafd0b660271c95dbc50cb0a6 Mon Sep 17 00:00:00 2001
From: Iuri Chaer <ichaer at splunk.com>
Date: Tue, 8 Oct 2024 11:20:26 +0100
Subject: [PATCH 3/7] lol, what a thing to forget

---
 .github/workflows/docs.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index 25eff4dcabc4a2..f559fbd237a99d 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -133,6 +133,7 @@ jobs:
           GIT_STATUS="$(git status --porcelain=v1 clang/docs/ClangFormatStyleOptions.rst)"
           if [ ! -z "${GIT_STATUS}" ]; then
             echo "Error: you must build the 'clang-format-style-options' target and commit any changes to 'clang/docs/ClangFormatStyleOptions.rst'"
+            exit 1
           fi
       - name: Build clang-tools-extra docs
         if: steps.docs-changed-subprojects.outputs.clang-tools-extra_any_changed == 'true'

>From 261ac339ac4c433f54e87de8d1632b428df32e96 Mon Sep 17 00:00:00 2001
From: Iuri Chaer <ichaer at splunk.com>
Date: Tue, 8 Oct 2024 11:22:13 +0100
Subject: [PATCH 4/7] Revert "REVERT BEFORE MERGING"

This reverts commit 584828b05034cffd28a87778e5c70c8575d81a5b.
---
 clang/include/clang/Format/Format.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 546b971a2ab35a..ef6c76a070bfaa 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -3791,7 +3791,7 @@ struct FormatStyle {
   enum ReferenceAlignmentStyle : int8_t {
     /// Align reference like ``PointerAlignment``.
     RAS_Pointer,
-    /// Align reference to the left FOOBAR CHANGE TO VALIDATE NEW CI CHECK.
+    /// Align reference to the left.
     /// \code
     ///   int& a;
     /// \endcode

>From 1cc9591bd718508c500b9df0343ddeb92cb5648a Mon Sep 17 00:00:00 2001
From: Iuri Chaer <ichaer at splunk.com>
Date: Tue, 15 Oct 2024 13:09:10 +0100
Subject: [PATCH 5/7] Make `clang-format-style-options` a dependency of
 `clangFormat` so it gets picked up by `FormatTests` as well.

---
 clang/docs/CMakeLists.txt       | 6 ------
 clang/lib/Format/CMakeLists.txt | 7 +++++++
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/clang/docs/CMakeLists.txt b/clang/docs/CMakeLists.txt
index 93a4356c1d53bb..4fecc007f59954 100644
--- a/clang/docs/CMakeLists.txt
+++ b/clang/docs/CMakeLists.txt
@@ -1,9 +1,3 @@
-add_custom_target(clang-format-style-options
-    COMMAND "${Python3_EXECUTABLE}" dump_format_style.py
-    WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/tools"
-    DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/../include/clang/Format/Format.h"
-            "${CMAKE_CURRENT_SOURCE_DIR}/../include/clang/Tooling/Inclusions/IncludeStyle.h")
-add_dependencies(clang-format clang-format-style-options)
 
 if (DOXYGEN_FOUND)
 if (LLVM_ENABLE_DOXYGEN)
diff --git a/clang/lib/Format/CMakeLists.txt b/clang/lib/Format/CMakeLists.txt
index b787b11ac7b744..315079a8692ce4 100644
--- a/clang/lib/Format/CMakeLists.txt
+++ b/clang/lib/Format/CMakeLists.txt
@@ -53,3 +53,10 @@ foreach (file IN LISTS files)
 endforeach ()
 
 add_custom_target(clang-format-check-format DEPENDS ${check_format_depends})
+
+add_custom_target(clang-format-style-options
+    COMMAND "${Python3_EXECUTABLE}" dump_format_style.py
+    WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../docs/tools"
+    DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/../../include/clang/Format/Format.h"
+            "${CMAKE_CURRENT_SOURCE_DIR}/../../include/clang/Tooling/Inclusions/IncludeStyle.h")
+add_dependencies(clangFormat clang-format-style-options)

>From 1c935163dc3b8f1d4b3f7eb73190e01c970f6a6f Mon Sep 17 00:00:00 2001
From: Iuri Chaer <iuri.chaer at gmail.com>
Date: Sat, 9 Nov 2024 14:40:09 +0000
Subject: [PATCH 6/7] Update clang/lib/Format/CMakeLists.txt

Co-authored-by: Owen Pan <owenpiano at gmail.com>
---
 clang/lib/Format/CMakeLists.txt | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Format/CMakeLists.txt b/clang/lib/Format/CMakeLists.txt
index 315079a8692ce4..f7bf53eb22c5c5 100644
--- a/clang/lib/Format/CMakeLists.txt
+++ b/clang/lib/Format/CMakeLists.txt
@@ -54,9 +54,12 @@ endforeach ()
 
 add_custom_target(clang-format-check-format DEPENDS ${check_format_depends})
 
-add_custom_target(clang-format-style-options
-    COMMAND "${Python3_EXECUTABLE}" dump_format_style.py
-    WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../docs/tools"
-    DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/../../include/clang/Format/Format.h"
-            "${CMAKE_CURRENT_SOURCE_DIR}/../../include/clang/Tooling/Inclusions/IncludeStyle.h")
+set(style_options_depends ${CLANG_SOURCE_DIR}/docs/ClangFormatStyleOptions.rst)
+add_custom_command(OUTPUT ${style_options_depends}
+  COMMAND ${Python3_EXECUTABLE} dump_format_style.py
+  WORKING_DIRECTORY ${CLANG_SOURCE_DIR}/docs/tools
+  DEPENDS ${CLANG_SOURCE_DIR}/include/clang/Format/Format.h
+          ${CLANG_SOURCE_DIR}/include/clang/Tooling/Inclusions/IncludeStyle.h
+  )
+add_custom_target(clang-format-style-options DEPENDS ${style_options_depends})
 add_dependencies(clangFormat clang-format-style-options)

>From 23100bd061fa64458a528842ccabbb3e6594393e Mon Sep 17 00:00:00 2001
From: Iuri Chaer <ichaer at splunk.com>
Date: Sat, 9 Nov 2024 14:43:50 +0000
Subject: [PATCH 7/7] Undo pipeline changes, let this PR be only about the
 cmake target.

---
 .github/workflows/docs.yml | 13 -------------
 1 file changed, 13 deletions(-)

diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index f559fbd237a99d..800e9291573533 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -75,9 +75,6 @@ jobs:
               - 'clang/include/clang/Basic/AttrDocs.td'
               - 'clang/include/clang/Driver/ClangOptionDocs.td'
               - 'clang/include/clang/Basic/DiagnosticDocs.td'
-            clang-format_style-headers:
-              - 'clang/include/clang/Format/Format.h'
-              - 'clang/include/clang/Tooling/Inclusions/IncludeStyle.h'
             clang-tools-extra:
               - 'clang-tools-extra/docs/**'
             lldb:
@@ -125,16 +122,6 @@ jobs:
         run: |
           cmake -B clang-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_SPHINX=ON ./llvm
           TZ=UTC ninja -C clang-build docs-clang-html docs-clang-man
-      - name: Confirm ClangFormatStyleOptions.rst is up-to-date
-        if: steps.docs-changed-subprojects.outputs.clang-format_style-headers_any_changed == 'true'
-        run: |
-          cmake -B clang-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_SPHINX=ON ./llvm
-          TZ=UTC ninja -C clang-build clang-format-style-options
-          GIT_STATUS="$(git status --porcelain=v1 clang/docs/ClangFormatStyleOptions.rst)"
-          if [ ! -z "${GIT_STATUS}" ]; then
-            echo "Error: you must build the 'clang-format-style-options' target and commit any changes to 'clang/docs/ClangFormatStyleOptions.rst'"
-            exit 1
-          fi
       - name: Build clang-tools-extra docs
         if: steps.docs-changed-subprojects.outputs.clang-tools-extra_any_changed == 'true'
         run: |



More information about the cfe-commits mailing list