diff --git a/.bazelrc b/.bazelrc index da598dff..47df4933 100644 --- a/.bazelrc +++ b/.bazelrc @@ -11,7 +11,6 @@ build --host_cxxopt='-std=c++23' # Enable warnings build --cxxopt='-Wall' build --cxxopt='-Wextra' -build --cxxopt='-Wpedantic' build --cxxopt='-Werror' build --cxxopt='-Wno-unused-parameter' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 09fb30df..893e3bbc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,60 +22,14 @@ jobs: with: clang-format-version: 19 - build-and-test-cmake: - name: Build and Test (CMake) - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Cache CCache - uses: actions/cache@v4 - id: ccache - with: - path: ~/.cache/ccache - key: ${{ runner.os }}-ccache-${{ hashFiles('conanfile.py') }}-${{ hashFiles('CMakeLists.txt') }}-${{ hashFiles('CMakePresets.json') }}-${{ github.run_id }} - restore-keys: | - ${{ runner.os }}-ccache-${{ hashFiles('conanfile.py') }}-${{ hashFiles('CMakeLists.txt') }}-${{ hashFiles('CMakePresets.json') }}- - ${{ runner.os }}-ccache- - - - name: Setup Conan - uses: hankhsu1996/setup-conan@v1 - with: - conan-version: "2.5.0" - cache-dependencies: true - cache-tool: true - - - name: Install Clang 19 - run: | - sudo apt-get update - sudo apt-get install -y clang-19 - sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-19 100 - sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-19 100 - sudo update-alternatives --set clang++ /usr/bin/clang++-19 - sudo update-alternatives --set clang /usr/bin/clang-19 - - - name: Install dependencies - run: | - conan profile detect --force - conan install . --build=missing - conan install . -s build_type=Debug --build=missing - - - name: Verify Clang is available - run: clang --version - - - name: Configure CMake and build project - run: | - cmake --preset release - cmake --build --preset release - - - name: Run tests - run: ctest --preset release - build-and-test-bazel: - name: Build and Test (Bazel) + name: Build and Test (Bazel, ${{ matrix.compiler.name }}-${{ matrix.compiler.version }}) runs-on: ubuntu-latest + strategy: + matrix: + compiler: + - { name: gcc, version: 13, cc: gcc-13, cxx: g++-13 } + - { name: clang, version: 19, cc: clang-19, cxx: clang++-19 } steps: - name: Checkout code @@ -88,31 +42,40 @@ jobs: disk-cache: ${{ github.workflow }} repository-cache: true - - name: Install Clang 19 + - name: Install ${{ matrix.compiler.name }}-${{ matrix.compiler.version }} run: | sudo apt-get update - sudo apt-get install -y clang-19 - sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-19 100 - sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-19 100 - sudo update-alternatives --set clang++ /usr/bin/clang++-19 - sudo update-alternatives --set clang /usr/bin/clang-19 + sudo apt-get install -y ${{ matrix.compiler.cc }} ${{ matrix.compiler.cxx }} - - name: Verify Clang is available - run: clang --version + - name: Verify compiler is available + run: ${{ matrix.compiler.cxx }} --version - name: Build with Bazel run: | - # Build release configuration - bazel build //... - # Build debug configuration - bazel build //... --config=debug + bazel build //... --action_env=CC=${{ matrix.compiler.cc }} --action_env=CXX=${{ matrix.compiler.cxx }} + bazel build //... --config=debug --action_env=CC=${{ matrix.compiler.cc }} --action_env=CXX=${{ matrix.compiler.cxx }} - name: Test with Bazel run: | - # Test release configuration - bazel test //... --test_output=all --test_timeout=5 - # Test debug configuration - bazel test //... --config=debug --test_output=all --test_timeout=5 + bazel test //... --test_output=all --test_timeout=5 --action_env=CC=${{ matrix.compiler.cc }} --action_env=CXX=${{ matrix.compiler.cxx }} + bazel test //... --config=debug --test_output=all --test_timeout=5 --action_env=CC=${{ matrix.compiler.cc }} --action_env=CXX=${{ matrix.compiler.cxx }} + + build-and-test-windows: + name: Build and Test (CMake, MSVC) + runs-on: windows-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Configure CMake + run: cmake -S . -B build -DBUILD_TESTS=ON + + - name: Build + run: cmake --build build --config Release + + - name: Run tests + run: ctest --test-dir build -C Release -E "PipeTransport|FramedPipeTransport" --output-on-failure docs: name: Generate Documentation diff --git a/.gitignore b/.gitignore index 84b9810f..3b62c7c4 100644 --- a/.gitignore +++ b/.gitignore @@ -78,3 +78,6 @@ compile_commands.json # Misc *.tmp.* + +# Local configuration +*.local.md diff --git a/README.md b/README.md index fd8235ce..13066f8d 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ![GitHub Release](https://img.shields.io/github/v/release/hankhsu1996/jsonrpc-cpp-lib) ![GitHub License](https://img.shields.io/github/license/hankhsu1996/jsonrpc-cpp-lib) -Welcome to the **JSON-RPC 2.0 Modern C++ Library**! This library provides a lightweight, modern C++ implementation of [JSON-RPC 2.0](https://www.jsonrpc.org/specification) servers and clients. It is designed to be flexible, allowing integration with various transport layers. This library makes it easy to register methods and notifications, binding them to client logic efficiently. +A lightweight, modern C++ implementation of [JSON-RPC 2.0](https://www.jsonrpc.org/specification) servers and clients. The library is designed to be flexible, allowing integration with various transport layers, and provides straightforward method and notification registration. ## Features @@ -49,7 +49,7 @@ CMake offers two main approaches for including this library: ##### A. As a Build-Time Dependency (FetchContent) -This approach downloads and builds the library as part of your project. It's ideal for development workflows where you want everything self-contained: +This approach downloads and builds the library as part of your project, suitable for development workflows where a self-contained build is desired: ```cmake include(FetchContent) @@ -66,7 +66,7 @@ target_link_libraries(your_app PRIVATE jsonrpc::jsonrpc) ##### B. As a System-Wide Installation (find_package) -This approach uses a pre-installed version of the library. It's better for production environments and system-wide installations: +This approach uses a pre-installed version of the library, appropriate for production environments and system-wide installations: 1. First, install the library: @@ -318,7 +318,7 @@ In both cases, the `compile_commands.json` file will be placed in the root direc ## Contributing -We welcome contributions! If you have suggestions or find any issues, feel free to open an issue or pull request. +Contributions are welcome. If you have suggestions or find issues, please open an issue or pull request. ## License diff --git a/tests/endpoint/dispatcher_test.cpp b/tests/endpoint/dispatcher_test.cpp index f08db1ef..fc19ce72 100644 --- a/tests/endpoint/dispatcher_test.cpp +++ b/tests/endpoint/dispatcher_test.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include diff --git a/tests/endpoint/endpoint_test.cpp b/tests/endpoint/endpoint_test.cpp index fdbbdb1f..bfcce7be 100644 --- a/tests/endpoint/endpoint_test.cpp +++ b/tests/endpoint/endpoint_test.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include