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
98 changes: 77 additions & 21 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: CI

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "master" branch
push:
Expand All @@ -15,32 +14,89 @@ on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false

# Set up a matrix to run the following 3 configurations:
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ ubuntu-latest, windows-latest ]
build_type: [ Release ]
c_compiler: [ gcc, clang, cl ]
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

# Runs a single command using the runners shell
- name: Get conan
run: |
python -m pip install conan
conan profile detect
- name: Install GCC
uses: egor-tensin/setup-gcc@v1.3
if: matrix.os == 'ubuntu-latest' && matrix.c_compiler == 'gcc'
with:
version: 13

- name: Install Clang
uses: egor-tensin/setup-clang@v1.4
if: matrix.os == 'ubuntu-latest' && matrix.c_compiler == 'clang'
with:
version: 16

- name: Setup python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: pip
- run: pip install -r requirements.txt

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"

- name: Create default Conan profile
run: conan profile detect

- name: Get dependencies
run: |
mkdir build
cd build
conan install .. --build=missing
run: conan install ${{ github.workspace }} --build=missing --output-folder=build --settings compiler.cppstd=20

- name: Configure CMake
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DBUILD_TESTING=ON
--toolchain=conan_toolchain.cmake
-S ${{ github.workspace }}

- name: Build project
run: |
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON --toolchain=conan_toolchain.cmake
cmake --build . --target all
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --parallel

- name: Run test suite
run: build/tests/cppIni_tests
working-directory: build
run: ctest --build-config ${{ matrix.build_type }}
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ project(cppIni LANGUAGES CXX VERSION 0.0.0)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

option(BUILD_TESTING ON "Build test files")
option(BUILD_SHARED_LIBS ON "Build shared library files")

add_subdirectory(src)

include(CTest)
if(BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
endif()
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
conan >= 2.0.10
18 changes: 13 additions & 5 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
cmake_minimum_required(VERSION 3.24)

include(CTest)

set(TEST_DRIVER_NAME TestDriver)

find_package(doctest REQUIRED)

add_executable(${PROJECT_NAME}_tests constructionTest.cpp)
set(TEST_SOURCES
ConstructionTest.cpp
)

add_executable(${PROJECT_NAME}_tests ${TEST_SOURCES})
target_link_libraries(${PROJECT_NAME}_tests doctest::doctest cppIni)
target_compile_definitions(${PROJECT_NAME}_tests
PUBLIC
Expand All @@ -18,3 +18,11 @@ target_include_directories(${PROJECT_NAME}
${PROJECT_SOURCE_DIR}/include
${DOCTEST_INCLUDE_DIR}
)

find_file(DOCTEST_CMAKE doctest.cmake)
if(NOT DOCTEST_CMAKE)
message(FATAL_ERROR "Could not find doctest.cmake")
else()
include(${DOCTEST_CMAKE})
doctest_discover_tests(${PROJECT_NAME}_tests)
endif()
4 changes: 2 additions & 2 deletions tests/constructionTest.cpp → tests/ConstructionTest.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN

#include <cppIni/cppIni.h>
#include <doctest/doctest.h>
#include <cppIni/cppIni.h>

TEST_CASE("Construction test")
{
CHECK(one() == 1);
CHECK_EQ(one(), 1);
}