From f67ca35a31d5aff96d241acab7119161834ee123 Mon Sep 17 00:00:00 2001 From: Wojciech Matusiak <62173407+WojtekMs@users.noreply.github.com> Date: Sun, 23 Mar 2025 17:53:37 +0100 Subject: [PATCH 1/5] Add formatting check to CI --- .github/workflows/ci.yml | 19 +++++++++++++++++-- requirements.txt | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 316d300..b5a1ea9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,9 +7,22 @@ on: branches: [ master ] jobs: + check_cc: + name: Check Coding Conventions + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v2 + + - name: Install pip dependencies + run: pip install -r requirements.txt + + - name: Check code formatting + run: find src/ include/ -regex ".*\.\(hpp\|cpp\|c\|h\)$" -execdir clang-format --style=LLVM --dry-run --Werror {} + ; + build: name: ${{ matrix.platform.name }} runs-on: ${{ matrix.platform.os }} + needs: check_cc strategy: fail-fast: false @@ -21,10 +34,12 @@ jobs: steps: - uses: actions/checkout@v2 + + - name: Install pip dependencies + run: pip install -r requirements.txt - - name: Install dependencies && configure + - name: Install conan dependencies && configure run: | - pip install 'conan~=2.0' conan install . --build=missing --profile:all ${{github.workspace}}/.github/profiles/${{matrix.platform.profile}} -c tools.system.package_manager:mode=install -c tools.system.package_manager:sudo=True - name: Build diff --git a/requirements.txt b/requirements.txt index 1a90aa8..37cd817 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ clang-format==20.1.0 +conan~=2.0 From 04ef094dd3d494a34c45782a260fb21466e0120a Mon Sep 17 00:00:00 2001 From: Wojciech Matusiak <62173407+WojtekMs@users.noreply.github.com> Date: Sun, 23 Mar 2025 18:52:27 +0100 Subject: [PATCH 2/5] Use check_formatting script on CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5a1ea9..a735231 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: run: pip install -r requirements.txt - name: Check code formatting - run: find src/ include/ -regex ".*\.\(hpp\|cpp\|c\|h\)$" -execdir clang-format --style=LLVM --dry-run --Werror {} + ; + run: bash infra/scripts/check_formatting.sh . build: name: ${{ matrix.platform.name }} From 6f7726c2b0e784bf0af45a3b3c00e72d2f11ad0e Mon Sep 17 00:00:00 2001 From: Wojciech Matusiak <62173407+WojtekMs@users.noreply.github.com> Date: Sun, 23 Mar 2025 18:53:05 +0100 Subject: [PATCH 3/5] Introduce formatting issue to test CI --- src/Box.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Box.cpp b/src/Box.cpp index 1441669..8eb8bf7 100644 --- a/src/Box.cpp +++ b/src/Box.cpp @@ -7,7 +7,7 @@ Box::Box(const std::string &text) : path_to_textures("images/board/"), max_char_count_inside_box(12), max_number_of_text_lines_inside_box(3), box_text_x_pos(-1.0f), box_text_y_pos(-1.0f), button_x_pos(-1.0f), button_y_pos(-1.0f) { - load_box_texture(); + load_box_texture(); load_font(); set_default_text(text); update_max_char_count(); From fca21a1914c22f4b237d0beac4a8dd757998267f Mon Sep 17 00:00:00 2001 From: Wojciech Matusiak <62173407+WojtekMs@users.noreply.github.com> Date: Sun, 23 Mar 2025 18:55:07 +0100 Subject: [PATCH 4/5] Fix formatting scripts Scripts now require you to activate venv before running it --- infra/hooks/pre-commit | 1 + infra/scripts/apply_formatting.sh | 2 +- infra/scripts/check_formatting.sh | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) mode change 100644 => 100755 infra/hooks/pre-commit diff --git a/infra/hooks/pre-commit b/infra/hooks/pre-commit old mode 100644 new mode 100755 index 629a96a..9ad9a1c --- a/infra/hooks/pre-commit +++ b/infra/hooks/pre-commit @@ -46,6 +46,7 @@ EOF fi # Check code formatting +. env/bin/activate bash ./infra/scripts/check_formatting.sh $(pwd) FORMATTING_EC=$? if [[ $FORMATTING_EC -ne 0 ]]; then diff --git a/infra/scripts/apply_formatting.sh b/infra/scripts/apply_formatting.sh index 889ec86..5d7d42e 100644 --- a/infra/scripts/apply_formatting.sh +++ b/infra/scripts/apply_formatting.sh @@ -14,7 +14,7 @@ if [[ ! -d .git ]]; then fi echo "Applying code formatting..." -. env/bin/activate && find src/ include/ -regex ".*\.\(hpp\|cpp\|c\|h\)$" -execdir clang-format --style=LLVM -i {} + ; +find src/ include/ -regex ".*\.\(hpp\|cpp\|c\|h\)$" -execdir clang-format --style=LLVM -i {} + ; FORMATTING_EC=$? if [[ $FORMATTING_EC -ne 0 ]]; then exit 1 diff --git a/infra/scripts/check_formatting.sh b/infra/scripts/check_formatting.sh index 4e138eb..4814779 100644 --- a/infra/scripts/check_formatting.sh +++ b/infra/scripts/check_formatting.sh @@ -14,7 +14,7 @@ if [[ ! -d .git ]]; then fi echo "Checking code formatting..." -. env/bin/activate && find src/ include/ -regex ".*\.\(hpp\|cpp\|c\|h\)$" -execdir clang-format --style=LLVM --dry-run --Werror {} + ; +find src/ include/ -regex ".*\.\(hpp\|cpp\|c\|h\)$" -execdir clang-format --style=LLVM --dry-run --Werror {} + ; FORMATTING_EC=$? if [[ $FORMATTING_EC -ne 0 ]]; then exit 1 From 1a88f28c252742bd3a387d838de02bf3a68e574c Mon Sep 17 00:00:00 2001 From: Wojciech Matusiak <62173407+WojtekMs@users.noreply.github.com> Date: Sun, 23 Mar 2025 18:57:46 +0100 Subject: [PATCH 5/5] Revert "Introduce formatting issue to test CI" This reverts commit 6f7726c2b0e784bf0af45a3b3c00e72d2f11ad0e. --- src/Box.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Box.cpp b/src/Box.cpp index 8eb8bf7..1441669 100644 --- a/src/Box.cpp +++ b/src/Box.cpp @@ -7,7 +7,7 @@ Box::Box(const std::string &text) : path_to_textures("images/board/"), max_char_count_inside_box(12), max_number_of_text_lines_inside_box(3), box_text_x_pos(-1.0f), box_text_y_pos(-1.0f), button_x_pos(-1.0f), button_y_pos(-1.0f) { - load_box_texture(); + load_box_texture(); load_font(); set_default_text(text); update_max_char_count();