Fix github workflow #26
This file contains 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
name: CMake Build and Test | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install Dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y clang-format | |
- name: Check Code Formatting | |
run: | | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
YELLOW='\033[1;33m' | |
NC='\033[0m' # No Color | |
echo -e "${YELLOW}+ Checking formatter${NC}" | |
is_formatted=0 | |
for file in $(find srcs/ include/ -type f \( -name "*.cpp" -o -name "*.hpp" -o -name "*.h" \)); do | |
echo "Checking file: $file" | |
output=$(clang-format --dry-run -Werror "$file" 2>&1) | |
echo "Output: $output" | |
# Check if output contains any suggestions | |
if [[ -n "${output//[$'\n\r ']}" ]]; then | |
echo -e "${RED}x ${NC}$(basename $file)" | |
is_formatted=1 | |
else | |
echo -e "${GREEN}✓ ${NC}$(basename $file)" | |
fi | |
done | |
if [[ $is_formatted -eq 1 ]]; then | |
echo "Some files aren't properly formatted" | |
exit 1 | |
else | |
echo "All files are properly formatted" | |
fi |