Commit d4a6f322 authored by Maciej Delmanowski's avatar Maciej Delmanowski

Merge branch 'drybjed-shellcheck-tests'

parents 2defe0d9 edd9bab1
Pipeline #17320600 passed with stages
in 4 minutes and 6 seconds
......@@ -24,6 +24,7 @@ before_install:
- 'sudo apt-get install -yq graphviz'
- 'pip install --upgrade pip six setuptools wheel'
- 'pip install pycodestyle unittest2 nose2 cov-core ansible sphinx sphinx-autobuild sphinx_rtd_theme yamllint'
- './lib/tests/travis-shellcheck'
- 'pip list'
......@@ -28,6 +28,10 @@ docs: test-docs
pep8: ## Test Python PEP8 compliance
pep8: test-pep8
.PHONY: shell
shell: ## Test shell script syntax
shell: test-shell
.PHONY: syntax
syntax: ## Check Ansible playbook syntax
syntax: test-playbook-syntax
......@@ -81,7 +85,7 @@ twine-upload: ## Upload Python packages to PyPI
@twine upload dist/*
.PHONY: test-all
test-all: clean-tests test-pep8 test-debops-tools test-docs test-playbook-syntax test-yaml test-docker-build
test-all: clean-tests test-pep8 test-debops-tools test-docs test-playbook-syntax test-yaml test-shell test-docker-build
.PHONY: test-pep8
......@@ -89,6 +93,11 @@ test-pep8:
@pycodestyle --show-source --statistics .
@./lib/tests/check-pep8 || true
.PHONY: test-shell
@printf "%s\n" "Testing shell syntax using shellcheck..."
@./lib/tests/check-shell || true
.PHONY: test-docker-build
#!/usr/bin/env bash
# Find all shell scripts and check their compliance using shellcheck
# Copyright (C) 2018 Maciej Delmanowski <>
# Copyright (C) 2018 DebOps
set -o nounset -o pipefail -o errexit
declare -a file_list
if ! type shellcheck > /dev/null 2>&1 ; then
printf "%s\n" "Error: shellcheck not found"
exit 1
printf "%s " "Searching for shell scripts"
while read in ; do
if file "${in}" | grep -q -E 'Bourne-Again shell script|bash script' ; then
counter=$(( counter + 1 ))
counter_state=$(( counter % 5 ))
if [ ${counter_state} -eq 0 ] ; then
printf "%s" "."
done < <(find . -type f)
printf " %s\n" "found ${#file_list[@]} shell scripts"
shellcheck "${file_list[@]}"
#!/usr/bin/env bash
# Install shellcheck in Travis CI environment
set -o nounset -o pipefail -o errexit
install_shellcheck () {
printf "Installing shellcheck from Debian Sid.\n"
curl -sSL "" | sudo -E apt-key add -
printf "deb unstable main contrib non-free\n" | sudo tee /etc/apt/sources.list.d/sid.list
sudo apt-get -qq update
sudo apt-get -yq install -t sid shellcheck
# Disable Debian Sid to not interfere with other packages
sudo rm -f /etc/apt/sources.list.d/sid.list
sudo apt-get -qq update
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment