Skip to content

Commit

Permalink
update Github CI
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinvn committed Sep 25, 2024
1 parent 2c76ec3 commit 51ad670
Show file tree
Hide file tree
Showing 60 changed files with 759 additions and 469 deletions.
118 changes: 72 additions & 46 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
# - 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
#
#
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
116 changes: 116 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -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"]
}
]
}
2 changes: 2 additions & 0 deletions docs/Doxygen/html/_random_8cpp.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@
<code>#include &lt;gsl/gsl_cdf.h&gt;</code><br />
<code>#include &lt;gsl/gsl_randist.h&gt;</code><br />
<code>#include &lt;cmath&gt;</code><br />
<code>#include &lt;cstdint&gt;</code><br />
<code>#include &lt;random&gt;</code><br />
<code>#include &lt;stdexcept&gt;</code><br />
</div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Expand Down
3 changes: 2 additions & 1 deletion docs/Doxygen/html/_random_8h.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
<div class="headertitle"><div class="title">Random.h File Reference</div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &lt;gsl/gsl_rng.h&gt;</code><br />
<div class="textblock"><code>#include &lt;gsl/gsl_randist.h&gt;</code><br />
<code>#include &lt;gsl/gsl_rng.h&gt;</code><br />
<code>#include &lt;cstddef&gt;</code><br />
<code>#include &lt;cstdint&gt;</code><br />
<code>#include &lt;memory&gt;</code><br />
Expand Down
Loading

0 comments on commit 51ad670

Please sign in to comment.