From 1fd6f2bf7cd243ad3e2c126ebce723d57000c7b4 Mon Sep 17 00:00:00 2001 From: cbdev Date: Thu, 9 Jul 2020 22:56:31 +0200 Subject: Restructure CI --- .ci.sh | 131 +++++++++++++++++++++++++++++++++++++++++++ .travis-ci.sh | 116 -------------------------------------- .travis.yml | 17 ++---- backends/openpixelcontrol.md | 4 +- 4 files changed, 137 insertions(+), 131 deletions(-) create mode 100755 .ci.sh delete mode 100644 .travis-ci.sh diff --git a/.ci.sh b/.ci.sh new file mode 100755 index 0000000..087bf11 --- /dev/null +++ b/.ci.sh @@ -0,0 +1,131 @@ +#!/bin/bash + +# Check for Travis and use the provided fold method if detected +if declare -f travis_fold > /dev/null; then + ci_fold(){ + travis_fold "$1" "$2" + } +else + ci_fold(){ + printf -- "-- %s stage %s --\n" "$1" "$2" + } +fi + +if [ -z "$OS" ]; then + OS="linux" +fi + +if [ "$TASK" = "spellcheck" ]; then + result=0 + # Create list of files to be spellchecked + spellcheck_files=$(find . -type f | grep -v ".git/") + + # Run spellintian to find spelling errors + sl_results=$(xargs spellintian 2>&1 <<< "$spellcheck_files") + + 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 [ "$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 + 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 + 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 + ci_fold start "make_sanitize" + if ! make sanitize; then + exit "$?" + fi + ci_fold end "make_sanitize" +elif [ "$TASK" = "windows" ]; then + ci_fold start "make_windows" + if ! make windows; then + exit "$?" + fi + make -C backends lua.dll + ci_fold end "make_windows" + if [ "$(git describe)" == "$(git describe --abbrev=0)" ] || [ -n "$DEPLOY" ]; then + ci_fold start "deploy_windows" + mkdir ./deployment + mkdir ./deployment/backends + mkdir ./deployment/docs + # Strip the Windows binaries as they become huge quickly + strip midimonster.exe backends/*.dll + 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/ + cd ./deployment + zip -r "./midimonster-$(git describe)-windows.zip" "./" + find . ! -iname '*.zip' -delete + ci_fold end "deploy_windows" + fi +else + # Otherwise compile as normal + ci_fold start "make" + if ! make full; then + exit "$?" + fi + ci_fold end "make" + if [ "$(git describe)" == "$(git describe --abbrev=0)" ] || [ -n "$DEPLOY" ]; then + ci_fold start "deploy_unix" + mkdir ./deployment + mkdir ./deployment/backends + mkdir ./deployment/docs + cp ./midimonster ./deployment/ + cp ./backends/*.so ./deployment/backends/ + cp ./monster.cfg ./deployment/monster.cfg + cp ./backends/*.md ./deployment/docs/ + cp -r ./configs ./deployment/ + cd ./deployment + tar czf "midimonster-$(git describe)-$OS.tgz" "./" + find . ! -iname '*.tgz' -delete + ci_fold end "deploy_unix" + fi +fi diff --git a/.travis-ci.sh b/.travis-ci.sh deleted file mode 100644 index c72070e..0000000 --- a/.travis-ci.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/bash - -if [ "$TASK" = "spellcheck" ]; then - result=0 - # Create list of files to be spellchecked - spellcheck_files=$(find . -type f | grep -v ".git/") - - # Run spellintian to find spelling errors - sl_results=$(xargs spellintian 2>&1 <<< "$spellcheck_files") - - 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 [ "$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 - 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 - 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" - if ! make sanitize; then - exit "$?" - fi - travis_fold end "make_sanitize" -elif [ "$TASK" = "windows" ]; then - travis_fold start "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)" ] || [ -n "$DEPLOY" ]; then - travis_fold start "deploy_windows" - mkdir ./deployment - mkdir ./deployment/backends - mkdir ./deployment/docs - # Strip the Windows binaries as they become huge quickly - strip midimonster.exe backends/*.dll - 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/ - cd ./deployment - zip -r "./midimonster-$(git describe)-windows.zip" "./" - find . ! -iname '*.zip' -delete - travis_fold end "deploy_windows" - fi -else - # Otherwise compile as normal - travis_fold start "make" - if ! make full; then - exit "$?" - fi - travis_fold end "make" - if [ "$(git describe)" == "$(git describe --abbrev=0)" ] || [ -n "$DEPLOY" ]; then - travis_fold start "deploy_unix" - mkdir ./deployment - mkdir ./deployment/backends - mkdir ./deployment/docs - cp ./midimonster ./deployment/ - cp ./backends/*.so ./deployment/backends/ - cp ./monster.cfg ./deployment/monster.cfg - cp ./backends/*.md ./deployment/docs/ - cp -r ./configs ./deployment/ - cd ./deployment - tar czf "midimonster-$(git describe)-$TRAVIS_OS_NAME.tgz" ./ - find . ! -iname '*.tgz' -delete - travis_fold end "deploy_unix" - fi -fi diff --git a/.travis.yml b/.travis.yml index 4e14339..5f60e59 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,17 +5,15 @@ dist: bionic before_script: - export -f travis_fold + - export OS="$TRAVIS_OS_NAME" script: - - "bash .travis-ci.sh" + - "bash .ci.sh" addons: apt: - packages: &base_build - - ccache packages: &core_build # This is all the bits we need to enable all options - - *base_build - libasound2-dev - libevdev-dev - libola-dev @@ -125,11 +123,6 @@ env: cache: apt: true - directories: - - $HOME/.ccache # ccache cache - -before_cache: - - ccache -s # see how many hits ccache got before_install: # Travis clones with --branch, which omits tags. Since we use them for the version string at build time, fetch them @@ -138,21 +131,19 @@ before_install: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi # 'brew install' sometimes returns non-zero for some arcane reason. Executing 'true' resets the exit code and allows Travis to continue building... # Travis seems to have Python 2.7 installed by default, which for some reason prevents pkg-config from reading python3.pc - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ccache ola lua openssl jack python3; brew link --overwrite python; true; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ola lua openssl jack python3; brew link --overwrite python; true; fi # OpenSSL is not a proper install due to some Apple bull, so provide additional locations via the environment... # Additionally, newer versions of this "recipe" seem to use the name 'openssl@1.1' instead of plain 'openssl' and there seems to be # no way to programmatically get the link and include paths. Genius! Hardcoding the new version for the time being... - export CFLAGS="$CFLAGS -I/usr/local/opt/openssl@1.1/include" - export LDFLAGS="$LDFLAGS -L/usr/local/opt/openssl@1.1/lib" - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then PATH=/usr/local/opt/ccache/libexec:$PATH; fi # Use ccache on Mac too - - if [ "$TRAVIS_OS_NAME" == "linux" -a \( "$TASK" = "compile" -o "$TASK" = "sanitize" \) -a "$CC" = "gcc" ]; then export CC="ccache gcc-8"; export CXX="ccache g++-8"; fi #Use the latest clang if we're compiling with clang - if [ "$TRAVIS_OS_NAME" == "linux" -a "$CC" = "clang" ]; then export CC="clang-6.0"; export CXX="clang-6.0"; fi #Report the compiler versions - $CC --version #OS X uses something other than $CXX variable - if [ "$TRAVIS_OS_NAME" == "linux" -a \( "$TASK" = "compile" -o "$TASK" = "sanitize" \) ]; then $CXX --version; fi -# Download libraries to link with on Windows +# Download libraries to link with for Windows - if [ "$TASK" == "windows" ]; then wget "https://downloads.sourceforge.net/project/luabinaries/5.3.5/Windows%20Libraries/Dynamic/lua-5.3.5_Win64_dllw6_lib.zip" -O lua53.zip; unzip lua53.zip lua53.dll; fi notifications: diff --git a/backends/openpixelcontrol.md b/backends/openpixelcontrol.md index d09d412..af5e811 100644 --- a/backends/openpixelcontrol.md +++ b/backends/openpixelcontrol.md @@ -35,12 +35,12 @@ Channels can be specified by their sequential index (one-based). Example mapping (data from Strip 2 LED 66's green component is mapped to the blue component of LED 2 on strip 1): ``` -strip1.channel6 < strip2.channel200 +op1.strip1.channel6 < op1.strip2.channel200 ``` Additionally, channels may be referred to by their color component and LED index: ``` -strip1.blue2 < strip2.green66 +op1.strip1.blue2 < op2.strip2.green66 ``` #### Known bugs / problems -- cgit v1.2.3