diff options
Diffstat (limited to 'util/travis')
-rwxr-xr-x | util/travis/before_install.sh | 15 | ||||
-rw-r--r-- | util/travis/clang-format-whitelist.txt | 389 | ||||
-rw-r--r-- | util/travis/common.sh | 3 | ||||
-rw-r--r-- | util/travis/lint.sh | 45 | ||||
-rwxr-xr-x | util/travis/script.sh | 21 |
5 files changed, 470 insertions, 3 deletions
diff --git a/util/travis/before_install.sh b/util/travis/before_install.sh index 891371984..a4328fa46 100755 --- a/util/travis/before_install.sh +++ b/util/travis/before_install.sh @@ -1,7 +1,15 @@ #!/bin/bash -e echo "Preparing for $TRAVIS_COMMIT_RANGE" -. util/travis/common.sh +if [[ "$LINT" == "1" ]]; then + curl http://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + sudo add-apt-repository "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.9 main" + sudo apt-get -yq update + sudo apt-get install clang-format-3.9 + exit 0 +fi + +. util/travis/common.sh needs_compile || exit 0 if [[ $TRAVIS_OS_NAME == "linux" ]]; then @@ -11,6 +19,7 @@ fi if [[ $PLATFORM == "Unix" ]]; then if [[ $TRAVIS_OS_NAME == "linux" ]]; then + sudo apt-get update sudo apt-get install libirrlicht-dev cmake libbz2-dev libpng12-dev \ libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev \ libhiredis-dev libogg-dev libgmp-dev libvorbis-dev libopenal-dev \ @@ -18,6 +27,10 @@ if [[ $PLATFORM == "Unix" ]]; then # Linking to LevelDB is broken, use a custom build wget http://minetest.kitsunemimi.pw/libleveldb-1.18-ubuntu12.04.7z sudo 7z x -o/usr libleveldb-1.18-ubuntu12.04.7z + if [[ "$VALGRIND" == "1" ]]; then + sudo apt-get install valgrind + fi + else brew update brew install freetype gettext hiredis irrlicht jpeg leveldb libogg libvorbis luajit diff --git a/util/travis/clang-format-whitelist.txt b/util/travis/clang-format-whitelist.txt new file mode 100644 index 000000000..932f59978 --- /dev/null +++ b/util/travis/clang-format-whitelist.txt @@ -0,0 +1,389 @@ +src/activeobject.h +src/ban.cpp +src/camera.cpp +src/camera.h +src/cavegen.cpp +src/cguittfont/CGUITTFont.cpp +src/cguittfont/CGUITTFont.h +src/cguittfont/irrUString.h +src/cguittfont/xCGUITTFont.h +src/chat.cpp +src/chat.h +src/chat_interface.h +src/client/clientlauncher.cpp +src/client/clientlauncher.h +src/client.cpp +src/clientenvironment.cpp +src/clientenvironment.h +src/client.h +src/clientiface.cpp +src/clientiface.h +src/client/joystick_controller.cpp +src/client/joystick_controller.h +src/clientmap.cpp +src/clientmap.h +src/clientmedia.cpp +src/clientmedia.h +src/clientobject.cpp +src/clientobject.h +src/client/tile.cpp +src/client/tile.h +src/clouds.cpp +src/clouds.h +src/collision.cpp +src/collision.h +src/config.h +src/content_cao.cpp +src/content_cao.h +src/content_cso.cpp +src/content_cso.h +src/content_mapblock.cpp +src/content_mapblock.h +src/content_mapnode.cpp +src/content_nodemeta.cpp +src/content_nodemeta.h +src/content_sao.cpp +src/content_sao.h +src/convert_json.cpp +src/convert_json.h +src/craftdef.cpp +src/craftdef.h +src/database.cpp +src/database-dummy.cpp +src/database-files.cpp +src/database-leveldb.cpp +src/database-postgresql.cpp +src/database-postgresql.h +src/database-redis.cpp +src/database-sqlite3.cpp +src/database-sqlite3.h +src/daynightratio.h +src/debug.cpp +src/debug.h +src/defaultsettings.cpp +src/drawscene.cpp +src/drawscene.h +src/dungeongen.cpp +src/dungeongen.h +src/emerge.cpp +src/emerge.h +src/environment.cpp +src/event.h +src/event_manager.h +src/exceptions.h +src/face_position_cache.cpp +src/face_position_cache.h +src/filecache.cpp +src/filesys.cpp +src/filesys.h +src/fontengine.cpp +src/fontengine.h +src/game.cpp +src/gamedef.h +src/game.h +src/genericobject.cpp +src/genericobject.h +src/gettext.cpp +src/gettext.h +src/guiChatConsole.cpp +src/guiChatConsole.h +src/guiEngine.cpp +src/guiEngine.h +src/guiFileSelectMenu.cpp +src/guiFormSpecMenu.cpp +src/guiFormSpecMenu.h +src/guiKeyChangeMenu.cpp +src/guiMainMenu.h +src/guiPasswordChange.cpp +src/guiscalingfilter.cpp +src/guiscalingfilter.h +src/guiTable.cpp +src/guiTable.h +src/guiVolumeChange.cpp +src/guiVolumeChange.h +src/httpfetch.cpp +src/hud.cpp +src/hud.h +src/imagefilters.cpp +src/imagefilters.h +src/intlGUIEditBox.cpp +src/intlGUIEditBox.h +src/inventory.cpp +src/inventory.h +src/inventorymanager.cpp +src/inventorymanager.h +src/irrlicht_changes/static_text.cpp +src/irrlicht_changes/static_text.h +src/irrlichttypes.h +src/itemdef.cpp +src/itemdef.h +src/itemstackmetadata.cpp +src/keycode.cpp +src/light.cpp +src/localplayer.cpp +src/log.cpp +src/log.h +src/main.cpp +src/mainmenumanager.h +src/mapblock.cpp +src/mapblock.h +src/mapblock_mesh.cpp +src/mapblock_mesh.h +src/map.cpp +src/mapgen.cpp +src/mapgen_flat.cpp +src/mapgen_fractal.cpp +src/mapgen.h +src/mapgen_singlenode.cpp +src/mapgen_v5.cpp +src/mapgen_v6.cpp +src/mapgen_v6.h +src/mapgen_v7.cpp +src/mapgen_v7.h +src/mapgen_valleys.cpp +src/mapgen_valleys.h +src/map.h +src/mapnode.cpp +src/mapnode.h +src/mapsector.cpp +src/mapsector.h +src/map_settings_manager.cpp +src/map_settings_manager.h +src/mesh.cpp +src/mesh.h +src/mesh_generator_thread.cpp +src/metadata.h +src/mg_biome.cpp +src/mg_biome.h +src/mg_decoration.cpp +src/mg_decoration.h +src/mg_ore.cpp +src/mg_ore.h +src/mg_schematic.cpp +src/mg_schematic.h +src/minimap.cpp +src/minimap.h +src/modalMenu.h +src/mods.cpp +src/mods.h +src/network/clientopcodes.cpp +src/network/clientopcodes.h +src/network/clientpackethandler.cpp +src/network/connection.cpp +src/network/connection.h +src/network/networkpacket.cpp +src/network/networkpacket.h +src/network/networkprotocol.h +src/network/serveropcodes.cpp +src/network/serveropcodes.h +src/network/serverpackethandler.cpp +src/nodedef.cpp +src/nodedef.h +src/nodemetadata.cpp +src/nodemetadata.h +src/nodetimer.cpp +src/nodetimer.h +src/noise.cpp +src/noise.h +src/objdef.cpp +src/objdef.h +src/object_properties.cpp +src/object_properties.h +src/particles.cpp +src/particles.h +src/pathfinder.cpp +src/pathfinder.h +src/player.cpp +src/player.h +src/porting_android.cpp +src/porting_android.h +src/porting.cpp +src/porting.h +src/profiler.h +src/quicktune.cpp +src/quicktune.h +src/quicktune_shortcutter.h +src/raycast.cpp +src/raycast.h +src/reflowscan.cpp +src/reflowscan.h +src/remoteplayer.cpp +src/rollback.cpp +src/rollback.h +src/rollback_interface.cpp +src/rollback_interface.h +src/script/common/c_content.cpp +src/script/common/c_content.h +src/script/common/c_converter.cpp +src/script/common/c_converter.h +src/script/common/c_internal.cpp +src/script/common/c_internal.h +src/script/common/c_types.cpp +src/script/common/c_types.h +src/script/cpp_api/s_async.cpp +src/script/cpp_api/s_async.h +src/script/cpp_api/s_base.cpp +src/script/cpp_api/s_base.h +src/script/cpp_api/s_client.cpp +src/script/cpp_api/s_entity.cpp +src/script/cpp_api/s_entity.h +src/script/cpp_api/s_env.cpp +src/script/cpp_api/s_env.h +src/script/cpp_api/s_internal.h +src/script/cpp_api/s_inventory.cpp +src/script/cpp_api/s_inventory.h +src/script/cpp_api/s_item.cpp +src/script/cpp_api/s_item.h +src/script/cpp_api/s_mainmenu.h +src/script/cpp_api/s_node.cpp +src/script/cpp_api/s_node.h +src/script/cpp_api/s_nodemeta.cpp +src/script/cpp_api/s_nodemeta.h +src/script/cpp_api/s_player.cpp +src/script/cpp_api/s_security.cpp +src/script/cpp_api/s_security.h +src/script/cpp_api/s_server.cpp +src/script/cpp_api/s_server.h +src/script/lua_api/l_areastore.cpp +src/script/lua_api/l_base.cpp +src/script/lua_api/l_base.h +src/script/lua_api/l_craft.cpp +src/script/lua_api/l_craft.h +src/script/lua_api/l_env.cpp +src/script/lua_api/l_env.h +src/script/lua_api/l_http.cpp +src/script/lua_api/l_http.h +src/script/lua_api/l_internal.h +src/script/lua_api/l_inventory.cpp +src/script/lua_api/l_inventory.h +src/script/lua_api/l_item.cpp +src/script/lua_api/l_item.h +src/script/lua_api/l_itemstackmeta.cpp +src/script/lua_api/l_itemstackmeta.h +src/script/lua_api/l_localplayer.cpp +src/script/lua_api/l_mainmenu.cpp +src/script/lua_api/l_mainmenu.h +src/script/lua_api/l_mapgen.cpp +src/script/lua_api/l_metadata.cpp +src/script/lua_api/l_minimap.cpp +src/script/lua_api/l_nodemeta.cpp +src/script/lua_api/l_nodemeta.h +src/script/lua_api/l_nodetimer.cpp +src/script/lua_api/l_noise.cpp +src/script/lua_api/l_object.cpp +src/script/lua_api/l_object.h +src/script/lua_api/l_particles.cpp +src/script/lua_api/l_particles.h +src/script/lua_api/l_rollback.cpp +src/script/lua_api/l_rollback.h +src/script/lua_api/l_server.cpp +src/script/lua_api/l_settings.cpp +src/script/lua_api/l_sound.cpp +src/script/lua_api/l_storage.cpp +src/script/lua_api/l_util.cpp +src/script/lua_api/l_vmanip.cpp +src/script/scripting_client.cpp +src/script/scripting_client.h +src/script/scripting_mainmenu.cpp +src/script/scripting_mainmenu.h +src/script/scripting_server.cpp +src/script/scripting_server.h +src/serialization.cpp +src/serialization.h +src/server.cpp +src/serverenvironment.cpp +src/serverenvironment.h +src/server.h +src/serverlist.cpp +src/serverlist.h +src/serverobject.cpp +src/serverobject.h +src/settings.cpp +src/settings.h +src/settings_translation_file.cpp +src/shader.cpp +src/shader.h +src/sky.cpp +src/socket.cpp +src/socket.h +src/sound.cpp +src/sound_openal.cpp +src/sound_openal.h +src/staticobject.cpp +src/staticobject.h +src/subgame.cpp +src/subgame.h +src/terminal_chat_console.cpp +src/terminal_chat_console.h +src/threading/atomic.h +src/threading/event.cpp +src/threading/mutex_auto_lock.h +src/threading/mutex.cpp +src/threading/mutex.h +src/threading/semaphore.cpp +src/threading/thread.cpp +src/threading/thread.h +src/threads.h +src/tileanimation.cpp +src/tool.cpp +src/tool.h +src/touchscreengui.cpp +src/treegen.cpp +src/treegen.h +src/unittest/test_areastore.cpp +src/unittest/test_collision.cpp +src/unittest/test_compression.cpp +src/unittest/test_connection.cpp +src/unittest/test.cpp +src/unittest/test_filepath.cpp +src/unittest/test.h +src/unittest/test_inventory.cpp +src/unittest/test_keycode.cpp +src/unittest/test_map_settings_manager.cpp +src/unittest/test_noderesolver.cpp +src/unittest/test_noise.cpp +src/unittest/test_random.cpp +src/unittest/test_schematic.cpp +src/unittest/test_serialization.cpp +src/unittest/test_settings.cpp +src/unittest/test_socket.cpp +src/unittest/test_threading.cpp +src/unittest/test_utilities.cpp +src/unittest/test_voxelalgorithms.cpp +src/unittest/test_voxelmanipulator.cpp +src/util/areastore.cpp +src/util/areastore.h +src/util/auth.cpp +src/util/auth.h +src/util/base64.cpp +src/util/base64.h +src/util/basic_macros.h +src/util/container.h +src/util/directiontables.cpp +src/util/directiontables.h +src/util/enriched_string.cpp +src/util/enriched_string.h +src/util/md32_common.h +src/util/numeric.cpp +src/util/numeric.h +src/util/pointedthing.cpp +src/util/pointedthing.h +src/util/pointer.h +src/util/serialize.cpp +src/util/serialize.h +src/util/sha1.cpp +src/util/srp.cpp +src/util/srp.h +src/util/strfnd.h +src/util/string.cpp +src/util/string.h +src/util/thread.h +src/util/timetaker.cpp +src/util/timetaker.h +src/version.cpp +src/version.h +src/voxelalgorithms.cpp +src/voxelalgorithms.h +src/voxel.cpp +src/voxel.h +src/wieldmesh.cpp diff --git a/util/travis/common.sh b/util/travis/common.sh index 16c7db324..35ceec08d 100644 --- a/util/travis/common.sh +++ b/util/travis/common.sh @@ -1,8 +1,9 @@ #!/bin/bash -e # Relative to git-repository root: -TRIGGER_COMPILE_PATHS="src/|CMakeLists.txt|cmake/Modules/|util/travis/|util/buildbot/" +TRIGGER_COMPILE_PATHS="src/.*\.(c|cpp|h)|CMakeLists.txt|cmake/Modules/|util/travis/|util/buildbot/" needs_compile() { git diff --name-only $TRAVIS_COMMIT_RANGE | egrep -q "^($TRIGGER_COMPILE_PATHS)" } + diff --git a/util/travis/lint.sh b/util/travis/lint.sh new file mode 100644 index 000000000..cd5f41779 --- /dev/null +++ b/util/travis/lint.sh @@ -0,0 +1,45 @@ +#! /bin/bash +function perform_lint() { + echo "Performing LINT..." + if hash clang-format-3.9 2>/dev/null; then + CLANG_FORMAT=clang-format-3.9 + else + CLANG_FORMAT=clang-format + fi + echo "LINT: Using binary $CLANG_FORMAT" + CLANG_FORMAT_WHITELIST="util/travis/clang-format-whitelist.txt" + + files_to_lint="$(find src/ -name '*.cpp' -or -name '*.h')" + + local errorcount=0 + local fail=0 + for f in ${files_to_lint}; do + d=$(diff -u "$f" <(${CLANG_FORMAT} "$f") || true) + + if ! [ -z "$d" ]; then + whitelisted=$(awk '$1 == "'$f'" { print 1 }' "$CLANG_FORMAT_WHITELIST") + + # If file is not whitelisted, mark a failure + if [ -z ${whitelisted} ]; then + errorcount=$((errorcount+1)) + + printf "The file %s is not compliant with the coding style" "$f" + if [ ${errorcount} -gt 50 ]; then + printf "\nToo many errors encountered previously, this diff is hidden.\n" + else + printf ":\n%s\n" "$d" + fi + + fail=1 + fi + fi + done + + if [ "$fail" = 1 ]; then + echo "LINT reports failure." + exit 1 + fi + + echo "LINT OK" +} + diff --git a/util/travis/script.sh b/util/travis/script.sh index 1bafb26cd..14b8dfb73 100755 --- a/util/travis/script.sh +++ b/util/travis/script.sh @@ -1,30 +1,49 @@ #!/bin/bash -e . util/travis/common.sh +. util/travis/lint.sh needs_compile || exit 0 +if [[ "$LINT" == "1" ]]; then + # Lint with exit CI + perform_lint + exit 0 +fi + if [[ $PLATFORM == "Unix" ]]; then mkdir -p travisbuild cd travisbuild || exit 1 + CMAKE_FLAGS='' if [[ $COMPILER == "g++-6" ]]; then export CC=gcc-6 export CXX=g++-6 fi + # Clang builds with FreeType fail on Travis if [[ $CC == "clang" ]]; then CMAKE_FLAGS+=' -DENABLE_FREETYPE=FALSE' fi + if [[ $TRAVIS_OS_NAME == "osx" ]]; then CMAKE_FLAGS+=' -DCUSTOM_GETTEXT_PATH=/usr/local/opt/gettext' fi + cmake -DCMAKE_BUILD_TYPE=Debug \ -DRUN_IN_PLACE=TRUE \ -DENABLE_GETTEXT=TRUE \ + -DBUILD_SERVER=TRUE \ $CMAKE_FLAGS .. make -j2 + echo "Running unit tests." - ../bin/minetest --run-unittests && exit 0 + CMD="../bin/minetest --run-unittests" + if [[ "$VALGRIND" == "1" ]]; then + valgrind --leak-check=full --leak-check-heuristics=all --undef-value-errors=no --error-exitcode=9 ${CMD} && exit 0 + else + ${CMD} && exit 0 + fi + elif [[ $PLATFORM == Win* ]]; then [[ $CC == "clang" ]] && exit 1 # Not supposed to happen # We need to have our build directory outside of the minetest directory because |