diff --git a/.travis.yml b/.travis.yml index 79f775399..e6943fadd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,13 @@ language: bash -install: - - ./ci/install.sh +sudo: false + +addons: + apt: + sources: + - debian-sid + packages: + - shellcheck script: - ./ci/build.sh notifications: email: false -sudo: required diff --git a/ci/build.sh b/ci/build.sh index 798bd39ee..ea84f72f4 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -1,46 +1,52 @@ #!/usr/bin/env bash -set -eo pipefail +set -o pipefail [[ "${DEBUG:-}" ]] && set -x declare -i failed failed=0 success() { printf "\r\033[2K [ \033[00;32mOK\033[0m ] Checking %s...\n" "$1" } fail() { printf "\r\033[2K [\033[0;31mFAIL\033[0m] Checking %s...\n" "$1" failed=1 } check() { local script="$1" - shellcheck "$script" || fail "$script" - success "$script" + if shellcheck "$script"; then + success "$script" + else + fail "$script" + fi } find_prunes() { local prunes="! -path './.git/*'" if [ -f .gitmodules ]; then - while read module; do + while read -r module; do prunes="$prunes ! -path './$module/*'" done < <(grep path .gitmodules | awk '{print $3}') fi echo "$prunes" } find_cmd() { - echo "find . -type f -and \( -perm +111 -or -name '*.sh' \) $(find_prunes)" + echo "find . -type f -and \( -perm /111 -or -name '*.sh' \) $(find_prunes)" } check_all_executables() { echo "Checking executables and .sh files..." - eval "$(find_cmd)" | while read script; do + while read -r script; do head=$(head -n1 "$script") + [[ "$head" =~ .*ruby.* ]] && continue + [[ "$head" =~ .*zsh.* ]] && continue + [[ "$head" =~ ^#compdef.* ]] && continue check "$script" - done + done < <(eval "$(find_cmd)") exit $failed } check_all_executables diff --git a/ci/install.sh b/ci/install.sh deleted file mode 100755 index c66b56c59..000000000 --- a/ci/install.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -set -eo pipefail - -main() { - local filename="shellcheck_0.3.7-1_amd64.deb" - wget "http://ftp.debian.org/debian/pool/main/s/shellcheck/$filename" - sudo dpkg -i "$filename" -} - -main