Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: CI

on:
push:
branches: [ main, develop, copilot/*, feature/* ]
pull_request:
branches: [ main, develop, feature/* ]

jobs:
build-and-test:
runs-on: ubuntu-latest
permissions:
contents: read
container:
image: chocotechnologies/dmod:1.0.2

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install dependencies
run: |
apt-get update
apt-get install -y lcov

- name: Configure CMake
run: |
mkdir -p build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DDMLIST_BUILD_TESTS=ON

- name: Build
run: |
cd build
make -j$(nproc)

- name: Run tests
run: |
cd build
ctest --output-on-failure --verbose

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: build/Testing/
retention-days: 30

coverage:
runs-on: ubuntu-latest
permissions:
contents: read
container:
image: chocotechnologies/dmod:1.0.2
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install dependencies
run: |
apt-get update
apt-get install -y lcov

- name: Configure CMake with coverage
run: |
mkdir -p build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON -DDMLIST_BUILD_TESTS=ON

- name: Build with coverage
run: |
cd build
make -j$(nproc)

- name: Run tests
run: |
cd build
ctest --output-on-failure

- name: Generate coverage report
run: |
cd build
lcov --directory . --capture --output-file coverage.info
lcov --remove coverage.info '/usr/*' '*/build/_deps/*' --output-file coverage_filtered.info --ignore-errors unused
lcov --list coverage_filtered.info

- name: Generate HTML coverage report
run: |
cd build
mkdir -p coverage_html
genhtml coverage_filtered.info --output-directory coverage_html

- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: build/coverage_html/
retention-days: 30

- name: Coverage summary
run: |
cd build
echo "## Coverage Summary" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
lcov --summary coverage_filtered.info 2>&1 | tee -a $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
103 changes: 103 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# =====================================================================
# DMOD Linked List Library
# =====================================================================
cmake_minimum_required(VERSION 3.10)

# ======================================================================
# DMOD List
# ======================================================================
project(dmlist
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

brakuje CI

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added CI workflow with build-and-test and coverage jobs in commit 974c737.

VERSION 1.0
DESCRIPTION "DMOD Linked List Library"
LANGUAGES C CXX)

# ======================================================================
# Coverage Configuration
# ======================================================================
option(ENABLE_COVERAGE "Enable code coverage" OFF)

if(ENABLE_COVERAGE)
if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
message(STATUS "Code coverage enabled")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage -fprofile-arcs -ftest-coverage")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
else()
message(WARNING "Code coverage is only supported with GCC or Clang")
set(ENABLE_COVERAGE OFF)
endif()
endif()

# ======================================================================
# Fetch DMOD repository
# ======================================================================
include(FetchContent)

# Only fetch and build dmod if it's not already available as a target
if(NOT TARGET dmod_inc)
# ======================================================================
# DMOD Configuration
# ======================================================================
set(DMOD_MODE "DMOD_SYSTEM" CACHE STRING "DMOD build mode" FORCE)
set(DMOD_BUILD_TESTS OFF CACHE BOOL "Build tests" FORCE)
set(DMOD_BUILD_EXAMPLES OFF CACHE BOOL "Build examples" FORCE)
set(DMOD_BUILD_TOOLS OFF CACHE BOOL "Build tools" FORCE)
set(DMOD_BUILD_TEMPLATES OFF CACHE BOOL "Build templates" FORCE)

FetchContent_Declare(
dmod
GIT_REPOSITORY https://github.com/choco-technologies/dmod.git
GIT_TAG develop
)

# Pass coverage flags to DMOD if enabled - set before FetchContent_MakeAvailable
if(ENABLE_COVERAGE)
set(DMOD_ENABLE_COVERAGE ON CACHE BOOL "Enable DMOD coverage")
# Ensure DMOD uses the same coverage flags
set(CMAKE_C_FLAGS_INIT "${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS}")
endif()

FetchContent_MakeAvailable(dmod)
set(DMOD_DIR ${dmod_SOURCE_DIR} CACHE PATH "DMOD source directory" FORCE)
else()
message(STATUS "dmod target already exists, skipping FetchContent")
endif()

include(${DMOD_DIR}/paths.cmake)

# ======================================================================
# DMOD List Library
# ======================================================================
set(MODULE_NAME dmlist)
add_library(${MODULE_NAME} STATIC
src/dmlist.c
)

target_compile_definitions(${MODULE_NAME}
PRIVATE
DMLIST_VERSION_STRING="== dmlist ver. ${PROJECT_VERSION} ==\\n"
)

target_include_directories(${MODULE_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
)

target_link_libraries(${MODULE_NAME}
PUBLIC
dmod_inc
)

create_library_makefile(${MODULE_NAME})

# ======================================================================
# Tests
# ======================================================================
option(DMLIST_BUILD_TESTS "Build tests" OFF)

if(DMLIST_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# ##############################################################################
# Makefile for the dmlist module
#
# This Makefile is used to build the dmlist module library
#
# DONT EDIT THIS FILE - it is automatically generated.
# Edit the scripts/Makefile-lib.in file instead.
#
# ##############################################################################
ifeq ($(DMOD_DIR),)
DMOD_DIR = _codeql_build_dir/_deps/dmod-src
endif

#
# Name of the module
#
DMOD_LIB_NAME=libdmlist.a
DMOD_SOURCES=src/dmlist.c
DMOD_INC_DIRS = include\
$(DMOD_DIR)/inc\
_codeql_build_dir/_deps/dmod-build
DMOD_LIBS = dmod_inc
DMOD_GEN_HEADERS_IN =
DMOD_DEFINITIONS = DMLIST_VERSION_STRING="== dmlist ver. 1.0 ==\n"

# -----------------------------------------------------------------------------
# Initialization of paths
# -----------------------------------------------------------------------------
include $(DMOD_DIR)/paths.mk

# -----------------------------------------------------------------------------
# Including the template for the library
# -----------------------------------------------------------------------------
DMOD_LIB_OBJS_DIR = $(DMOD_OBJS_DIR)/dmlist
include $(DMOD_SLIB_FILE_PATH)
Loading