[gnome-kiosk/check-style] ci: Enforce coding style in CI
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-kiosk/check-style] ci: Enforce coding style in CI
- Date: Fri, 29 Jul 2022 14:25:36 +0000 (UTC)
commit 66ed6f9012ca25b6a8413fa5e5d382ad58345718
Author: Ray Strode <rstrode redhat com>
Date: Fri Jul 29 10:19:44 2022 -0400
ci: Enforce coding style in CI
We just ran gnome-kiosk through uncrustify, but there's nothing to
prevent it from getting bad again.
This commit adds an uncrustification check to CI.
.gitlab-ci.yml | 15 +++++++++++++-
meson.build | 3 +++
scripts/check-format.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 72 insertions(+), 1 deletion(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 01d0927..bb5dca0 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,5 +1,6 @@
stages:
- build
+ - test
build-fedora:
image: fedora:rawhide
@@ -20,15 +21,27 @@ build-fedora:
mesa-libGL-devel
meson
mutter-devel
+ patchutils
+ uncrustify
script:
- export BUILD_ROOT=_build
- meson . $BUILD_ROOT --prefix=/usr --sysconfdir=/etc --localstatedir=/var
--mandir=/usr/share/man --libdir=/usr/lib64
- ninja -C $BUILD_ROOT
- ninja -C $BUILD_ROOT install
- ninja -C $BUILD_ROOT dist
- - ninja -C $BUILD_ROOT test
except:
- tags
artifacts:
paths:
- _build/meson-dist
+ only:
+ - merge_requests
+
+test-fedora:
+ extends:
+ - build-fedora
+ stage: test
+ script:
+ - ninja -C $BUILD_ROOT test
+ only:
+ - merge_requests
diff --git a/meson.build b/meson.build
index 8a43bb0..8e53052 100644
--- a/meson.build
+++ b/meson.build
@@ -269,3 +269,6 @@ i18n.merge_file(
install_dir: desktop_data_dir,
type: 'desktop'
)
+
+test('check-format', find_program('scripts/check-format.sh'))
+
diff --git a/scripts/check-format.sh b/scripts/check-format.sh
new file mode 100755
index 0000000..ff021f5
--- /dev/null
+++ b/scripts/check-format.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+SRC_DIR=$(dirname "$0")/..
+
+exec >& /dev/stderr
+
+set -x
+env
+
+if [ -z "$CI_MERGE_REQUEST_DIFF_BASE_SHA" ]; then
+ UPSTREAM_BRANCH="$(git rev-parse --abbrev-ref --symbolic-full-name @{u})"
+else
+ UPSTREAM_BRANCH="$CI_MERGE_REQUEST_DIFF_BASE_SHA"
+fi
+
+cd "$SRC_DIR"
+
+cp scripts/uncrustify.cfg scripts/latest-uncrustify.cfg
+
+git diff --quiet
+DIRTY_TREE="$?"
+
+if [ "$DIRTY_TREE" -ne 0 ]; then
+ git stash
+ git stash apply
+fi
+
+find -name '*.[ch]' -exec uncrustify -q -c scripts/latest-uncrustify.cfg --replace {} \;
+
+echo > after
+find -name '*.[ch]' -exec git diff -- {} \; >> after
+
+git reset --hard $UPSTREAM_BRANCH
+find -name '*.[ch]' -exec uncrustify -q -c scripts/latest-uncrustify.cfg --replace {} \;
+
+echo > before
+find -name '*.[ch]' -exec git diff -- {} \; >> before
+
+interdiff --no-revert-omitted before after > diff
+
+if [ -n "$(cat diff)" ]; then
+ echo "Uncrustify found style abnormalities" 2>&1
+ cat diff
+ exit 1
+fi
+
+git reset --hard HEAD@{1}
+
+if [ "$DIRTY_TREE" -ne 0 ]; then
+ git stash pop
+fi
+
+echo "No new style abnormalities found by uncrustify!"
+exit 0
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]