-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (40 loc) · 1.2 KB
/
cmake-multi-platform.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: Formatter
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
output=$(clang-format --dry-run -Werror "$file" 2>&1)
# 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
fi