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

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


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

Instead of using the BuildKite jobs, use GitHub actions to detect clang-format violations and trailing whitespace in PRs.

Fixes #66468

>From 46330c22414ed8722e85ff349f502d4e5a1bac5d Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Fri, 15 Sep 2023 09:17:18 -0400
Subject: [PATCH] [clang] Setup whitespace detection and clang-format as Github
 actions

Instead of using the BuildKite jobs, use GitHub actions to detect
clang-format violations and trailing whitespace in PRs.

Fixes #66468
---
 .../clang/pr-check-trailing-whitespace.yml     | 14 ++++++++++++++
 .github/workflows/clang/pr-clang-format.yml    | 18 ++++++++++++++++++
 clang/lib/AST/Expr.cpp                         |  2 +-
 clang/lib/AST/ExprClassification.cpp           |  6 ++++++
 clang/utils/ci/buildkite-pipeline.yml          | 11 -----------
 clang/utils/ci/run-buildbot                    |  3 ---
 6 files changed, 39 insertions(+), 15 deletions(-)
 create mode 100644 .github/workflows/clang/pr-check-trailing-whitespace.yml
 create mode 100644 .github/workflows/clang/pr-clang-format.yml

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:
+    - 'clang/**'
+
+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:
+    - 'clang/**'
+
+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: '16'
+        check-path: 'clang/'
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 &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->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: "17"
 steps:
-  - label: "Format"
-    commands:
-      - "clang/utils/ci/run-buildbot check-format"
-    agents:
-      queue: "linux"
-    retry:
-      automatic:
-        - exit_status: -1  # Agent was lost
-          limit: 2
-    timeout_in_minutes: 120
-
   - label: "Building and testing clang (Linux)"
     commands:
       - "clang/utils/ci/run-buildbot build-clang"
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 "${BUILDER}" in
-check-format)
-    ! grep -rnI '[[:blank:]]$' clang/lib clang/include clang/docs
-;;
 build-clang)
     mkdir install
     # We use Release here to avoid including debug information. Otherwise, the



More information about the cfe-commits mailing list