[gjs: 1/4] CI: add cpplint
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 1/4] CI: add cpplint
- Date: Tue, 6 Mar 2018 13:36:08 +0000 (UTC)
commit cee91e97a36b482180278f3d34652aea23c37064
Author: Claudio André <claudioandre br gmail com>
Date: Sun Mar 4 13:56:35 2018 -0300
CI: add cpplint
.gitlab-ci.yml | 8 ++++++++
test/test-ci.sh | 29 +++++++++++++++++++++++++++++
2 files changed, 37 insertions(+)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 43bad5a..5688d2f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -19,6 +19,7 @@ stages:
- $(pwd)/.cache/jhbuild/build/gjs/Makefile
- $(pwd)/coverage/
- $(pwd)/cppcheck/
+ - $(pwd)/cpplint/
- $(pwd)/tokei/
script:
@@ -126,6 +127,13 @@ cppcheck:
variables:
CODECHECK: "CPPCHECK"
+cpplint:
+ <<: *build
+ stage: static_analysis
+ image: claudioandre/spidermonkey:fedora.dev.gcc
+ variables:
+ CODECHECK: "CPPLINT"
+
code_statistics:
<<: *build
stage: static_analysis
diff --git a/test/test-ci.sh b/test/test-ci.sh
index 9ecdf23..a4342e5 100755
--- a/test/test-ci.sh
+++ b/test/test-ci.sh
@@ -66,6 +66,7 @@ source test/extra/do_jhbuild.sh
save_dir="$(pwd)"
mkdir -p "$save_dir"/coverage; touch "$save_dir"/coverage/doing-"$1"
mkdir -p "$save_dir"/cppcheck; touch "$save_dir"/cppcheck/doing-"$1"
+mkdir -p "$save_dir"/cpplint; touch "$save_dir"/cpplint/doing-"$1"
mkdir -p "$save_dir"/tokei; touch "$save_dir"/tokei/doing-"$1"
if [[ $1 == "GJS" ]]; then
@@ -144,6 +145,34 @@ elif [[ $1 == "CPPCHECK" ]]; then
exit 3
fi
+elif [[ $1 == "CPPLINT" ]]; then
+ # Install needed packages
+ pip install cpplint
+
+ echo
+ echo '-- Lint report --'
+ cpplint $(find . -name \*.cpp -or -name \*.c -or -name \*.h | sort) 2>&1 | \
+ tee "$save_dir"/cpplint/current-report.txt | sed -E 's/:[0-9]+:/:LINE:/' | tee
/cwd/current-report.txt
+ echo
+
+ mkdir -p ~/tmp-upstream; cd ~/tmp-upstream || exit 1
+ git clone --depth 1 https://gitlab.gnome.org/GNOME/gjs.git; cd gjs || exit 1
+
+ echo '-- Master Lint report --'
+ cpplint $(find . -name \*.cpp -or -name \*.c -or -name \*.h | sort) 2>&1 | \
+ tee "$save_dir"/cpplint/master-report.txt | sed -E 's/:[0-9]+:/:LINE:/' | tee /cwd/master-report.txt
+ echo
+
+ # Compare the report with master and fails if new warnings are found
+ if ! diff --brief /cwd/master-report.txt /cwd/current-report.txt > /dev/null; then
+ echo '----------------------------------------'
+ echo '### New warnings found by cpplint ###'
+ echo '----------------------------------------'
+ diff -u /cwd/master-report.txt /cwd/current-report.txt || true
+ echo '----------------------------------------'
+ exit 4
+ fi
+
elif [[ $1 == "TOKEI" ]]; then
echo
echo '-- Project statistics --'
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]