From 20803bd7d7578706ad55b56cf1a4d8865b5c1285 Mon Sep 17 00:00:00 2001 From: cbdev Date: Wed, 11 Mar 2020 20:44:24 +0100 Subject: Restructure CI spellchecking --- .travis-ci.sh | 80 +++++++++++++++++++++-------------------------------------- 1 file changed, 28 insertions(+), 52 deletions(-) (limited to '.travis-ci.sh') diff --git a/.travis-ci.sh b/.travis-ci.sh index 8008026..e9e3df3 100644 --- a/.travis-ci.sh +++ b/.travis-ci.sh @@ -1,66 +1,42 @@ #!/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=$(spellintian $spellcheck_files 2>&1) -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=$(codespell --check-filenames --check-hidden --quiet 2 --regex "[a-zA-Z0-9][\\-'a-zA-Z0-9]+[a-zA-Z0-9]" $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" = 'sanitize' ]; then # Run sanitized compile travis_fold start "make_sanitize" make sanitize; travis_fold end "make_sanitize" -elif [[ $TASK = 'windows' ]]; then +elif [ "$TASK" = 'windows' ]; then travis_fold start "make_windows" make windows; make -C backends lua.dll -- cgit v1.2.3 From abb1ffd367f4046d77ac62b0b017b407997bc43b Mon Sep 17 00:00:00 2001 From: cbdev Date: Wed, 11 Mar 2020 21:53:14 +0100 Subject: Add codesmell statistics to CI --- .travis-ci.sh | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to '.travis-ci.sh') diff --git a/.travis-ci.sh b/.travis-ci.sh index e9e3df3..763e558 100644 --- a/.travis-ci.sh +++ b/.travis-ci.sh @@ -21,7 +21,7 @@ if [ "$TASK" = "spellcheck" ]; then fi # Run codespell to find some more - cs_results=$(codespell --check-filenames --check-hidden --quiet 2 --regex "[a-zA-Z0-9][\\-'a-zA-Z0-9]+[a-zA-Z0-9]" $spellcheck_files 2>&1) + cs_results=$(codespell --check-hidden --quiet 2 --regex "[a-zA-Z0-9][\\-'a-zA-Z0-9]+[a-zA-Z0-9]" $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" @@ -31,12 +31,40 @@ if [ "$TASK" = "spellcheck" ]; then printf "Codespell reports no errors\n" fi exit "$result" -elif [ "$TASK" = 'sanitize' ]; then +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; travis_fold end "make_sanitize" -elif [ "$TASK" = 'windows' ]; then +elif [ "$TASK" = "windows" ]; then travis_fold start "make_windows" make windows; make -C backends lua.dll -- cgit v1.2.3 From 9ec65119e11941d81a641f6387cdb542b4e8070e Mon Sep 17 00:00:00 2001 From: cbdev Date: Wed, 11 Mar 2020 22:23:55 +0100 Subject: Refactor installer --- .travis-ci.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to '.travis-ci.sh') diff --git a/.travis-ci.sh b/.travis-ci.sh index 763e558..3b7d7f5 100644 --- a/.travis-ci.sh +++ b/.travis-ci.sh @@ -3,10 +3,10 @@ if [ "$TASK" = "spellcheck" ]; then result=0 # Create list of files to be spellchecked - spellcheck_files=$(find -type f | grep -v ".git/") + spellcheck_files=$(find . -type f | grep -v ".git/") # Run spellintian to find spelling errors - sl_results=$(spellintian $spellcheck_files 2>&1) + sl_results=$(xargs spellintian 2>&1 <<< "$spellcheck_files") sl_errors=$(wc -l <<< "$sl_results") sl_errors_dups=$((grep "\(duplicate word\)" | wc -l) <<< "$sl_results") @@ -21,7 +21,7 @@ if [ "$TASK" = "spellcheck" ]; then fi # Run codespell to find some more - cs_results=$(codespell --check-hidden --quiet 2 --regex "[a-zA-Z0-9][\\-'a-zA-Z0-9]+[a-zA-Z0-9]" $spellcheck_files 2>&1) + cs_results=$(xargs codespell --quiet 2 --regex "[a-zA-Z0-9][\\-'a-zA-Z0-9]+[a-zA-Z0-9]" <<< "$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" @@ -100,7 +100,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 -- cgit v1.2.3 From 6da00154f7745a4705047fc73ce42b7036b0bbdc Mon Sep 17 00:00:00 2001 From: cbdev Date: Sun, 15 Mar 2020 12:19:50 +0100 Subject: Fix build and CI exits --- .travis-ci.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to '.travis-ci.sh') diff --git a/.travis-ci.sh b/.travis-ci.sh index 3b7d7f5..c832f2c 100644 --- a/.travis-ci.sh +++ b/.travis-ci.sh @@ -21,7 +21,7 @@ if [ "$TASK" = "spellcheck" ]; then fi # Run codespell to find some more - cs_results=$(xargs codespell --quiet 2 --regex "[a-zA-Z0-9][\\-'a-zA-Z0-9]+[a-zA-Z0-9]" <<< "$spellcheck_files" 2>&1) + 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" @@ -62,11 +62,15 @@ elif [ "$TASK" = "codesmell" ]; then 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 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 @@ -87,7 +91,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" -- cgit v1.2.3 From bc275e10defe27e6d288ccf9125fe9b915168240 Mon Sep 17 00:00:00 2001 From: cbdev Date: Tue, 21 Apr 2020 00:20:23 +0200 Subject: Do not load lua backend automatically on Windows --- .travis-ci.sh | 3 +++ 1 file changed, 3 insertions(+) (limited to '.travis-ci.sh') diff --git a/.travis-ci.sh b/.travis-ci.sh index c832f2c..5272fde 100644 --- a/.travis-ci.sh +++ b/.travis-ci.sh @@ -71,7 +71,9 @@ elif [ "$TASK" = "windows" ]; then if make windows; then exit "$?" fi + # Build the lua backend but disable it by default to avoid scary error messages make -C backends lua.dll + mv backends/lua.dll backends/lua.dll.disabled travis_fold end "make_windows" if [ "$(git describe)" == "$(git describe --abbrev=0)" ]; then travis_fold start "deploy_windows" @@ -80,6 +82,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/ -- cgit v1.2.3 From 6503d83dee9c2c7dd30572b84f11b95f832e9309 Mon Sep 17 00:00:00 2001 From: cbdev Date: Sun, 26 Apr 2020 21:50:00 +0200 Subject: Disable stop-the-world windows error messages --- .travis-ci.sh | 1 - 1 file changed, 1 deletion(-) (limited to '.travis-ci.sh') diff --git a/.travis-ci.sh b/.travis-ci.sh index 5272fde..39652a1 100644 --- a/.travis-ci.sh +++ b/.travis-ci.sh @@ -73,7 +73,6 @@ elif [ "$TASK" = "windows" ]; then fi # Build the lua backend but disable it by default to avoid scary error messages make -C backends lua.dll - mv backends/lua.dll backends/lua.dll.disabled travis_fold end "make_windows" if [ "$(git describe)" == "$(git describe --abbrev=0)" ]; then travis_fold start "deploy_windows" -- cgit v1.2.3 From 929026130c7866d9b70be7a6cc820f103ae241b4 Mon Sep 17 00:00:00 2001 From: cbdev Date: Sun, 26 Apr 2020 22:54:17 +0200 Subject: Periodically retry connecting remotes for maweb --- .travis-ci.sh | 1 - 1 file changed, 1 deletion(-) (limited to '.travis-ci.sh') diff --git a/.travis-ci.sh b/.travis-ci.sh index 39652a1..40beec6 100644 --- a/.travis-ci.sh +++ b/.travis-ci.sh @@ -71,7 +71,6 @@ elif [ "$TASK" = "windows" ]; then if make windows; then exit "$?" fi - # Build the lua backend but disable it by default to avoid scary error messages make -C backends lua.dll travis_fold end "make_windows" if [ "$(git describe)" == "$(git describe --abbrev=0)" ]; then -- cgit v1.2.3 From c0bb55ff08faf2f89af947090d1c9bc412927d9f Mon Sep 17 00:00:00 2001 From: cbdev Date: Mon, 27 Apr 2020 22:20:19 +0200 Subject: Fix CI script --- .travis-ci.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to '.travis-ci.sh') diff --git a/.travis-ci.sh b/.travis-ci.sh index 40beec6..8f6a5ca 100644 --- a/.travis-ci.sh +++ b/.travis-ci.sh @@ -62,13 +62,13 @@ elif [ "$TASK" = "codesmell" ]; then elif [ "$TASK" = "sanitize" ]; then # Run sanitized compile travis_fold start "make_sanitize" - if make sanitize; then + if ! make sanitize; then exit "$?" fi travis_fold end "make_sanitize" elif [ "$TASK" = "windows" ]; then travis_fold start "make_windows" - if make windows; then + if ! make windows; then exit "$?" fi make -C backends lua.dll @@ -92,7 +92,7 @@ elif [ "$TASK" = "windows" ]; then else # Otherwise compile as normal travis_fold start "make" - if make full; then + if ! make full; then exit "$?" fi travis_fold end "make" -- cgit v1.2.3