
* shellcheck utility allow to determinate common mistakes of bash scripting[1] * yamllint utility allow to determinate common mistakes of yaml files[3] * Add List system dependencies for running common tests Add an other-requirements.txt file containing a cross-platform list of dependencies needed for running included tox-based tests. Also include a tox environment for convenience calling the bindep[2] utility to list any missing system requirements. For other-requirements.txt see also: http://docs.openstack.org/infra/manual/drivers.html#package-requirements [1] http://hackage.haskell.org/package/ShellCheck [2] http://docs.openstack.org/infra/bindep/ [3] https://pypi.python.org/pypi/yamllint/ Change-Id: Ia2498bdb0f7c310ec3d2c2f11f5d3fc08c8b352c
56 lines
1.3 KiB
Bash
Executable File
56 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
WORKSPACE="${WORKSPACE:-${1}}"
|
|
|
|
function help_m() {
|
|
cat <<-EOF
|
|
***********************************************************************
|
|
Shellcheck script help message:
|
|
Please use env variable:
|
|
- Set directory for scan:
|
|
export WORKSPACE='/dir/with/sh/files/to/scan'
|
|
- or directly:
|
|
./shellcheck.sh "/dir/with/sh/files/to/scan"
|
|
***********************************************************************
|
|
EOF
|
|
}
|
|
|
|
function run_check() {
|
|
local e_count=0
|
|
|
|
cat <<-EOF
|
|
***********************************************************************
|
|
*
|
|
* Starting shellcheck against dir:"${WORKSPACE}"
|
|
*
|
|
***********************************************************************
|
|
EOF
|
|
while read -d '' -r script; do
|
|
unset RESULT
|
|
shellcheck "${script}"
|
|
RESULT=$?
|
|
if [ ${RESULT} != 0 ]; then
|
|
((e_count++))
|
|
fi
|
|
done < <(find "${WORKSPACE}" -name '*.sh' -print0)
|
|
cat <<-EOF
|
|
***********************************************************************
|
|
*
|
|
* shellcheck finished with ${e_count} errors.
|
|
*
|
|
***********************************************************************
|
|
EOF
|
|
if [ "${e_count}" -gt 0 ] ; then
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
### Body:
|
|
|
|
if [[ -z "${WORKSPACE}" ]]; then
|
|
echo "ERROR: \${WORKSPACE} variable is not set!"
|
|
help_m
|
|
exit 1
|
|
fi
|
|
run_check
|