[clang] [clang] Setup whitespace detection and clang-format as Github actions (PR #66509)

via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 15 06:24:09 PDT 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-github-workflow
            
<details>
<summary>Changes</summary>
Instead of using the BuildKite jobs, use GitHub actions to detect clang-format violations and trailing whitespace in PRs.

Fixes #66468
--
Full diff: https://github.com/llvm/llvm-project/pull/66509.diff

6 Files Affected:

- (added) .github/workflows/clang/pr-check-trailing-whitespace.yml (+14) 
- (added) .github/workflows/clang/pr-clang-format.yml (+18) 
- (modified) clang/lib/AST/Expr.cpp (+1-1) 
- (modified) clang/lib/AST/ExprClassification.cpp (+6) 
- (modified) clang/utils/ci/buildkite-pipeline.yml (-11) 
- (modified) clang/utils/ci/run-buildbot (-3) 


<pre>
diff --git a/.github/workflows/clang/pr-check-trailing-whitespace.yml b/.github/workflows/clang/pr-check-trailing-whitespace.yml
new file mode 100644
index 000000000000000..b08f1e24d785ac5
--- /dev/null
+++ b/.github/workflows/clang/pr-check-trailing-whitespace.yml
@@ -0,0 +1,14 @@
+name: Ensure there are no trailing whitespace
+
+on:
+  pull_request:
+    paths:
+    - &#x27;clang/**&#x27;
+
+jobs:
+  example:
+    name: Find Trailing Whitespace
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout at v3
+      - uses: harupy/find-trailing-whitespace at master
diff --git a/.github/workflows/clang/pr-clang-format.yml b/.github/workflows/clang/pr-clang-format.yml
new file mode 100644
index 000000000000000..2589b815a480f09
--- /dev/null
+++ b/.github/workflows/clang/pr-clang-format.yml
@@ -0,0 +1,18 @@
+name: clang-format Check
+
+on:
+  pull_request:
+    paths:
+    - &#x27;clang/**&#x27;
+
+jobs:
+  formatting-check:
+    name: Formatting Check
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout at v3
+    - name: Run clang-format style check
+      uses: jidicula/clang-format-action at v4.11.0
+      with:
+        clang-format-version: &#x27;16&#x27;
+        check-path: &#x27;clang/&#x27;
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 4f3837371b3fc5e..342a7e3e47144bd 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -63,7 +63,7 @@ const Expr *Expr::getBestDynamicClassTypeExpr() const {
   }
 
   return E;
-}
+}   
 
 const CXXRecordDecl *Expr::getBestDynamicClassType() const {
   const Expr *E = getBestDynamicClassTypeExpr();
diff --git a/clang/lib/AST/ExprClassification.cpp b/clang/lib/AST/ExprClassification.cpp
index 12193b7812f9bf8..18d35d1d47cfb82 100644
--- a/clang/lib/AST/ExprClassification.cpp
+++ b/clang/lib/AST/ExprClassification.cpp
@@ -79,6 +79,12 @@ Cl Expr::ClassifyImpl(ASTContext &amp;Ctx, SourceLocation *Loc) const {
   return Classification(kind, modifiable);
 }
 
+static int not_well_formatted_code(int i)
+{
+   int hi = i ;
+    return hi;
+}
+
 /// Classify an expression which creates a temporary, based on its type.
 static Cl::Kinds ClassifyTemporary(QualType T) {
   if (T-&gt;isRecordType())
diff --git a/clang/utils/ci/buildkite-pipeline.yml b/clang/utils/ci/buildkite-pipeline.yml
index 7a679176038c693..22ee165d1edf4e1 100644
--- a/clang/utils/ci/buildkite-pipeline.yml
+++ b/clang/utils/ci/buildkite-pipeline.yml
@@ -17,17 +17,6 @@ env:
     # LLVM RELEASE bump version
     LLVM_HEAD_VERSION: &quot;17&quot;
 steps:
-  - label: &quot;Format&quot;
-    commands:
-      - &quot;clang/utils/ci/run-buildbot check-format&quot;
-    agents:
-      queue: &quot;linux&quot;
-    retry:
-      automatic:
-        - exit_status: -1  # Agent was lost
-          limit: 2
-    timeout_in_minutes: 120
-
   - label: &quot;Building and testing clang (Linux)&quot;
     commands:
       - &quot;clang/utils/ci/run-buildbot build-clang&quot;
diff --git a/clang/utils/ci/run-buildbot b/clang/utils/ci/run-buildbot
index d117fccc7e3fbd8..56a1a9a8c8cfa22 100755
--- a/clang/utils/ci/run-buildbot
+++ b/clang/utils/ci/run-buildbot
@@ -69,9 +69,6 @@ cmake --version
 ninja --version
 
 case &quot;${BUILDER}&quot; in
-check-format)
-    ! grep -rnI &#x27;[[:blank:]]$&#x27; clang/lib clang/include clang/docs
-;;
 build-clang)
     mkdir install
     # We use Release here to avoid including debug information. Otherwise, the
</pre>
</details>


https://github.com/llvm/llvm-project/pull/66509


More information about the cfe-commits mailing list