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>
This commit is contained in:
Frederic Martinsons 2020-11-10 09:53:00 +01:00
parent 728c591d76
commit 8f45fbdadd
5 changed files with 43 additions and 1 deletions

View File

@ -12,7 +12,7 @@ cache:
variables: variables:
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/glib/fedora:v9" FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/glib/fedora:v9"
COVERITY_IMAGE: "registry.gitlab.gnome.org/gnome/glib/coverity:v1" 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" ANDROID_IMAGE: "registry.gitlab.gnome.org/gnome/glib/android-ndk:v3"
MINGW_IMAGE: "registry.gitlab.gnome.org/gnome/glib/mingw:v2" MINGW_IMAGE: "registry.gitlab.gnome.org/gnome/glib/mingw:v2"
MESON_TEST_TIMEOUT_MULTIPLIER: 2 MESON_TEST_TIMEOUT_MULTIPLIER: 2
@ -40,6 +40,29 @@ variables:
only: only:
- schedules - 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: style-check-diff:
extends: .only-default extends: .only-default
image: $DEBIAN_IMAGE image: $DEBIAN_IMAGE

View File

@ -2,6 +2,7 @@ FROM debian:buster
RUN apt-get update -qq && apt-get install --no-install-recommends -qq -y \ RUN apt-get update -qq && apt-get install --no-install-recommends -qq -y \
bindfs \ bindfs \
black \
clang \ clang \
clang-tools-7 \ clang-tools-7 \
clang-format-7 \ clang-format-7 \
@ -9,6 +10,7 @@ RUN apt-get update -qq && apt-get install --no-install-recommends -qq -y \
desktop-file-utils \ desktop-file-utils \
elfutils \ elfutils \
findutils \ findutils \
flake8 \
fuse \ fuse \
gcc \ gcc \
g++ \ g++ \
@ -36,6 +38,7 @@ RUN apt-get update -qq && apt-get install --no-install-recommends -qq -y \
python3-setuptools \ python3-setuptools \
python3-wheel \ python3-wheel \
shared-mime-info \ shared-mime-info \
shellcheck \
systemtap-sdt-dev \ systemtap-sdt-dev \
unzip \ unzip \
wget \ wget \

5
.gitlab-ci/run-black.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
set -e
black --diff --check $(git ls-files '*.py')

5
.gitlab-ci/run-flake8.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
set -e
flake8 --max-line-length=88 $(git ls-files '*.py')

6
.gitlab-ci/run-shellcheck.sh Executable file
View File

@ -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")