diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b672eef..d8f4fa8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,63 +2,89 @@ name: C++ CI on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] + +env: + VCPKG_ROOT: ${{ github.workspace }}/vcpkg + CMAKE_BUILD_TYPE: Release + BUILD_DIR: build + VCPKG_TRIPLET: x64-linux jobs: build-and-test: + name: Build and Test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y cmake g++ make - - - name: Build - run: | - mkdir build && cd build - cmake .. - make - - - name: Run tests - run: | - cd build - ctest --output-on-failure - - lint: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 + - name: Show C++ version + run: | + /usr/bin/c++ --version - - name: Install clang-format - run: sudo apt-get install -y clang-format + # Checkout the repository + - name: Checkout Repository + uses: actions/checkout@v3 - - name: Run clang-format - run: | - find src tests -name '*.cpp' -o -name '*.h' | xargs clang-format -i --style=file - git diff --exit-code + # Install latest CMake and Ninja + - name: Install CMake and Ninja + uses: lukka/get-cmake@latest - clang-tidy: - runs-on: ubuntu-latest + # Set up vcpkg using lukka/get-vcpkg action + - name: Setup vcpkg + uses: + lukka/run-vcpkg@v11 - steps: - - uses: actions/checkout@v2 + # Run CMake to generate Ninja project files, using the vcpkg's toolchain file to resolve and install + # the dependencies as specified in vcpkg.json. Note that the vcpkg's toolchain is specified + # in the CMakePresets.json file. + # This step also runs vcpkg with Binary Caching leveraging GitHub Action cache to + # store the built packages artifacts. + - name: Restore from cache the dependencies and generate project files + run: | + cmake --preset ninja-multi-vcpkg-ci - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y cmake g++ make clang-tidy + # Build (Release configuration only) the whole project with Ninja (which is spawn by CMake). + # + # Note: if the preset misses the "configuration", it is possible to explicitly select the + # configuration with the `--config` flag, e.g.: + # run: cmake --build --preset ninja-vcpkg --config Release + - name: Build (Release configuration) + run: | + cmake --build --preset ninja-vcpkg-release-ci - - name: Generate compile_commands.json - run: | - mkdir build && cd build - cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. + # Test the whole project with CTest, again Release configuration only. + - name: Test (Release configuration) + run: | + ctest --preset test-release-ci - - name: Run clang-tidy - run: | - find src tests -name '*.cpp' -o -name '*.h' | xargs clang-tidy -p build \ No newline at end of file + # - name: Install clang-tidy + # run: sudo apt-get update && sudo apt-get install -y clang-tidy + # + # # Run clang-tidy on all source and header files + # - name: Run clang-tidy + # run: | + # find src tests -type f \( -name '*.cpp' -o -name '*.h' \) -print0 | xargs -0 clang-tidy -p build + # + # + # format: + # name: Code Formatting + # runs-on: ubuntu-latest + # + # steps: + # # 1. Checkout the repository + # - name: Checkout Repository + # uses: actions/checkout@v3 + # + # # 2. Install clang-format + # - name: Install clang-format + # run: sudo apt-get update && sudo apt-get install -y clang-format + # + # # 3. Run clang-format on source and header files + # - name: Run clang-format + # run: | + # find src tests -type f \( -name '*.cpp' -o -name '*.h' \) -print0 | xargs -0 clang-format -i --style=file + # # Check for formatting changes + # git diff --exit-code + # + # diff --git a/CMakeLists.txt b/CMakeLists.txt index c47def8..0351864 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ endif() project(malasim) # Set C++ standard -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..eb02897 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,116 @@ +{ + "version": 8, + "cmakeMinimumRequired": { + "major": 3, + "minor": 21, + "patch": 0 + }, + "configurePresets": [ + { + "name": "ninja-multi-vcpkg-ci", + "displayName": "Ninja Multi-Config", + "description": "Configure with vcpkg toolchain and generate Ninja project files for all configurations", + "binaryDir": "${sourceDir}/build/${presetName}", + "generator": "Ninja Multi-Config", + "toolchainFile": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "CMAKE_TOOLCHAIN_FILE": "${env.VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON", + "CMAKE_CXX_STANDARD": "20", + "CMAKE_CXX_STANDARD_REQUIRED": "ON", + "CMAKE_CXX_EXTENSIONS": "OFF" + } + }, + { + "name": "ninja-multi-vcpkg-local", + "displayName": "Ninja Multi-Config Local", + "description": "Configure with vcpkg toolchain and generate Ninja project files for all configurations", + "binaryDir": "${sourceDir}/build/${presetName}", + "generator": "Ninja Multi-Config", + "toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" + } + ], + "buildPresets": [ + { + "name": "ninja-vcpkg-debug-ci", + "configurePreset": "ninja-multi-vcpkg-ci", + "displayName": "Build (Debug)", + "description": "Build with Ninja/vcpkg (Debug)", + "configuration": "Debug" + }, + { + "name": "ninja-vcpkg-release-ci", + "configurePreset": "ninja-multi-vcpkg-ci", + "displayName": "Build (Release)", + "description": "Build with Ninja/vcpkg (Release)", + "configuration": "Release" + }, + { + "name": "ninja-vcpkg-ci", + "configurePreset": "ninja-multi-vcpkg-ci", + "displayName": "Build", + "description": "Build with Ninja/vcpkg" + }, + { + "name": "ninja-vcpkg-debug-local", + "configurePreset": "ninja-multi-vcpkg-local", + "displayName": "Build (Debug)", + "description": "Build with Ninja/vcpkg (Debug)", + "configuration": "Debug" + }, + { + "name": "ninja-vcpkg-release-local", + "configurePreset": "ninja-multi-vcpkg-local", + "displayName": "Build (Release)", + "description": "Build with Ninja/vcpkg (Release)", + "configuration": "Release" + }, + { + "name": "ninja-vcpkg-local", + "configurePreset": "ninja-multi-vcpkg-local", + "displayName": "Build", + "description": "Build with Ninja/vcpkg" + } + ], + "testPresets": [ + { + "name": "test-ninja-vcpkg-ci", + "configurePreset": "ninja-multi-vcpkg-ci", + "hidden": true + }, + { + "name": "test-debug-ci", + "description": "Test (Debug)", + "displayName": "Test (Debug)", + "configuration": "Debug", + "inherits": ["test-ninja-vcpkg-ci"] + }, + { + "name": "test-release-ci", + "description": "Test (Release)", + "displayName": "Test (Release)", + "configuration": "Release", + "inherits": ["test-ninja-vcpkg-ci"] + }, + { + "name": "test-ninja-vcpkg-local", + "configurePreset": "ninja-multi-vcpkg-local", + "hidden": true + }, + { + "name": "test-debug-local", + "description": "Test (Debug)", + "displayName": "Test (Debug)", + "configuration": "Debug", + "inherits": ["test-ninja-vcpkg-local"] + }, + { + "name": "test-release-local", + "description": "Test (Release)", + "displayName": "Test (Release)", + "configuration": "Release", + "inherits": ["test-ninja-vcpkg-local"] + } + ] +} diff --git a/docs/Doxygen/html/_random_8cpp.html b/docs/Doxygen/html/_random_8cpp.html index 8302503..b5a6a50 100644 --- a/docs/Doxygen/html/_random_8cpp.html +++ b/docs/Doxygen/html/_random_8cpp.html @@ -96,7 +96,9 @@ #include <gsl/gsl_cdf.h>
#include <gsl/gsl_randist.h>
#include <cmath>
+#include <cstdint>
#include <random>
+#include <stdexcept>