[glib: 1/4] add 2 new stages: sh-check (which run shellcheck) and py-check (which run black and flake8)




commit 8f45fbdaddff5269d113ee2f0d4cbf1794288a98
Author: Frederic Martinsons <frederic martinsons sigfox com>
Date:   Tue Nov 10 09:53:00 2020 +0100

    add 2 new stages: sh-check (which run shellcheck) and py-check (which run black and flake8)
    
    The debian docker have been modified to install these tools.
    
    Closes #2046
    
    Signed-off-by: Frederic Martinsons <frederic martinsons sigfox com>

 .gitlab-ci.yml                      | 25 ++++++++++++++++++++++++-
 .gitlab-ci/debian-stable.Dockerfile |  3 +++
 .gitlab-ci/run-black.sh             |  5 +++++
 .gitlab-ci/run-flake8.sh            |  5 +++++
 .gitlab-ci/run-shellcheck.sh        |  6 ++++++
 5 files changed, 43 insertions(+), 1 deletion(-)
---
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..35ecec527
--- /dev/null
+++ b/.gitlab-ci/run-black.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+set -e
+
+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..1776cad97
--- /dev/null
+++ b/.gitlab-ci/run-flake8.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+set -e
+
+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..f6d2dd59f
--- /dev/null
+++ b/.gitlab-ci/run-shellcheck.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+set -e
+
+# Ignoring third-party directories that we don't want to parse
+shellcheck $(git ls-files '*.sh' | grep -Ev "glib/libcharset|glib/dirent")


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]