From 2e3053e427794cbee63c6db0a89ac9616bb94a44 Mon Sep 17 00:00:00 2001 From: Hai Nguyen Date: Wed, 28 Feb 2024 16:33:21 +0100 Subject: [PATCH] Create a github workflow using cmake --- .github/workflows/github_ci.yaml | 40 ++++++++++++++++++++++++++++++++ .gitignore | 3 ++- CMakePresets.json | 2 ++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/github_ci.yaml diff --git a/.github/workflows/github_ci.yaml b/.github/workflows/github_ci.yaml new file mode 100644 index 0000000..dd8b949 --- /dev/null +++ b/.github/workflows/github_ci.yaml @@ -0,0 +1,40 @@ +# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage. +# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml +name: Github CI CMake + +on: + push: + branches: [ "**" ] + pull_request: + branches: [ "main" ] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + build: + # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. + # You can convert this to a matrix build if you need cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Configure CMake + working-directory: ${{github.workspace}} + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake --preset=linux_debug + + - name: Build + working-directory: ${{github.workspace}}/com_bus_controller_pc + # Build your program with the given configuration + run: cmake --build --preset=linux_debug + + - name: Test + working-directory: ${{github.workspace}} + # Execute tests defined by the CMake configuration. + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: ctest preset=github_ci --test-dir build/linux_debug/ \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1ba014d..a0548a8 100755 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ tools/template_generator/*.c tools/template_generator/*.h tools/template_generator/CMakeLists.txt doxygen/ -tools/template_generator/__pycache__/ \ No newline at end of file +tools/template_generator/__pycache__/ +Testing/ \ No newline at end of file diff --git a/CMakePresets.json b/CMakePresets.json index 78e1f0e..1b4173c 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -23,6 +23,7 @@ "displayName": "Linux debug configuration", "description": "Debug configuration using ninja generator on linux", "inherits": "linux_base", + "binaryDir": "${sourceDir}/build/linux_debug", "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } @@ -32,6 +33,7 @@ "displayName": "Linux release configuration", "description": "Release configuration using ninja generator on linux", "inherits": "linux_base", + "binaryDir": "${sourceDir}/build/linux_release", "cacheVariables": { "CMAKE_BUILD_TYPE": "Release" }