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.yml | 46 +++++++++++++++------------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) (limited to '.travis.yml') diff --git a/.travis.yml b/.travis.yml index b9b6969..48b4b71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,8 +12,6 @@ script: addons: apt: packages: &base_build - # This is the absolute minimum for configure to pass - # Non C++ based tasks use it so they can run make builtfiles - ccache packages: &core_build # This is all the bits we need to enable all options @@ -36,6 +34,11 @@ addons: packages: &core_build_windows - *core_build - mingw-w64 + packages: &linters + - lintian + - codespell + - shellcheck + - cloc jobs: fast_finish: true @@ -74,30 +77,6 @@ jobs: apt: packages: - *core_build_clang_latest - - os: linux - dist: bionic - env: TASK='spellintian' - addons: - apt: - packages: - - *core_build - - moreutils - - os: linux - dist: bionic - env: TASK='spellintian-duplicates' - addons: - apt: - packages: - - *core_build - - moreutils - - os: linux - dist: bionic - env: TASK='codespell' - addons: - apt: - packages: - - *core_build - - moreutils - os: osx osx_image: xcode10.2 compiler: clang @@ -116,10 +95,18 @@ jobs: allow_failures: - os: linux dist: bionic - env: TASK='spellintian-duplicates' + env: TASK='codesmell' + addons: + apt: + packages: + - *linters - os: linux dist: bionic - env: TASK='codespell' + env: TASK='spellcheck' + addons: + apt: + packages: + - *linters env: global: @@ -136,9 +123,6 @@ cache: before_cache: - ccache -s # see how many hits ccache got -install: - - if [ "$TASK" = "codespell" ]; then pip install --user git+https://github.com/codespell-project/codespell.git; fi - before_install: # Travis clones with --branch, which omits tags. Since we use them for the version string at build time, fetch them - git pull --tags -- 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 +++++++++++++++++++++++++++++++--- .travis.yml | 12 ++++++++++-- midimonster.h | 6 ++++-- 3 files changed, 45 insertions(+), 7 deletions(-) (limited to '.travis.yml') 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 diff --git a/.travis.yml b/.travis.yml index 48b4b71..a5de2f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ before_script: - export -f travis_fold script: - - "bash -ex .travis-ci.sh" + - "bash .travis-ci.sh" addons: apt: @@ -35,6 +35,8 @@ addons: - *core_build - mingw-w64 packages: &linters + - python3 + - python3-pip - lintian - codespell - shellcheck @@ -92,7 +94,6 @@ jobs: compiler: clang env: - TASK='sanitize' - allow_failures: - os: linux dist: bionic env: TASK='codesmell' @@ -107,6 +108,13 @@ jobs: apt: packages: - *linters + allow_failures: + - os: linux + dist: bionic + env: TASK='codesmell' + - os: linux + dist: bionic + env: TASK='spellcheck' env: global: diff --git a/midimonster.h b/midimonster.h index bad83c7..dc0e255 100644 --- a/midimonster.h +++ b/midimonster.h @@ -234,10 +234,12 @@ MM_API instance* mm_instance_find(char* backend, uint64_t ident); * matching `ident`, a pointer to it is returned. * This API is just a convenience function. The array of channels is * only used for mapping internally, creating and managing your own - * channel store is possible. + * channel store is possible. When returning pointers from a + * backend-local channel store, the returned pointers must stay + * valid over the lifetime of the instance. * For each channel with a non-NULL `impl` field registered using * this function, the backend will receive a call to its channel_free - * function. + * function (if it exists). */ MM_API channel* mm_channel(instance* i, uint64_t ident, uint8_t create); -- cgit v1.2.3 From 5087d4ebde3f9a1ec775928ec25f50099be3d8ad Mon Sep 17 00:00:00 2001 From: Spacelord Date: Thu, 12 Mar 2020 14:31:21 +0100 Subject: Add travis irc notification --- .travis.yml | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to '.travis.yml') diff --git a/.travis.yml b/.travis.yml index a5de2f4..c3bcc12 100644 --- a/.travis.yml +++ b/.travis.yml @@ -154,6 +154,15 @@ before_install: # Download libraries to link with on Windows - if [ "$TASK" == "windows" ]; then mkdir libs; 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; mv lua53.dll libs; fi +notifications: + irc: + channels: + - "rc.hackint.org#midimonster" + on_success: change # default: always + on_failure: always # default: always + nick: MIDIMonster CI + use_notice: true + deploy: provider: releases file_glob: true -- cgit v1.2.3 From 378296f1b49c64f20c61966d2dcc8c8143181a07 Mon Sep 17 00:00:00 2001 From: Spacelord Date: Thu, 12 Mar 2020 14:40:42 +0100 Subject: Fix typo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.travis.yml') diff --git a/.travis.yml b/.travis.yml index c3bcc12..b9c2b9d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -157,7 +157,7 @@ before_install: notifications: irc: channels: - - "rc.hackint.org#midimonster" + - "irc.hackint.org#midimonster" on_success: change # default: always on_failure: always # default: always nick: MIDIMonster CI -- cgit v1.2.3 From 4b120a64f68fd7f36e8080981d68d0830d113205 Mon Sep 17 00:00:00 2001 From: cbdev Date: Thu, 12 Mar 2020 21:51:43 +0100 Subject: Fix rate-limited frame synthesis --- .travis.yml | 2 +- backends/artnet.c | 4 ++-- backends/sacn.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to '.travis.yml') diff --git a/.travis.yml b/.travis.yml index b9c2b9d..d7c25b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -160,7 +160,7 @@ notifications: - "irc.hackint.org#midimonster" on_success: change # default: always on_failure: always # default: always - nick: MIDIMonster CI + nick: mm_ci use_notice: true deploy: diff --git a/backends/artnet.c b/backends/artnet.c index 7d5d9ee..34fc82d 100644 --- a/backends/artnet.c +++ b/backends/artnet.c @@ -280,8 +280,8 @@ static int artnet_set(instance* inst, size_t num, channel** c, channel_value* v) //check output rate limit, request next frame if(frame_delta < ARTNET_FRAME_TIMEOUT){ artnet_fd[data->fd_index].output_instance[u].mark = 1; - if(!next_frame || next_frame > (ARTNET_KEEPALIVE_INTERVAL - frame_delta)){ - next_frame = (ARTNET_KEEPALIVE_INTERVAL - frame_delta); + if(!next_frame || next_frame > (ARTNET_FRAME_TIMEOUT - frame_delta)){ + next_frame = (ARTNET_FRAME_TIMEOUT - frame_delta); } return 0; } diff --git a/backends/sacn.c b/backends/sacn.c index c9be8ff..495bdf3 100644 --- a/backends/sacn.c +++ b/backends/sacn.c @@ -374,8 +374,8 @@ static int sacn_set(instance* inst, size_t num, channel** c, channel_value* v){ //check if ratelimiting engaged if(frame_delta < SACN_FRAME_TIMEOUT){ global_cfg.fd[data->fd_index].universe[u].mark = 1; - if(!global_cfg.next_frame || global_cfg.next_frame > (SACN_KEEPALIVE_INTERVAL - frame_delta)){ - global_cfg.next_frame = (SACN_KEEPALIVE_INTERVAL - frame_delta); + if(!global_cfg.next_frame || global_cfg.next_frame > (SACN_FRAME_TIMEOUT - frame_delta)){ + global_cfg.next_frame = (SACN_FRAME_TIMEOUT - frame_delta); } return 0; } -- 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 +++ .travis.yml | 2 +- backends/Makefile | 2 +- backends/libmmbackend.c | 7 +++++++ backends/lua.md | 5 ++--- backends/rtpmidi.c | 2 +- 6 files changed, 15 insertions(+), 6 deletions(-) (limited to '.travis.yml') 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/ diff --git a/.travis.yml b/.travis.yml index d7c25b6..8cf9e82 100644 --- a/.travis.yml +++ b/.travis.yml @@ -152,7 +152,7 @@ before_install: #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 - - if [ "$TASK" == "windows" ]; then mkdir libs; 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; mv lua53.dll libs; fi + - 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: irc: diff --git a/backends/Makefile b/backends/Makefile index 1e66995..700c9b3 100644 --- a/backends/Makefile +++ b/backends/Makefile @@ -65,7 +65,7 @@ ola.so: CPPFLAGS += -Wno-write-strings lua.so: CFLAGS += $(shell pkg-config --cflags lua53 || pkg-config --cflags lua5.3 || echo "-DBUILD_ERROR=\"Missing pkg-config data for lua53\"") lua.so: LDLIBS += $(shell pkg-config --libs lua53 || pkg-config --libs lua5.3 || echo "-DBUILD_ERROR=\"Missing pkg-config data for lua53\"") lua.dll: CFLAGS += $(shell pkg-config --cflags lua53 || pkg-config --cflags lua5.3 || echo "-DBUILD_ERROR=\"Missing pkg-config data for lua53\"") -lua.dll: LDLIBS += -L../libs -llua53 +lua.dll: LDLIBS += -L../ -llua53 python.so: CFLAGS += $(shell pkg-config --cflags python3 || pkg-config --cflags python || echo "-DBUILD_ERROR=\"Missing pkg-config data for python3\"") python.so: CFLAGS += $(shell pkg-config --libs python3 || pkg-config --libs python || echo "-DBUILD_ERROR=\"Missing pkg-config data for python3\"") diff --git a/backends/libmmbackend.c b/backends/libmmbackend.c index 2bbc226..92adc3c 100644 --- a/backends/libmmbackend.c +++ b/backends/libmmbackend.c @@ -20,8 +20,15 @@ int mmbackend_strdup(char** dest, char* src){ char* mmbackend_socket_strerror(int err_no){ #ifdef _WIN32 static char error[2048] = ""; + ssize_t u; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, WSAGetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), error, sizeof(error), NULL); + //remove trailing newline that for some reason is included in most of these... + for(u = strlen(error) - 1; u > 0; u--){ + if(!isprint(error[u])){ + error[u] = 0; + } + } return error; #else return strerror(err_no); diff --git a/backends/lua.md b/backends/lua.md index e59e513..0a31dce 100644 --- a/backends/lua.md +++ b/backends/lua.md @@ -101,7 +101,6 @@ the MIDIMonster project can not provide this file within this repository. You will need to acquire a copy of `lua53.dll`, for example by downloading it from the [luabinaries project](http://luabinaries.sourceforge.net/download.html). -To build the `lua` backend for Windows, place `lua53.dll` in a subdirectory `libs/` in the project root -and run `make lua.dll` inside the `backends/` directory. - +Place this file in the project root directory and run `make lua.dll` inside the `backends/` directory +to build the backend. At runtime, Windows searches for the file in the same directory as `midimonster.exe`. diff --git a/backends/rtpmidi.c b/backends/rtpmidi.c index 52cb0c5..7df8563 100644 --- a/backends/rtpmidi.c +++ b/backends/rtpmidi.c @@ -525,7 +525,7 @@ static int rtpmidi_applecommand(instance* inst, struct sockaddr* dest, socklen_t //FIXME should we match sending/receiving ports? if the reference does this, it should be documented bytes = sendto(control ? data->control_fd : data->fd, frame, sizeof(apple_command) + strlen(inst->name) + 1, 0, dest, dest_len); if(bytes != sizeof(apple_command) + strlen(inst->name) + 1){ - LOGPF("Failed to transmit session command on %s", inst->name); + LOGPF("Failed to transmit session command on %s: %s", inst->name, mmbackend_socket_strerror(errno)); return 1; } return 0; -- 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 +++--- .travis.yml | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) (limited to '.travis.yml') 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" diff --git a/.travis.yml b/.travis.yml index 8cf9e82..4e14339 100644 --- a/.travis.yml +++ b/.travis.yml @@ -134,6 +134,7 @@ before_cache: before_install: # Travis clones with --branch, which omits tags. Since we use them for the version string at build time, fetch them - git pull --tags + - printf "This is %s on %s\n" "$(git describe)" "$TRAVIS_OS_NAME" - 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 -- cgit v1.2.3