-
Notifications
You must be signed in to change notification settings - Fork 0
Initialize dmlist as DMOD linked list library #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
28700a8
Initial plan
Copilot 156b3b1
Initialize dmlist library with basic linked list implementation
Copilot 561e4de
Fix null pointer checks in tests
Copilot 974c737
Rename _init to _create and add CI workflow
Copilot b6a5ce8
Add explicit permissions to CI workflow for security
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| 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() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
brakuje CI
There was a problem hiding this comment.
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.