Skip to content

Commit

Permalink
Speed up Travis by using preinstalled LuaRocks
Browse files Browse the repository at this point in the history
  • Loading branch information
galjonsfigur committed Jul 24, 2019
1 parent 582cda4 commit 0ba9e21
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 10 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ addons:
packages:
- python-serial
- srecord
- luarocks
cache:
- directories:
- cache
Expand Down
75 changes: 65 additions & 10 deletions tools/travis/run-luacheck.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,71 @@

set -e

echo "Installing Lua 5.3, LuaRocks and Luacheck"
(
cd "$TRAVIS_BUILD_DIR" || exit
exists() {
if command -v "$1" >/dev/null 2>&1
then
return 0
else
return 1
fi
}

usage() {
echo "
usage: bash tools/travis/run-luacheck.sh [-s]
Avarible options are:
-s: Standalone mode: Lua, LuaRocks and luacheck
will be installed in nodemcu-firmare/cache folder.
By default script will use luarocks installed in host system.
"
}

install_tools() {
if ! exists luarocks; then
echo "LuaRocks not found!"
exit 1
fi

eval "`luarocks path --bin`" #Set PATH for luacheck
#In Travis Path it's not changed by LuaRocks for some unknown reason
if [ "${TRAVIS}" = "true" ]; then
export PATH=$PATH:/home/travis/.luarocks/bin
fi

if ! exists luacheck; then
echo "Installing luacheck"
luarocks install --local luacheck || exit
fi

}

install_tools_standalone() {
if ! [ -x cache/localua/bin/luarocks ]; then
echo "Installing Lua 5.3 and LuaRocks"
bash tools/travis/localua.sh cache/localua || exit
cache/localua/bin/luarocks install luacheck || exit
)
fi

if ! [ -x cache/localua/bin/luacheck ]; then
echo "Installing luacheck"
cache/localua/bin/luarocks install luacheck || exit
fi
}

if [[ $1 == "" ]]; then
install_tools
else
while getopts "s" opt
do
case $opt in
(s) install_tools_standalone ;;
(*) usage; exit 1 ;;
esac
done
fi

(
echo "Static analysys of:"
find lua_modules lua_examples -iname "*.lua" -print0 | xargs -0 echo
)
echo "Static analysys of"
find lua_examples -iname "*.lua" -print0 | xargs -0 echo

(find lua_modules lua_examples -iname "*.lua" -print0 | xargs -0 cache/localua/bin/luacheck --config tools/luacheck_config.lua) || exit
(find lua_modules lua_examples -iname "*.lua" -print0 | xargs -0 luacheck --config tools/luacheck_config.lua) || exit

0 comments on commit 0ba9e21

Please sign in to comment.