ci: Enforce clang-format for asahi
authorAlyssa Rosenzweig <alyssa@collabora.com>
Fri, 10 Mar 2023 01:36:12 +0000 (20:36 -0500)
committerMarge Bot <emma+marge@anholt.net>
Fri, 17 Mar 2023 19:59:21 +0000 (19:59 +0000)
Some drivers use clang-format exclusively. We would like to lint for correct
formatting in CI to catch style issues before they land, because mixing
clang-format and not clang-format within a codebase is a recipe for conflicts.

We don't expect this lint to ever fail in "normal" usage, since we expect
developers on these drivers to setup automatic formatting in their editor.
However, it can be useful as a failsafe or for drive-by contributors who don't
know the style guide.

Enable the linting for Asahi. We'll enable for Panfrost shortly, but Panfrost
isn't clang-format clean quite yet.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Eric Engestrom <eric@igalia.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20553>

.gitlab-ci/test-source-dep.yml
.gitlab-ci/test/gitlab-ci.yml

index 1a17b0f..0dbed2d 100644 (file)
     - changes:
       - src/**/*.rs
       when: on_success
+
+.lint-clang-format-rules:
+   rules:
+    - !reference [.core-rules, rules]
+    - changes:
+      - src/**/asahi/**/*
+      when: on_success
index 093cc3b..5dd2780 100644 (file)
@@ -30,6 +30,19 @@ rustfmt:
     - shopt -s globstar
     - rustfmt --check --verbose src/**/*.rs
 
+clang-format:
+  # Cancel job if a newer commit is pushed to the same branch
+  interruptible: true
+  stage: lint
+  extends:
+    - .use-debian/x86_build
+    - .lint-clang-format-rules
+  variables:
+    GIT_STRATEGY: fetch
+  script:
+    - shopt -s globstar
+    - clang-format-13 --Werror --dry-run src/**/asahi/**/*.{h,c,cpp}
+
 .test-gl:
   extends:
     - .test