mbox series

[0/8] clang-format: add more rules and enable on CI

Message ID 20240708092317.267915-1-karthik.188@gmail.com (mailing list archive)
Headers show
Series clang-format: add more rules and enable on CI | expand

Message

karthik nayak July 8, 2024, 9:23 a.m. UTC
The series was mostly inspired by a patch sent recently to 'include
kh_foreach* macros in ForEachMacros' [1]. I was wondering why we don't
run the formatting on CI and reduce some of the workload of reviewers.

We have a '.clang-format' file to provide rules for code formatting.
The commits 1-6 aims to add more rules to the file while deprecating old
ones.

Commit 7 enables CI action on GitHub and GitLab to also check for the
code formatting. Currently, it is allowed to fail. This way we can build
confidence and fine tune the values as needed and finally enforce the
check in a future patch. I'm not well versed with GitHub workflows, and
I mostly tried to copy existing work there. Expecting some feedback in
that section!

Commit 8 fixes an existing issue with the 'check-whitespace' job, which
is failing as success in the GitLab CI.

1: https://lore.kernel.org/git/4e7893f5-2dd9-46cf-8a64-cf780f4e1730@web.de/

Karthik Nayak (8):
  clang-format: indent preprocessor directives after hash
  clang-format: avoid spacing around bitfield colon
  clang-format: ensure files end with newlines
  clang-format: replace deprecated option with 'SpacesInParens'
  clang-format: avoid braces on simple single-statement bodies
  clang-format: formalize some of the spacing rules
  ci: run style check on GitHub and GitLab
  check-whitespace: detect if no base_commit is provided

 .clang-format                     | 41 +++++++++++++++++++++++++++----
 .github/workflows/check-style.yml | 29 ++++++++++++++++++++++
 .gitlab-ci.yml                    | 14 ++++++++++-
 ci/check-whitespace.sh            | 13 +++++++---
 ci/install-dependencies.sh        |  2 +-
 ci/run-style-check.sh             |  8 ++++++
 6 files changed, 97 insertions(+), 10 deletions(-)
 create mode 100644 .github/workflows/check-style.yml
 create mode 100755 ci/run-style-check.sh

Comments

Chris Torek July 8, 2024, 10:06 a.m. UTC | #1
On Mon, Jul 8, 2024 at 2:23 AM Karthik Nayak <karthik.188@gmail.com> wrote:
> The series was mostly inspired by a patch sent recently to 'include
> kh_foreach* macros in ForEachMacros' [1]. I was wondering why we don't
> run the formatting on CI and reduce some of the workload of reviewers.

As a big fan of automated formatting, I scanned through all of these.
I did not spot anything problematic and had just a few minor comments.
I'm not an expert on clang-format directives, nor on GitHub/GitLab CI,
though.  Anyway if you want it you can have a reviewed-by from me. :-)

(Comments stuck on individual patches)

Chris