-
-
Save NonymousMorlock/f8273c38ee8b2decef2cd51176bec293 to your computer and use it in GitHub Desktop.
lintool is a bash script for flutter projects to automate checks before creating a Pull Request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#minimum code coverage value | |
coverage_limit=70 | |
exit_message () { | |
echo "\e[1;31m π Lintool failed.\n πͺ Check the issues.\n π Run again.\e[0m" | |
exit 0 | |
} | |
flutter format --set-exit-if-changed lib test || exit_message | |
flutter analyze lib test || exit_message | |
flutter test -j 4 --no-pub --coverage --test-randomize-ordering-seed random || exit_message | |
coverage_output=$(genhtml coverage/lcov.info -o coverage/) | |
regex="([0-9]+)\.[0-9]*%" | |
if [[ $coverage_output =~ $regex ]] | |
then | |
coverage_value="${BASH_REMATCH[1]}" | |
echo "Code Coverage is $coverage_value%" | |
if [ $coverage_value -lt $coverage_limit ] | |
then | |
echo "Code Coverage must be at least $coverage_limit%" | |
exit_message | |
fi | |
else | |
echo "π Can't detect Code Coverage Value. Check it yourself." | |
fi | |
echo "\e[1;32m Ready to push!\e[0m π" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment