Merge "Add xrally_kubernetes_full in all gates"
[releng.git] / jjb / kuberef / kuberef-run-linting.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2020 Samsung Electronics
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 set -o nounset
12 set -o pipefail
13 set -o xtrace
14
15 # shellcheck disable=SC1091
16 source /etc/os-release || source /usr/lib/os-release
17
18 pkgs=""
19 if ! command -v shellcheck; then
20     case ${ID,,} in
21         *suse*|rhel|centos|fedora)
22             pkgs="ShellCheck"
23         ;;
24         ubuntu|debian)
25             pkgs="shellcheck"
26         ;;
27     esac
28 fi
29
30 if ! command -v pip; then
31     pkgs+=" python-pip"
32 fi
33
34 if [ -n "$pkgs" ]; then
35     case ${ID,,} in
36         *suse*)
37             sudo zypper install --gpg-auto-import-keys refresh
38             sudo -H -E zypper install -y --no-recommends "$pkgs"
39         ;;
40         ubuntu|debian)
41             sudo apt-get update
42             sudo -H -E apt-get -y --no-install-recommends install "$pkgs"
43         ;;
44         rhel|centos|fedora)
45             PKG_MANAGER=$(command -v dnf || command -v yum)
46             if ! sudo "$PKG_MANAGER" repolist | grep "epel/"; then
47                 sudo -H -E "$PKG_MANAGER" -q -y install epel-release
48             fi
49             sudo "$PKG_MANAGER" updateinfo --assumeyes
50             sudo -H -E "${PKG_MANAGER}" -y install "$pkgs"
51         ;;
52     esac
53 fi
54
55 tox -e lint
56 bash -c 'shopt -s globstar; shellcheck  **/*.sh'