Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/iwyu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: IWYU

on:
workflow_call: # Can also run on PRs by changing this to 'pull_request'
pull_request:
jobs:
Analyzers:
name: Check headers (IWYU)
runs-on: ubuntu-latest
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

- 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
29 changes: 27 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,33 @@ 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: |
# Check if PR body contains "no functional change"
if echo "${{ github.event.pull_request.body }}" | grep -iq "no functional changes"; 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 }})

# 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:
Expand Down Expand Up @@ -52,7 +77,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"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/try_compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Compilation

on:
push:

branches-ignore: main
jobs:
build:
runs-on: ${{ matrix.os }}
Expand Down
7 changes: 5 additions & 2 deletions attacks.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "attacks.h"

#include "bitboard.h"
#include <cstddef>
#include <initializer_list>
#include <utility>
namespace chess::_chess {
// [INTERNAL]

Expand Down Expand Up @@ -190,4 +193,4 @@ inline static std::array<std::array<Bitboard, SQ_NONE + 1>, SQ_NONE + 1> generat
return squares_between_bb;
}
std::array<std::array<Bitboard, SQ_NONE + 1>, SQ_NONE + 1> SQUARES_BETWEEN_BB = generate_between();
} // namespace chess::movegen
} // namespace chess::movegen
2 changes: 0 additions & 2 deletions attacks.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#pragma once
#include "bitboard.h"
#include "fwd_decl.h"
#include "types.h"
#include <array>
#include <immintrin.h>
Expand Down
6 changes: 3 additions & 3 deletions moves_io.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "moves_io.h"
#include "attacks.h"
#include "position.h"
#include "types.h"
#include <algorithm>
#include <iostream>
#include <regex>
#include <cassert>
#include <cctype>
#include <string_view>
#if defined(__EXCEPTIONS)
#define THROW_IF_EXCEPTIONS_ON(stuff) throw stuff
#else
#define THROW_IF_EXCEPTIONS_ON(stuff) ((void)0)
Expand Down
8 changes: 5 additions & 3 deletions moves_io.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#pragma once
#include "fwd_decl.h"
#include <cstdint>
#include <stdexcept>
#include "types.h"
#include <exception>
#include <string>
#include <string_view>
namespace chess {
template <typename T, typename> class _Position;
}
namespace chess::uci {
std::string moveToUci(Move move, bool chess960 = false);

Expand Down
1 change: 1 addition & 0 deletions position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "printers.h"
#include "zobrist.h"
#include <algorithm>
#include <initializer_list>
#include <iostream>
#include <sstream>
#include <utility>
Expand Down
6 changes: 6 additions & 0 deletions position.h
Original file line number Diff line number Diff line change
@@ -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 <algorithm>
#include <array>
#include <cassert>
#include <cstdint>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <vector>
namespace chess {

Expand Down
4 changes: 3 additions & 1 deletion printers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
#include "moves_io.h"
#include "position.h"
#include <algorithm>
#include <cctype>
#include <iomanip>
#include <iostream>
#include <string>
#include <unordered_map>
namespace chess {
template <typename T> using DescriptiveNameNotation = std::unordered_map<T, std::string>;
Expand Down Expand Up @@ -146,4 +148,4 @@ template <typename PieceC, typename> std::ostream &operator<<(std::ostream &os,
INSTANTITATE(EnginePiece)
INSTANTITATE(PolyglotPiece)
INSTANTITATE(ContiguousMappingPiece)
} // namespace chess
} // namespace chess
5 changes: 2 additions & 3 deletions printers.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once
#include "fwd_decl.h"
#include <cstdint>
#include "types.h"
#include <iosfwd>
#include <type_traits>
namespace chess {
Expand All @@ -16,4 +15,4 @@ template <typename T, typename> class _Position;

template <typename PieceC = EnginePiece, typename = std::enable_if_t<is_piece_enum<PieceC>::value>>
std::ostream &operator<<(std::ostream &os, const _Position<PieceC, void> &pos);
} // namespace chess
} // namespace chess
Loading