aboutsummaryrefslogtreecommitdiffhomepage
path: root/.travis-ci.sh
diff options
context:
space:
mode:
Diffstat (limited to '.travis-ci.sh')
-rw-r--r--.travis-ci.sh123
1 files changed, 67 insertions, 56 deletions
diff --git a/.travis-ci.sh b/.travis-ci.sh
index 8008026..8f6a5ca 100644
--- a/.travis-ci.sh
+++ b/.travis-ci.sh
@@ -1,68 +1,76 @@
#!/bin/bash
-# This script is triggered from the script section of .travis.yml
-# It runs the appropriate commands depending on the task requested.
+if [ "$TASK" = "spellcheck" ]; then
+ result=0
+ # Create list of files to be spellchecked
+ spellcheck_files=$(find . -type f | grep -v ".git/")
-set -e
+ # Run spellintian to find spelling errors
+ sl_results=$(xargs spellintian 2>&1 <<< "$spellcheck_files")
-SPELLINGBLACKLIST=$(cat <<-BLACKLIST
--wholename "./.git/*"
-BLACKLIST
-)
+ sl_errors=$(wc -l <<< "$sl_results")
+ sl_errors_dups=$((grep "\(duplicate word\)" | wc -l) <<< "$sl_results")
+ sl_errors_nodups=$((grep -v "\(duplicate word\)" | wc -l) <<< "$sl_results")
-if [[ $TASK = 'spellintian' ]]; then
- # run spellintian only if it is the requested task, ignoring duplicate words
- spellingfiles=$(eval "find ./ -type f -and ! \( \
- $SPELLINGBLACKLIST \
- \) | xargs")
- # count the number of spellintian errors, ignoring duplicate words
- spellingerrors=$(zrun spellintian $spellingfiles 2>&1 | grep -v "\(duplicate word\)" | wc -l)
- if [[ $spellingerrors -ne 0 ]]; then
- # print the output for info
- zrun spellintian $spellingfiles | grep -v "\(duplicate word\)"
- echo "Found $spellingerrors spelling errors via spellintian, ignoring duplicates"
- exit 1;
+ if [ "$sl_errors" -ne 0 ]; then
+ printf "Spellintian found %s errors (%s spelling, %s duplicate words):\n\n" "$sl_errors" "$sl_errors_nodups" "$sl_errors_dups"
+ printf "%s\n\n" "$sl_results"
+ result=1
else
- echo "Found $spellingerrors spelling errors via spellintian, ignoring duplicates"
- fi;
-elif [[ $TASK = 'spellintian-duplicates' ]]; then
- # run spellintian only if it is the requested task
- spellingfiles=$(eval "find ./ -type f -and ! \( \
- $SPELLINGBLACKLIST \
- \) | xargs")
- # count the number of spellintian errors
- spellingerrors=$(zrun spellintian $spellingfiles 2>&1 | wc -l)
- if [[ $spellingerrors -ne 0 ]]; then
- # print the output for info
- zrun spellintian $spellingfiles
- echo "Found $spellingerrors spelling errors via spellintian"
- exit 1;
- else
- echo "Found $spellingerrors spelling errors via spellintian"
- fi;
-elif [[ $TASK = 'codespell' ]]; then
- # run codespell only if it is the requested task
- spellingfiles=$(eval "find ./ -type f -and ! \( \
- $SPELLINGBLACKLIST \
- \) | xargs")
- # count the number of codespell errors
- spellingerrors=$(zrun codespell --check-filenames --check-hidden --quiet 2 --regex "[a-zA-Z0-9][\\-'a-zA-Z0-9]+[a-zA-Z0-9]" $spellingfiles 2>&1 | wc -l)
- if [[ $spellingerrors -ne 0 ]]; then
- # print the output for info
- zrun codespell --check-filenames --check-hidden --quiet 2 --regex "[a-zA-Z0-9][\\-'a-zA-Z0-9]+[a-zA-Z0-9]" $spellingfiles
- echo "Found $spellingerrors spelling errors via codespell"
- exit 1;
+ printf "Spellintian reports no errors\n"
+ fi
+
+ # Run codespell to find some more
+ cs_results=$(xargs codespell --quiet 2 <<< "$spellcheck_files" 2>&1)
+ cs_errors=$(wc -l <<< "$cs_results")
+ if [ "$cs_errors" -ne 0 ]; then
+ printf "Codespell found %s errors:\n\n" "$cs_errors"
+ printf "%s\n\n" "$cs_results"
+ result=1
else
- echo "Found $spellingerrors spelling errors via codespell"
- fi;
-elif [[ $TASK = 'sanitize' ]]; then
+ printf "Codespell reports no errors\n"
+ fi
+ exit "$result"
+elif [ "$TASK" = "codesmell" ]; then
+ result=0
+
+ if [ -z "$(which lizard)" ]; then
+ printf "Installing lizard...\n"
+ pip3 install lizard
+ fi
+
+ # Run shellcheck for all shell scripts
+ printf "Running shellcheck...\n"
+ shell_files="$(find . -type f -iname \*.sh)"
+ xargs shellcheck -Cnever -s bash <<< "$shell_files"
+ if [ "$?" -ne "0" ]; then
+ result=1
+ fi
+
+ # Run cloc for some stats
+ printf "Code statistics:\n\n"
+ cloc ./
+
+ # Run lizard for the project
+ printf "Running lizard for code complexity analysis\n"
+ lizard ./
+ if [ "$?" -ne "0" ]; then
+ result=1
+ fi
+
+ exit "$result"
+elif [ "$TASK" = "sanitize" ]; then
# Run sanitized compile
travis_fold start "make_sanitize"
- make sanitize;
+ if ! make sanitize; then
+ exit "$?"
+ fi
travis_fold end "make_sanitize"
-elif [[ $TASK = 'windows' ]]; then
+elif [ "$TASK" = "windows" ]; then
travis_fold start "make_windows"
- make windows;
+ if ! make windows; then
+ exit "$?"
+ fi
make -C backends lua.dll
travis_fold end "make_windows"
if [ "$(git describe)" == "$(git describe --abbrev=0)" ]; then
@@ -72,6 +80,7 @@ elif [[ $TASK = 'windows' ]]; then
mkdir ./deployment/docs
cp ./midimonster.exe ./deployment/
cp ./backends/*.dll ./deployment/backends/
+ cp ./backends/*.dll.disabled ./deployment/backends/
cp ./monster.cfg ./deployment/monster.cfg
cp ./backends/*.md ./deployment/docs/
cp -r ./configs ./deployment/
@@ -83,7 +92,9 @@ elif [[ $TASK = 'windows' ]]; then
else
# Otherwise compile as normal
travis_fold start "make"
- make full;
+ if ! make full; then
+ exit "$?"
+ fi
travis_fold end "make"
if [ "$(git describe)" == "$(git describe --abbrev=0)" ]; then
travis_fold start "deploy_unix"
@@ -96,7 +107,7 @@ else
cp ./backends/*.md ./deployment/docs/
cp -r ./configs ./deployment/
cd ./deployment
- tar czf "midimonster-$(git describe)-$TRAVIS_OS_NAME.tgz" *
+ tar czf "midimonster-$(git describe)-$TRAVIS_OS_NAME.tgz" ./
find . ! -iname '*.tgz' -delete
travis_fold end "deploy_unix"
fi