Created
October 1, 2023 01:44
-
-
Save apeckham/2fb5841aab4bfdb86adcd798d6170c38 to your computer and use it in GitHub Desktop.
ci script for lein reflection check
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 | |
set -euf -o pipefail | |
get_warnings() { | |
lein check 2>&1 | grep "Reflection" || { echo "Error in reflection-linter.sh"; exit 1; } | |
} | |
parse_line() { | |
echo $1 | awk -F 'Reflection warning, |:| - ' '{print $2, $3, $4, $5}' | |
} | |
is_src_file() { | |
[[ -e "src/$1" ]] | |
} | |
warnings=$(get_warnings) | |
parsed_warnings=() | |
while IFS= read -r warning; do | |
parsed=$(parse_line "$warning") | |
is_src_file $(echo $parsed | awk '{print $1}') && parsed_warnings+=("$parsed") | |
done <<< "$warnings" | |
if [[ ${#parsed_warnings[@]} -eq 0 ]]; then | |
echo -e "\033[0;32mNo reflection warnings! Success.\033[0m" | |
else | |
echo -e "\033[1;31mThere are some reflection warnings.\033[0m 😞" | |
for warning in "${parsed_warnings[@]}"; do echo $warning; done | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment