From d0e45a42a0d7f88fa8bf7a755627434b612f8fc9 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Tue, 31 Mar 2026 22:08:39 +0700 Subject: [PATCH 01/10] Ignore main branch in push events for compilation --- .github/workflows/try_compile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/try_compile.yml b/.github/workflows/try_compile.yml index e436057..a1759f3 100644 --- a/.github/workflows/try_compile.yml +++ b/.github/workflows/try_compile.yml @@ -2,7 +2,7 @@ name: Compilation on: push: - + branches-ignore: main jobs: build: runs-on: ${{ matrix.os }} From bbe843dd6324e64c3b7e29d6d8f13466f1bc1012 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Tue, 31 Mar 2026 22:13:20 +0700 Subject: [PATCH 02/10] Add IWYU workflow for header analysis --- .github/workflows/iwyu.yml | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/iwyu.yml diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml new file mode 100644 index 0000000..4154811 --- /dev/null +++ b/.github/workflows/iwyu.yml @@ -0,0 +1,48 @@ +name: IWYU + +on: + workflow_call: # Can also run on PRs by changing this to 'pull_request' + +jobs: + Analyzers: + name: Check headers (IWYU) + runs-on: ubuntu-22.04 + defaults: + run: + working-directory: ${{ github.workspace }} + shell: bash + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt update + sudo apt install -y cmake ninja-build clang-17 libc++-17-dev libclang-17-dev wget + + - name: Checkout IWYU + uses: actions/checkout@v4 + with: + repository: include-what-you-use/include-what-you-use + ref: f25caa280dc3277c4086ec345ad279a2463fea0f + path: include-what-you-use + persist-credentials: false + + - name: Build IWYU + run: | + mkdir -p build_iwyu && cd build_iwyu + cmake -G "Ninja" -DCMAKE_PREFIX_PATH="/usr/lib/llvm-17" ../include-what-you-use + ninja + sudo ninja install + working-directory: include-what-you-use + + - name: Check IWYU version + run: include-what-you-use --version + + - name: Run IWYU analysis + run: | + # Generate compile_commands.json for your library + cmake -B build_iwyu_analysis -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -S . + + # Run IWYU on all source files + iwyu_tool.py -p build_iwyu_analysis -- -Xiwyu --mapping="${{ github.workspace }}/.github/ci/libcxx17.imp" -Xiwyu --error From 079ea74fd9843be000f87ebacb30734a5b346aaf Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Tue, 31 Mar 2026 22:17:34 +0700 Subject: [PATCH 03/10] Add job to check for functional changes in PR Added a job to determine if functional changes exist based on modified .cpp or .c files. The build job now depends on this check to skip full tests if no relevant changes are detected. --- .github/workflows/test.yml | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4e1a665..eabaa1c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,8 +5,28 @@ on: branches: [ "main" ] jobs: + determine_changes: + name: Determine if functional changes exist + runs-on: ubuntu-latest + outputs: + skip_full_tests: ${{ steps.check.outputs.skip_full_tests }} + steps: + - uses: actions/checkout@v4 + - id: check + run: | + # List changed files between PR base and head + CHANGED=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }}) + + # Check if any .cpp or .c files changed + if echo "$CHANGED" | grep -E '\.(cpp|c)$' >/dev/null; then + echo "skip_full_tests=false" >> "$GITHUB_OUTPUT" + else + echo "skip_full_tests=true" >> "$GITHUB_OUTPUT" + fi + build: - if: ${{ !endsWith(github.event.pull_request.title, 'no functional change') }} + needs: determine_changes + if: ${{ needs.determine_changes.outputs.skip_full_tests != 'true' }} runs-on: ${{ matrix.os }} strategy: @@ -52,7 +72,7 @@ jobs: shell: bash run: | if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then - if "${{ matrix.cpp_compiler }}" == "clang++" ]]; then + if [[ "${{ matrix.cpp_compiler }}" == "clang++" ]]; then SANITIZERS="memory,undefined" else SANITIZERS="address,undefined" From d621906f49cad437c42f9eb60962b3933253be26 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Tue, 31 Mar 2026 22:17:50 +0700 Subject: [PATCH 04/10] Update iwyu.yml --- .github/workflows/iwyu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml index 4154811..54f70b5 100644 --- a/.github/workflows/iwyu.yml +++ b/.github/workflows/iwyu.yml @@ -2,7 +2,7 @@ name: IWYU on: workflow_call: # Can also run on PRs by changing this to 'pull_request' - + pull_request: jobs: Analyzers: name: Check headers (IWYU) From 7beb57fa4a3be866e6b4720cf49116809b171842 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Tue, 31 Mar 2026 22:24:49 +0700 Subject: [PATCH 05/10] Implement skip tests condition based on PR body Add check for 'no functional change' in PR body to skip full tests. --- .github/workflows/test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eabaa1c..09dfdd1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,6 +14,11 @@ jobs: - uses: actions/checkout@v4 - id: check run: | + # Check if PR body contains "no functional change" + if echo "${{ github.event.pull_request.body }}" | grep -iq "no functional change"; then + echo "skip_full_tests=true" >> $GITHUB_OUTPUT + exit 0 + fi # List changed files between PR base and head CHANGED=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }}) From a65274d556d2fd9277cec8e6d9b4a7bb831d950a Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Tue, 31 Mar 2026 22:25:25 +0700 Subject: [PATCH 06/10] Update test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 09dfdd1..9c8cc1d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: - id: check run: | # Check if PR body contains "no functional change" - if echo "${{ github.event.pull_request.body }}" | grep -iq "no functional change"; then + if echo "${{ github.event.pull_request.body }}" | grep -iq "no functional changes"; then echo "skip_full_tests=true" >> $GITHUB_OUTPUT exit 0 fi From 32acf59f03b2cbeab6cba3f444a5dd5f983643a5 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Tue, 31 Mar 2026 22:30:55 +0700 Subject: [PATCH 07/10] Update runner version to ubuntu-latest in iwyu.yml --- .github/workflows/iwyu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml index 54f70b5..8147f4c 100644 --- a/.github/workflows/iwyu.yml +++ b/.github/workflows/iwyu.yml @@ -6,7 +6,7 @@ on: jobs: Analyzers: name: Check headers (IWYU) - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest defaults: run: working-directory: ${{ github.workspace }} From a86718bba727f37a789b672f39f3e46f2c11d7ea Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Tue, 31 Mar 2026 22:38:11 +0700 Subject: [PATCH 08/10] Update iwyu.yml --- .github/workflows/iwyu.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml index 8147f4c..7f34c2d 100644 --- a/.github/workflows/iwyu.yml +++ b/.github/workflows/iwyu.yml @@ -34,7 +34,6 @@ jobs: cmake -G "Ninja" -DCMAKE_PREFIX_PATH="/usr/lib/llvm-17" ../include-what-you-use ninja sudo ninja install - working-directory: include-what-you-use - name: Check IWYU version run: include-what-you-use --version From 823c405212a536ced2923ab917133062ffa4f6c8 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Tue, 31 Mar 2026 22:57:41 +0700 Subject: [PATCH 09/10] patches (#50) * Update position.h * Replace sstream with initializer_list include * Apply clang-format * Remove unused includes from attacks.h Removed unnecessary includes for bitboard and forward declarations. * Add necessary includes to attacks.cpp Added includes for cstddef, initializer_list, utility, and bitboard. * Apply clang-format * Update includes in moves_io.h Replaced includes and added types.h for better type handling. * Apply clang-format * Update moves_io.cpp * Apply clang-format * Add additional includes to position.h * Apply clang-format * Update printers.h * Update printers.cpp * Apply clang-format * Include stdexcept for exception handling Added include for stdexcept to handle exceptions. * Apply clang-format --------- Co-authored-by: GitHub Actions --- attacks.cpp | 7 +++++-- attacks.h | 2 -- moves_io.cpp | 6 +++--- moves_io.h | 8 +++++--- position.cpp | 2 +- position.h | 6 ++++++ printers.cpp | 4 +++- printers.h | 5 ++--- 8 files changed, 25 insertions(+), 15 deletions(-) diff --git a/attacks.cpp b/attacks.cpp index 69d0efc..899f960 100644 --- a/attacks.cpp +++ b/attacks.cpp @@ -1,5 +1,8 @@ #include "attacks.h" - +#include "bitboard.h" +#include +#include +#include namespace chess::_chess { // [INTERNAL] @@ -190,4 +193,4 @@ inline static std::array, SQ_NONE + 1> generat return squares_between_bb; } std::array, SQ_NONE + 1> SQUARES_BETWEEN_BB = generate_between(); -} // namespace chess::movegen \ No newline at end of file +} // namespace chess::movegen diff --git a/attacks.h b/attacks.h index 5027d84..08d4b22 100644 --- a/attacks.h +++ b/attacks.h @@ -1,6 +1,4 @@ #pragma once -#include "bitboard.h" -#include "fwd_decl.h" #include "types.h" #include #include diff --git a/moves_io.cpp b/moves_io.cpp index 06a89fe..6d613da 100644 --- a/moves_io.cpp +++ b/moves_io.cpp @@ -1,11 +1,11 @@ #include "moves_io.h" +#include "attacks.h" #include "position.h" #include "types.h" #include -#include -#include +#include +#include #include -#if defined(__EXCEPTIONS) #define THROW_IF_EXCEPTIONS_ON(stuff) throw stuff #else #define THROW_IF_EXCEPTIONS_ON(stuff) ((void)0) diff --git a/moves_io.h b/moves_io.h index 5dccb74..b94cda1 100644 --- a/moves_io.h +++ b/moves_io.h @@ -1,9 +1,11 @@ #pragma once -#include "fwd_decl.h" -#include -#include +#include "types.h" +#include #include #include +namespace chess { +template class _Position; +} namespace chess::uci { std::string moveToUci(Move move, bool chess960 = false); diff --git a/position.cpp b/position.cpp index fb0b5b7..8282e52 100644 --- a/position.cpp +++ b/position.cpp @@ -4,8 +4,8 @@ #include "printers.h" #include "zobrist.h" #include +#include #include -#include #include #ifndef GENERATE_AT_RUNTIME #define _POSSIBLY_CONSTEXPR constexpr diff --git a/position.h b/position.h index 178e886..e7113a2 100644 --- a/position.h +++ b/position.h @@ -1,11 +1,17 @@ #pragma once #include "attacks.h" #include "bitboard.h" +#include "fwd_decl.h" #include "movegen.h" #include "types.h" #include "zobrist.h" +#include +#include +#include +#include #include #include +#include #include namespace chess { diff --git a/printers.cpp b/printers.cpp index 74e69cc..f13315b 100644 --- a/printers.cpp +++ b/printers.cpp @@ -2,8 +2,10 @@ #include "moves_io.h" #include "position.h" #include +#include #include #include +#include #include namespace chess { template using DescriptiveNameNotation = std::unordered_map; @@ -146,4 +148,4 @@ template std::ostream &operator<<(std::ostream &os, INSTANTITATE(EnginePiece) INSTANTITATE(PolyglotPiece) INSTANTITATE(ContiguousMappingPiece) -} // namespace chess \ No newline at end of file +} // namespace chess diff --git a/printers.h b/printers.h index 42581c0..96bec90 100644 --- a/printers.h +++ b/printers.h @@ -1,6 +1,5 @@ #pragma once -#include "fwd_decl.h" -#include +#include "types.h" #include #include namespace chess { @@ -16,4 +15,4 @@ template class _Position; template ::value>> std::ostream &operator<<(std::ostream &os, const _Position &pos); -} // namespace chess \ No newline at end of file +} // namespace chess From 2199ccc4e2f14a6ab96131807e3344a3a7f375f4 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Tue, 31 Mar 2026 22:59:00 +0700 Subject: [PATCH 10/10] Add sstream include to position.cpp --- position.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/position.cpp b/position.cpp index 8282e52..b35fe13 100644 --- a/position.cpp +++ b/position.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #ifndef GENERATE_AT_RUNTIME #define _POSSIBLY_CONSTEXPR constexpr