summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip@tecnocode.co.uk>2020-11-17 14:23:17 +0000
committerPhilip Withnall <philip@tecnocode.co.uk>2020-11-17 14:23:17 +0000
commit053d2ae2b4cd31c98f1523f0bc7748296e633b6d (patch)
tree062a17a79254343ff153337a7c8b2e6a9657ef36
parentc3388932fd159c14155ece9809d3642347558b3d (diff)
parentbafc7cf1b13646afdff921fab39be27ea6c6aead (diff)
downloadglib-053d2ae2b4cd31c98f1523f0bc7748296e633b6d.tar.gz
Merge branch '2046-add-shellcheck-pylint-in-ci' into 'master'
resolve "Add pylint and shellcheck CI checks" Closes #2046 See merge request GNOME/glib!1743
-rw-r--r--.gitlab-ci.yml25
-rw-r--r--.gitlab-ci/debian-stable.Dockerfile3
-rwxr-xr-x.gitlab-ci/run-black.sh6
-rwxr-xr-x.gitlab-ci/run-flake8.sh6
-rwxr-xr-x.gitlab-ci/run-shellcheck.sh7
-rwxr-xr-xcheck-abis.sh4
-rw-r--r--gio/tests/x-content/unix-software/autorun.sh2
-rwxr-xr-xsanity_check40
-rwxr-xr-xtests/run-assert-msg-test.sh1
9 files changed, 50 insertions, 44 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a89211a35..80dbfef83 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -12,7 +12,7 @@ cache:
variables:
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/glib/fedora:v9"
COVERITY_IMAGE: "registry.gitlab.gnome.org/gnome/glib/coverity:v1"
- DEBIAN_IMAGE: "registry.gitlab.gnome.org/gnome/glib/debian-stable:v6"
+ DEBIAN_IMAGE: "registry.gitlab.gnome.org/gnome/glib/debian-stable:v7"
ANDROID_IMAGE: "registry.gitlab.gnome.org/gnome/glib/android-ndk:v3"
MINGW_IMAGE: "registry.gitlab.gnome.org/gnome/glib/mingw:v2"
MESON_TEST_TIMEOUT_MULTIPLIER: 2
@@ -40,6 +40,29 @@ variables:
only:
- schedules
+sh-check:
+ extends: .only-default
+ image: $DEBIAN_IMAGE
+ stage: style-check
+ allow_failure: true
+ script:
+ - .gitlab-ci/run-shellcheck.sh
+ only:
+ changes:
+ - "**/*.sh"
+
+py-check:
+ extends: .only-default
+ image: $DEBIAN_IMAGE
+ stage: style-check
+ allow_failure: true
+ script:
+ - .gitlab-ci/run-black.sh
+ - .gitlab-ci/run-flake8.sh
+ only:
+ changes:
+ - "**/*.py"
+
style-check-diff:
extends: .only-default
image: $DEBIAN_IMAGE
diff --git a/.gitlab-ci/debian-stable.Dockerfile b/.gitlab-ci/debian-stable.Dockerfile
index 54d2d8c24..38758fc9e 100644
--- a/.gitlab-ci/debian-stable.Dockerfile
+++ b/.gitlab-ci/debian-stable.Dockerfile
@@ -2,6 +2,7 @@ FROM debian:buster
RUN apt-get update -qq && apt-get install --no-install-recommends -qq -y \
bindfs \
+ black \
clang \
clang-tools-7 \
clang-format-7 \
@@ -9,6 +10,7 @@ RUN apt-get update -qq && apt-get install --no-install-recommends -qq -y \
desktop-file-utils \
elfutils \
findutils \
+ flake8 \
fuse \
gcc \
g++ \
@@ -36,6 +38,7 @@ RUN apt-get update -qq && apt-get install --no-install-recommends -qq -y \
python3-setuptools \
python3-wheel \
shared-mime-info \
+ shellcheck \
systemtap-sdt-dev \
unzip \
wget \
diff --git a/.gitlab-ci/run-black.sh b/.gitlab-ci/run-black.sh
new file mode 100755
index 000000000..fdeaf1684
--- /dev/null
+++ b/.gitlab-ci/run-black.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+set -e
+
+# shellcheck disable=SC2046
+black --diff --check $(git ls-files '*.py')
diff --git a/.gitlab-ci/run-flake8.sh b/.gitlab-ci/run-flake8.sh
new file mode 100755
index 000000000..2a7628303
--- /dev/null
+++ b/.gitlab-ci/run-flake8.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+set -e
+
+# shellcheck disable=SC2046
+flake8 --max-line-length=88 $(git ls-files '*.py')
diff --git a/.gitlab-ci/run-shellcheck.sh b/.gitlab-ci/run-shellcheck.sh
new file mode 100755
index 000000000..abf2e5ef3
--- /dev/null
+++ b/.gitlab-ci/run-shellcheck.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+set -e
+
+# Ignoring third-party directories that we don't want to parse
+# shellcheck disable=SC2046
+shellcheck $(git ls-files '*.sh' | grep -Ev "glib/libcharset|glib/dirent")
diff --git a/check-abis.sh b/check-abis.sh
index a18103bf8..5340f317d 100755
--- a/check-abis.sh
+++ b/check-abis.sh
@@ -1,11 +1,11 @@
#!/bin/sh -e
list_leaked_symbols () {
- nm -D "$1" | grep ' T ' | cut -f 3 -d ' ' | egrep -v "$2"
+ nm -D "$1" | grep ' T ' | cut -f 3 -d ' ' | grep -E -v "$2"
}
check_symbols () {
- if [ "`list_leaked_symbols "$1" "$2" | wc -l`" -ne 0 ]; then
+ if [ "$(list_leaked_symbols "$1" "$2" | wc -l)" -ne 0 ]; then
echo File "$1" possibly leaking symbols:
list_leaked_symbols "$1" "$2"
exit 1
diff --git a/gio/tests/x-content/unix-software/autorun.sh b/gio/tests/x-content/unix-software/autorun.sh
index 6dfc55944..ef09a62a6 100644
--- a/gio/tests/x-content/unix-software/autorun.sh
+++ b/gio/tests/x-content/unix-software/autorun.sh
@@ -1,3 +1,3 @@
#! /bin/sh
-do something here
+# do something here
diff --git a/sanity_check b/sanity_check
deleted file mode 100755
index 44ae7f1f3..000000000
--- a/sanity_check
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/sh
-
-VERSION=$1
-
-if [ ! -f glib-$VERSION.tar.gz ]; then
- echo "ERROR: glib-$VERSION.tar.gz does not exist..."
- exit 1
-fi
-
-echo ""
-
-echo "Checking glib-$VERSION.tar.gz..."
-tar xfz glib-$VERSION.tar.gz
-
-
-for file in INSTALL NEWS
-do
- echo -n "$file... "
- if [ "x`grep $VERSION glib-$VERSION/$file | wc -l | awk -F' ' '{print $1}'`" = "x0" ]; then
- echo "failed."
- #exit 1
- else
- echo "ok"
- fi
-done
-
-echo -n "INSTALL..."
-if [ "x`grep $VERSION glib-$VERSION/INSTALL | wc -l | awk -F' ' '{print $1}'`" = "x2" ]; then
- echo "ok"
-else
- echo "failed."
- exit 1
-fi
-
-echo ""
-echo "Number of lines in created documentation files:"
-
-wc -l glib-$VERSION/docs/reference/*/html/*.html | grep total
-
-rm -rf glib-$VERSION
diff --git a/tests/run-assert-msg-test.sh b/tests/run-assert-msg-test.sh
index 526c75a81..88f86f1e2 100755
--- a/tests/run-assert-msg-test.sh
+++ b/tests/run-assert-msg-test.sh
@@ -41,6 +41,7 @@ echo_v "Running gdb on assert-msg-test"
OUT=$($LIBTOOL --mode=execute gdb --batch -x "${srcdir:-.}/assert-msg-test.gdb" ./assert-msg-test 2> $error_out) || fail "failed to run gdb"
echo_v "Checking if assert message is in __glib_assert_msg"
+# shellcheck disable=SC2016
if ! echo "$OUT" | grep -q '^$1.*"GLib:ERROR:.*assert-msg-test.c:.*:.*main.*: assertion failed: (42 < 0)"'; then
fail "__glib_assert_msg does not have assertion message"
fi