From 2d136f1335e76cd1fe0d81ac92c2670e4834bedd Mon Sep 17 00:00:00 2001 From: Romain BOULLARD Date: Wed, 28 Jan 2026 15:33:55 +0100 Subject: [PATCH 1/8] Clang Format checks --- .gitea/workflows/ci.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 47d0701..0c8f756 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -44,4 +44,13 @@ jobs: - name: Unit Tests run: | cd ./build/${{ matrix.build_type }} - xvfb-run ctest . --output-on-failure \ No newline at end of file + xvfb-run ctest . --output-on-failure + + clang-format: + runs-on: ubuntu-latest + timeout-minutes: 120 + container: + image: git.romainboullard.com/bigfootdev/linuxbigfootbuilder:main + steps: + name: Clang Format Checkout + run: chmod +x format.sh && ./format.sh Bigfoot checker \ No newline at end of file -- 2.49.1 From 987ee4987b050ee734027f8ea8e4fa5b36547fa4 Mon Sep 17 00:00:00 2001 From: Romain BOULLARD Date: Wed, 28 Jan 2026 15:35:45 +0100 Subject: [PATCH 2/8] typo --- .gitea/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 0c8f756..af12576 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -45,12 +45,12 @@ jobs: run: | cd ./build/${{ matrix.build_type }} xvfb-run ctest . --output-on-failure - + clang-format: runs-on: ubuntu-latest timeout-minutes: 120 container: image: git.romainboullard.com/bigfootdev/linuxbigfootbuilder:main steps: - name: Clang Format Checkout - run: chmod +x format.sh && ./format.sh Bigfoot checker \ No newline at end of file + - name: Clang Format Checkout + run: chmod +x format.sh && ./format.sh Bigfoot checker \ No newline at end of file -- 2.49.1 From e0dac02623cf3cc8a782d06c30184083057a669b Mon Sep 17 00:00:00 2001 From: Romain BOULLARD Date: Wed, 28 Jan 2026 15:39:07 +0100 Subject: [PATCH 3/8] setup job --- .gitea/workflows/ci.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index af12576..16363c9 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -51,6 +51,15 @@ jobs: timeout-minutes: 120 container: image: git.romainboullard.com/bigfootdev/linuxbigfootbuilder:main + name: "Clang Format Checks" steps: - - name: Clang Format Checkout + - name: Install Node.js + run: apt-get update && apt-get install -y nodejs + + - name: Checkout repository + uses: actions/checkout@v6 + with: + submodules: recursive + + - name: Clang Format Checks run: chmod +x format.sh && ./format.sh Bigfoot checker \ No newline at end of file -- 2.49.1 From 827cb72021c123a64d3086b4fe9c88b29337f27c Mon Sep 17 00:00:00 2001 From: Romain BOULLARD Date: Wed, 28 Jan 2026 15:42:38 +0100 Subject: [PATCH 4/8] deliberate formatting mistake --- Bigfoot/Tests/System/Time.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Bigfoot/Tests/System/Time.cpp b/Bigfoot/Tests/System/Time.cpp index 6a9b602..38cc795 100644 --- a/Bigfoot/Tests/System/Time.cpp +++ b/Bigfoot/Tests/System/Time.cpp @@ -18,8 +18,7 @@ class TimeFixture: public ::testing::Test /****************************************************************************************/ -TEST_F(TimeFixture, Year_ShouldReturnTheYear) -{ +TEST_F(TimeFixture, Year_ShouldReturnTheYear){ EXPECT_EQ(m_time.Year(), 2026); } -- 2.49.1 From 604b31fa6bfa1e5108a8cb8a035283e7d6a2b932 Mon Sep 17 00:00:00 2001 From: Romain BOULLARD Date: Wed, 28 Jan 2026 17:07:58 +0100 Subject: [PATCH 5/8] fix script --- .gitea/workflows/ci.yml | 2 +- Bigfoot/Sources/Engine/touch.cpp | 2 +- Bigfoot/Tests/Engine/touch.cpp | 2 +- format.bat | 90 ++++++++++++++++++++++++-------- format.sh | 82 ++++++++++++++++++++--------- 5 files changed, 127 insertions(+), 51 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 16363c9..2e63796 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -62,4 +62,4 @@ jobs: submodules: recursive - name: Clang Format Checks - run: chmod +x format.sh && ./format.sh Bigfoot checker \ No newline at end of file + run: ./format.sh --check Bigfoot \ No newline at end of file diff --git a/Bigfoot/Sources/Engine/touch.cpp b/Bigfoot/Sources/Engine/touch.cpp index 96884b8..cc4afd9 100644 --- a/Bigfoot/Sources/Engine/touch.cpp +++ b/Bigfoot/Sources/Engine/touch.cpp @@ -1 +1 @@ -// to delete when an actual source is in Engine \ No newline at end of file +// to delete when an actual source is in Engine diff --git a/Bigfoot/Tests/Engine/touch.cpp b/Bigfoot/Tests/Engine/touch.cpp index 70d2a47..38a47cf 100644 --- a/Bigfoot/Tests/Engine/touch.cpp +++ b/Bigfoot/Tests/Engine/touch.cpp @@ -1 +1 @@ -// to delete when an actual test is in EngineTests \ No newline at end of file +// to delete when an actual test is in EngineTests diff --git a/format.bat b/format.bat index afc89f1..d9f5f51 100644 --- a/format.bat +++ b/format.bat @@ -1,30 +1,74 @@ @echo off -REM Variable that will hold the name of the clang-format command +SETLOCAL ENABLEDELAYEDEXPANSION + +REM ========================= +REM Variables +REM ========================= SET FMT=clang-format +SET MODE= +SET EXIT_CODE=0 -REM Function to format files -:format -for /r %%f in (*.h *.hpp *.m *.mm *.c *.cpp) do ( - echo %%~nxf | findstr /i "_generated$" >nul - if errorlevel 1 ( - echo format %%f - %FMT% -i "%%f" +REM ========================= +REM Parse arguments +REM ========================= +:parse_args +IF "%~1"=="" GOTO end_parse_args +IF "%~1"=="--check" ( + SET MODE=check +) ELSE IF "%~1"=="--fix" ( + SET MODE=fix +) ELSE ( + SET DIRS=!DIRS! "%~1" +) +SHIFT +GOTO parse_args +:end_parse_args + +IF "%MODE%"=="" ( + ECHO Usage: %~nx0 --check|--fix [ ...] + EXIT /B 1 +) + +IF "%DIRS%"=="" ( + ECHO Please provide at least one directory. + EXIT /B 1 +) + +REM ========================= +REM Iterate over directories +REM ========================= +FOR %%D IN (%DIRS%) DO ( + IF NOT EXIST "%%~D" ( + ECHO %%~D is not a valid directory. + SET EXIT_CODE=1 + GOTO :continue_dirs ) -) -echo ~~~ %1 Done ~~~ -exit /b -REM Check if argument is provided -if "%1"=="" ( - echo Please provide a directory as an argument. - exit /b + REM Recursively find source files + FOR /R "%%~D" %%F IN (*.h *.hpp *.c *.cpp *.m *.mm) DO ( + SET FILE=%%F + REM Skip *_generated* files + ECHO !FILE! | FINDSTR /I "_generated" >nul + IF ERRORLEVEL 1 ( + IF "%MODE%"=="fix" ( + ECHO Formatting !FILE! + %FMT% -i "!FILE!" + ) ELSE ( + REM Check mode: run clang-format --dry-run --Werror + %FMT% --dry-run --Werror "!FILE!" 2>nul + IF ERRORLEVEL 1 ( + REM clang-format will already print diagnostic + ECHO --- Diff for !FILE! --- + REM Generate diff using fc + %FMT% "!FILE!" > "%TEMP%\fmt.tmp" + fc "!FILE!" "%TEMP%\fmt.tmp" + SET EXIT_CODE=1 + ) + ) + ) + ) + + :continue_dirs ) -REM Check if directory exists -if not exist "%1" ( - echo %1 is not a valid directory. - exit /b -) - -cd %1 -call :format +EXIT /B %EXIT_CODE% diff --git a/format.sh b/format.sh index 5023e12..ff50922 100644 --- a/format.sh +++ b/format.sh @@ -1,31 +1,63 @@ #!/bin/bash +set -euo pipefail -# Variable that will hold the name of the clang-format command FMT="clang-format" +MODE="" +DIRS=() -# Function to format files -format() { - for f in $(find "$1" \( -name '*.h' -or -name '*.hpp' -or -name '*.m' -or -name '*.mm' -or -name '*.c' -or -name '*.cpp' \)); do - # Skip *_generated.h files - if [[ "$f" == *_generated* ]]; then - continue +# Parse arguments +for arg in "$@"; do + case "$arg" in + --check) + MODE="check" + ;; + --fix) + MODE="fix" + ;; + *) + DIRS+=("$arg") + ;; + esac +done + +if [[ -z "$MODE" ]]; then + echo "Usage: $0 --check|--fix [ ...]" + exit 1 +fi + +if [[ ${#DIRS[@]} -eq 0 ]]; then + echo "Please provide at least one directory." + exit 1 +fi + +EXIT_CODE=0 + +for DIR in "${DIRS[@]}"; do + if [[ ! -d "$DIR" ]]; then + echo "$DIR is not a valid directory." + EXIT_CODE=1 + continue + fi + + while IFS= read -r -d '' file; do + [[ "$file" == *_generated* ]] && continue + + if [[ "$MODE" == "fix" ]]; then + echo "Formatting $file" + $FMT -i "$file" + else + # Check mode: run clang-format with dry-run and Werror + # Capture stdout/stderr for diagnostic + if ! $FMT --dry-run --Werror "$file"; then + # clang-format will already print: + # Bigfoot/Tests/System/Time.cpp:21:46: error: code should be clang-formatted [-Wclang-format-violations] + # Now additionally print the diff for clarity + diff_output=$(diff -u "$file" <($FMT -style=file "$file") || true) + echo "$diff_output" + EXIT_CODE=1 + fi fi - echo "format ${f}" - ${FMT} -i "${f}" - done - echo "~~~ $1 Done ~~~" -} + done < <(find "$DIR" \( -name '*.h' -o -name '*.hpp' -o -name '*.c' -o -name '*.cpp' -o -name '*.m' -o -name '*.mm' \) -print0) +done -# Check if argument is provided -if [ -z "$1" ]; then - echo "Please provide a directory as an argument." - exit 1 -fi - -# Check if directory exists -if [ ! -d "$1" ]; then - echo "$1 is not a valid directory." - exit 1 -fi - -format "$1" +exit $EXIT_CODE -- 2.49.1 From b3011e45db08c05eeb119613919850c6586837a5 Mon Sep 17 00:00:00 2001 From: Romain BOULLARD Date: Wed, 28 Jan 2026 17:13:00 +0100 Subject: [PATCH 6/8] fix permission denied --- .gitea/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 2e63796..8c52204 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -62,4 +62,4 @@ jobs: submodules: recursive - name: Clang Format Checks - run: ./format.sh --check Bigfoot \ No newline at end of file + run: chmod +x format.sh && ./format.sh --check Bigfoot \ No newline at end of file -- 2.49.1 From 30203dda4ae5c434b98e6bd0774604565f45e913 Mon Sep 17 00:00:00 2001 From: Romain BOULLARD Date: Wed, 28 Jan 2026 17:29:53 +0100 Subject: [PATCH 7/8] fix scripts --- format.bat | 9 +++------ format.sh | 35 ++++++++++++++++++++--------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/format.bat b/format.bat index d9f5f51..54d904f 100644 --- a/format.bat +++ b/format.bat @@ -18,6 +18,7 @@ IF "%~1"=="--check" ( ) ELSE IF "%~1"=="--fix" ( SET MODE=fix ) ELSE ( + REM Accumulate directories SET DIRS=!DIRS! "%~1" ) SHIFT @@ -54,14 +55,10 @@ FOR %%D IN (%DIRS%) DO ( ECHO Formatting !FILE! %FMT% -i "!FILE!" ) ELSE ( - REM Check mode: run clang-format --dry-run --Werror + ECHO Checking !FILE! %FMT% --dry-run --Werror "!FILE!" 2>nul IF ERRORLEVEL 1 ( - REM clang-format will already print diagnostic - ECHO --- Diff for !FILE! --- - REM Generate diff using fc - %FMT% "!FILE!" > "%TEMP%\fmt.tmp" - fc "!FILE!" "%TEMP%\fmt.tmp" + REM clang-format will already print diagnostics SET EXIT_CODE=1 ) ) diff --git a/format.sh b/format.sh index ff50922..eb8f665 100644 --- a/format.sh +++ b/format.sh @@ -4,8 +4,11 @@ set -euo pipefail FMT="clang-format" MODE="" DIRS=() +EXIT_CODE=0 +# ========================= # Parse arguments +# ========================= for arg in "$@"; do case "$arg" in --check) @@ -20,18 +23,21 @@ for arg in "$@"; do esac done +# Ensure mode is set if [[ -z "$MODE" ]]; then echo "Usage: $0 --check|--fix [ ...]" exit 1 fi +# Ensure at least one directory if [[ ${#DIRS[@]} -eq 0 ]]; then echo "Please provide at least one directory." exit 1 fi -EXIT_CODE=0 - +# ========================= +# Process directories +# ========================= for DIR in "${DIRS[@]}"; do if [[ ! -d "$DIR" ]]; then echo "$DIR is not a valid directory." @@ -39,25 +45,24 @@ for DIR in "${DIRS[@]}"; do continue fi - while IFS= read -r -d '' file; do - [[ "$file" == *_generated* ]] && continue + # Find all source files safely (null-separated) + while IFS= read -r -d '' FILE; do + [[ "$FILE" == *_generated* ]] && continue if [[ "$MODE" == "fix" ]]; then - echo "Formatting $file" - $FMT -i "$file" + echo "Formatting $FILE" + "$FMT" -i "$FILE" else - # Check mode: run clang-format with dry-run and Werror - # Capture stdout/stderr for diagnostic - if ! $FMT --dry-run --Werror "$file"; then - # clang-format will already print: - # Bigfoot/Tests/System/Time.cpp:21:46: error: code should be clang-formatted [-Wclang-format-violations] - # Now additionally print the diff for clarity - diff_output=$(diff -u "$file" <($FMT -style=file "$file") || true) - echo "$diff_output" + echo "Checking $FILE" + # Check mode: clang-format diagnostic only + if ! "$FMT" --dry-run --Werror "$FILE"; then + # clang-format prints: file:line:col: error ... EXIT_CODE=1 fi fi - done < <(find "$DIR" \( -name '*.h' -o -name '*.hpp' -o -name '*.c' -o -name '*.cpp' -o -name '*.m' -o -name '*.mm' \) -print0) + done < <( + find "$DIR" \( -name '*.h' -o -name '*.hpp' -o -name '*.c' -o -name '*.cpp' -o -name '*.m' -o -name '*.mm' \) -print0 + ) done exit $EXIT_CODE -- 2.49.1 From d25c7cd38c6e959778fe357a209ddc812c5de8e0 Mon Sep 17 00:00:00 2001 From: Romain BOULLARD Date: Wed, 28 Jan 2026 17:39:29 +0100 Subject: [PATCH 8/8] fix formatting --- Bigfoot/Sources/System/Include/System/UUID/UUID.hpp | 3 --- Bigfoot/Sources/Utils/Include/Utils/Version.hpp | 3 +-- Bigfoot/Tests/System/Time.cpp | 3 ++- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Bigfoot/Sources/System/Include/System/UUID/UUID.hpp b/Bigfoot/Sources/System/Include/System/UUID/UUID.hpp index cd20fca..21ff3b1 100644 --- a/Bigfoot/Sources/System/Include/System/UUID/UUID.hpp +++ b/Bigfoot/Sources/System/Include/System/UUID/UUID.hpp @@ -37,11 +37,8 @@ class UUID ~UUID() = default; - [[nodiscard]] operator std::span() const; - [[nodiscard]] operator std::string() const; - [[nodiscard]] operator bool() const; UUID& operator=(const UUID& p_uuid) = default; diff --git a/Bigfoot/Sources/Utils/Include/Utils/Version.hpp b/Bigfoot/Sources/Utils/Include/Utils/Version.hpp index be7b058..2751ec9 100644 --- a/Bigfoot/Sources/Utils/Include/Utils/Version.hpp +++ b/Bigfoot/Sources/Utils/Include/Utils/Version.hpp @@ -92,8 +92,7 @@ class Version return m_combined; } - [[nodiscard]] - operator std::string() const; + [[nodiscard]] operator std::string() const; constexpr Version& operator=(const Version& p_version) = default; diff --git a/Bigfoot/Tests/System/Time.cpp b/Bigfoot/Tests/System/Time.cpp index 38cc795..6a9b602 100644 --- a/Bigfoot/Tests/System/Time.cpp +++ b/Bigfoot/Tests/System/Time.cpp @@ -18,7 +18,8 @@ class TimeFixture: public ::testing::Test /****************************************************************************************/ -TEST_F(TimeFixture, Year_ShouldReturnTheYear){ +TEST_F(TimeFixture, Year_ShouldReturnTheYear) +{ EXPECT_EQ(m_time.Year(), 2026); } -- 2.49.1