summaryrefslogtreecommitdiffstats
path: root/jjb/kuberef/kuberef-run-linting.sh
diff options
context:
space:
mode:
authorVictor Morales <v.morales@samsung.com>2020-08-13 18:49:28 -0400
committerVictor Morales <v.morales@samsung.com>2020-08-13 19:28:36 -0400
commitcb2a4f34df19398c2800beca0d8723ad4f0d2573 (patch)
tree5e026811c1284705d8c4870c940e7b635330e17a /jjb/kuberef/kuberef-run-linting.sh
parent0c108ad88bad281eaea677419969d5dc0e641517 (diff)
Add Lint process to Kuberef
Lint tools allow to check syntax errors and verify best practices on coding. This change includes a Jenkins Job for running those tools on every change submitted. Signed-off-by: Victor Morales <v.morales@samsung.com> Change-Id: I0a4a5378a8e75322993be049b961886d5595c0db
Diffstat (limited to 'jjb/kuberef/kuberef-run-linting.sh')
-rwxr-xr-xjjb/kuberef/kuberef-run-linting.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/jjb/kuberef/kuberef-run-linting.sh b/jjb/kuberef/kuberef-run-linting.sh
new file mode 100755
index 000000000..4f681ac53
--- /dev/null
+++ b/jjb/kuberef/kuberef-run-linting.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2020 Samsung Electronics
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+set -o nounset
+set -o pipefail
+set -o xtrace
+
+# shellcheck disable=SC1091
+source /etc/os-release || source /usr/lib/os-release
+
+pkgs=""
+if ! command -v shellcheck; then
+ case ${ID,,} in
+ *suse*|rhel|centos|fedora)
+ pkgs="ShellCheck"
+ ;;
+ ubuntu|debian)
+ pkgs="shellcheck"
+ ;;
+ esac
+fi
+
+if ! command -v pip; then
+ pkgs+=" python-pip"
+fi
+
+if [ -n "$pkgs" ]; then
+ case ${ID,,} in
+ *suse*)
+ sudo zypper install --gpg-auto-import-keys refresh
+ sudo -H -E zypper install -y --no-recommends "$pkgs"
+ ;;
+ ubuntu|debian)
+ sudo apt-get update
+ sudo -H -E apt-get -y --no-install-recommends install "$pkgs"
+ ;;
+ rhel|centos|fedora)
+ PKG_MANAGER=$(command -v dnf || command -v yum)
+ if ! sudo "$PKG_MANAGER" repolist | grep "epel/"; then
+ sudo -H -E "$PKG_MANAGER" -q -y install epel-release
+ fi
+ sudo "$PKG_MANAGER" updateinfo --assumeyes
+ sudo -H -E "${PKG_MANAGER}" -y install "$pkgs"
+ ;;
+ esac
+fi
+
+tox -e lint
+bash -c 'shopt -s globstar; shellcheck **/*.sh'