Skip to content

Commit

Permalink
Add CI setup that performs code analysis and build checks (#14)
Browse files Browse the repository at this point in the history
* Add CI setup that performs code analysis and build checks

* Fix cmake indentation
  • Loading branch information
BugelNiels authored Sep 29, 2024
1 parent b62c122 commit 170b2ee
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 26 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: C++ CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3

# Set up C++ toolchain
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential cmake cppcheck clang-format
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: '6.5.*'

# Run static code analysis using cppcheck
- name: Static analysis (cppcheck)
run: |
cppcheck --enable=all --inconclusive --std=c++17 --force . 2> cppcheck-report.txt || true
# Upload cppcheck results as an artifact (Corrected indentation)
- name: Upload cppcheck report
uses: actions/upload-artifact@v3
with:
name: cppcheck-report
path: cppcheck-report.txt

# Run linting on C++ files using clang-format
- name: Lint C++ files (clang-format)
run: |
find . -name '*.cpp' -o -name '*.hpp' | xargs clang-format -i
# Run linting on CMake files using cmakelint
- name: Install pip and cmakelint
run: |
sudo apt-get install -y python3-pip
pip install cmakelint
- name: Lint CMake files
run: |
find . -name 'CMakeLists.txt' -o -name '*.cmake' | xargs cmakelint --linelength=120
# Build the project using CMake
- name: Create build directory
run: mkdir build

- name: Configure with CMake
run: cmake -S . -B build

- name: Build with CMake
run: cmake --build build
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ CatmarkSubdiv
.code-workspace

# Other IDE files

.idea

# OS X
Expand Down Expand Up @@ -62,4 +61,5 @@ CatmarkSubdiv
*.toc
*.vrb

saves/
saves/
venv
45 changes: 21 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,32 @@ include(GNUInstallDirs)
find_package(QT NAMES Qt5 Qt6 REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)

if (SLIDER_LIBRARY MATCHES ON)
if(SLIDER_LIBRARY MATCHES ON)
add_library(${PROJECT_NAME}
include/doubleslider.hpp
include/intslider.hpp
include/valueslider.hpp
src/doubleslider.cpp
src/intslider.cpp
src/valueslider.cpp
)
else ()
include/doubleslider.hpp
include/intslider.hpp
include/valueslider.hpp
src/doubleslider.cpp
src/intslider.cpp
src/valueslider.cpp)
else()
add_executable(${PROJECT_NAME}
include/doubleslider.hpp
include/intslider.hpp
include/valueslider.hpp
src/doubleslider.cpp
src/intslider.cpp
src/valueslider.cpp
src/demo.cpp)
endif ()
include/doubleslider.hpp
include/intslider.hpp
include/valueslider.hpp
src/doubleslider.cpp
src/intslider.cpp
src/valueslider.cpp
src/demo.cpp)
endif()

target_link_libraries(${PROJECT_NAME} PRIVATE
Qt::Core
Qt::Widgets
)
Qt::Core
Qt::Widgets)

target_include_directories(${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_LIST_DIR}
include/
)
PRIVATE
${CMAKE_CURRENT_LIST_DIR}
include/)

install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

0 comments on commit 170b2ee

Please sign in to comment.