[gtranslator/add-clang-format-ci] Add check stage to CI with code style
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator/add-clang-format-ci] Add check stage to CI with code style
- Date: Thu, 2 Jun 2022 16:37:21 +0000 (UTC)
commit 1a753f49f3888d5e5328da6eedee7a9f7d06d337
Author: Daniel GarcĂa Moreno <dani danigm net>
Date: Thu Jun 2 18:28:59 2022 +0200
Add check stage to CI with code style
Checks the code style using the clang-format-diff tool to unify the
coding style to the GNU C coding style.
.gitlab-ci.yml | 15 +++++++++++++++
scripts/check-diff-style.sh | 7 +++++++
2 files changed, 22 insertions(+)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 3b84c613..83525a6e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,5 +1,10 @@
include: 'https://gitlab.gnome.org/GNOME/citemplates/raw/master/flatpak/flatpak_ci_initiative.yml'
+stages:
+ - check
+ - test
+ - deploy
+
variables:
BUNDLE: "org.gnome.GtranslatorDevel.flatpak"
@@ -19,3 +24,13 @@ nightly:
extends: '.publish_nightly'
dependencies:
- 'flatpak'
+
+# Lint the code
+clang-format:
+ stage: check
+ image: fedora:36
+ script:
+ - dnf install -y clang-tools-extra
+ - git diff -U0 --no-color --relative $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME | scripts/check-diff-style.sh
+ only:
+ - merge_requests
diff --git a/scripts/check-diff-style.sh b/scripts/check-diff-style.sh
new file mode 100755
index 00000000..936ff049
--- /dev/null
+++ b/scripts/check-diff-style.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+TMP_FILE=$(mktemp)
+clang-format-diff -p1 -style GNU | tee $TMP_FILE
+OUT=$(cat $TMP_FILE | wc -l)
+rm $TMP_FILE
+(( $OUT == 0 ))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]