Skip to content

Commit

Permalink
Finish v0.2.0
Browse files Browse the repository at this point in the history
This release adds an interface for plain C and several quality of life features for the repository such as a code
coverage report for pull requests and a conan recipe that allows us to create a conan package. On top of that, a code
of conduct and contributing guidelines were added.
  • Loading branch information
Master92 committed Nov 14, 2024
2 parents ce308be + caf96a0 commit 2f5bff0
Show file tree
Hide file tree
Showing 21 changed files with 756 additions and 34 deletions.
46 changes: 23 additions & 23 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ on:
push:
branches:
- "master"
- "develop"
pull_request:
branches:
- "master"
- "develop"

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -27,47 +29,47 @@ jobs:
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ ubuntu-latest, windows-latest ]
os: [ ubuntu-24.04, windows-latest ]
build_type: [ Release ]
c_compiler: [ gcc, clang, cl ]
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
- os: ubuntu-latest
- os: ubuntu-24.04
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
- os: ubuntu-24.04
c_compiler: clang
cpp_compiler: clang++
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
- os: ubuntu-24.04
c_compiler: cl

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: 🔧 Install GCC
uses: egor-tensin/[email protected]
if: matrix.os == 'ubuntu-latest' && matrix.c_compiler == 'gcc'
if: matrix.os == 'ubuntu-24.04' && matrix.c_compiler == 'gcc'
with:
version: 13

- name: 🔧 Install Clang
uses: egor-tensin/[email protected]
if: matrix.os == 'ubuntu-latest' && matrix.c_compiler == 'clang'
if: matrix.os == 'ubuntu-24.04' && matrix.c_compiler == 'clang'
with:
version: 16

- name: 🔧 Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: pip
python-version: '3.13'
cache: 'pip'

- name: ☁️ Install required python packages
run: pip install -r requirements.txt
Expand All @@ -76,27 +78,25 @@ jobs:
# 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"
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
if [ "${{ matrix.os }}" == "windows-latest" ]; then
echo "preset-name=conan-default" >> "$GITHUB_OUTPUT"
else
echo "preset-name=conan-release" >> "$GITHUB_OUTPUT"
fi
- name: 🐸 Create default Conan profile
run: conan profile detect

- name: ☁️ Get dependencies
run: conan install ${{ github.workspace }} --build=missing --output-folder=build --settings compiler.cppstd=20
run: conan install ${{ github.workspace }} --build=missing -s compiler.cppstd=20 -o testing=True

- 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 }}
run: cmake --preset ${{ steps.strings.outputs.preset-name }}

- name: 🔨 Build project
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --parallel
run: cmake --build --preset conan-release --parallel

- name: 🏃 Run test suite
working-directory: build
run: ctest --build-config ${{ matrix.build_type }}
run: ctest --preset conan-release
61 changes: 61 additions & 0 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Coverage

on:
# Triggers the workflow on push or pull request events but only for the "master" branch
push:
branches:
- "master"
- "develop"
pull_request:
branches:
- "master"
- "develop"

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: 🔧 Install GCC
uses: egor-tensin/[email protected]
with:
version: 13

- name: 🔧 Setup python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: pip

- name: ☁️ Install required packages
run: |
sudo apt-get install -y lcov
pip install -r requirements.txt
- name: 🐸 Create default Conan profile
run: conan profile detect

- name: ☁️ Get dependencies
run: conan install ${{ github.workspace }} --build=missing -s compiler.cppstd=20 -o testing=True -o coverage=True

- name: 🛠️ Configure CMake
run: cmake --preset conan-release

- name: 🔨 Build project
run: cmake --build --preset conan-release --parallel

- name: 🏃 Run test suite
run: ctest --preset conan-release

- name: 📊 Generate coverage reports with lcov
run: |
lcov --directory . --capture --output-file coverage.info --gcov-tool gcov-13
lcov --remove coverage.info '/usr/*' --remove coverage.info '**/.conan*' --remove coverage.info '**/test*' --remove coverage.info '**/test_package*' --output-file coverage.info
lcov --list coverage.info
- name: ☂️ Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
/*build*
/doc
/include/cppIni/cppini_export.h
test_package/build
python
CMakeUserPresets.json
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
cmake_minimum_required(VERSION 3.24)
project(cppIni LANGUAGES CXX VERSION 0.1.0)
project(cppIni LANGUAGES CXX VERSION 0.2.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")
option(BUILD_TESTING "Build test files" OFF)
option(BUILD_SHARED_LIBS "Build shared library files" ON)
option(CODE_COVERAGE "Enable coverage reporting" OFF)

include(cmake/CodeCoverage.cmake)
add_subdirectory(src)

if(BUILD_TESTING)
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# cppIni - A C++20 library for reading and writing INI files

Branch | Status | Coverage
--- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------| ---
`master` | [![Build](https://github.com/Master92/cppIni/actions/workflows/build.yaml/badge.svg?branch=master)](https://github.com/Master92/cppIni/actions/workflows/build.yaml) | [![codecov](https://codecov.io/gh/Master92/cppIni/branch/master/graph/badge.svg?token=V66BUECAMV)](https://codecov.io/gh/Master92/cppIni)
`develop` | [![Build](https://github.com/Master92/cppIni/actions/workflows/build.yaml/badge.svg?branch=develop)](https://github.com/Master92/cppIni/actions/workflows/build.yaml) | [![codecov](https://codecov.io/gh/Master92/cppIni/branch/develop/graph/badge.svg?token=V66BUECAMV)](https://codecov.io/gh/Master92/cppIni/tree/develop)

[![Release](https://img.shields.io/github/v/tag/Master92/cppIni?label=release)](https://github.com/Master92/cppIni/releases)
[![Build](https://img.shields.io/github/actions/workflow/status/Master92/cppIni/build.yaml?logo=github)](https://github.com/Master92/cppIni/actions/workflows/build.yaml)
![License](https://img.shields.io/github/license/Master92/cppIni)
![GitHub stars](https://img.shields.io/github/stars/Master92/cppIni?label=%E2%AD%90%20Stars)

Expand Down
14 changes: 14 additions & 0 deletions cmake/CodeCoverage.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.24)

# Code coverage configuration
add_library(coverage_config INTERFACE)
if(CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU")
message("Enabling code coverage")
target_compile_options(coverage_config INTERFACE
-O0 # no optimization
-g # generate debug info
--coverage # sets all required flags
)
target_link_options(coverage_config INTERFACE --coverage)
endif()
install(TARGETS coverage_config EXPORT ${PROJECT_NAME}-targets)
105 changes: 105 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# cppIni - A C++20 library for reading and writing INI files
# Copyright (C) 2023-2024 Nils Hofmann <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from conan import ConanFile
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps


class cppiniRecipe(ConanFile):
name = "cppini"
version = "0.2.0"
package_type = "library"

# Optional metadata
license = "GPL-3.0-or-later"
author = "Nils Hofmann <[email protected]>"
url = "https://github.com/Master92/cppIni"
description = "A C++20 library for reading and writing INI files"
topics = ("c++20", "configuration", "ini")

# Binary configuration
settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False],
"fPIC": [True, False],
"testing": [True, False],
"coverage": [True, False]
}
default_options = {
"shared": False,
"fPIC": True,
"testing": True,
"coverage": False
}

# Sources are located in the same place as this recipe, copy them to the recipe
exports_sources = "CMakeLists.txt", "src/*", "include/*", "cmake/*", "tests/*"

def build_requirements(self):
self.build_requires("cmake/[>=3.24]")
if self.options.testing:
self.test_requires("doctest/[>=2.4]")

def config_options(self):
if self.settings.os == "Windows":
self.options.rm_safe("fPIC")

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")

def layout(self):
cmake_layout(self)

def validate(self):
if self.settings.compiler.cppstd:
check_min_cppstd(self, "20")

def generate(self):
deps = CMakeDeps(self)
deps.generate()
tc = CMakeToolchain(self)
tc.variables["BUILD_SHARED_LIBS"] = self.options.shared
tc.variables["BUILD_TESTING"] = self.options.testing
tc.variables["CODE_COVERAGE"] = self.options.coverage
tc.generate()

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
cmake.test()

def package(self):
cmake = CMake(self)
cmake.install()

def package_info(self):
self.cpp_info.libs = ["cppini"]
6 changes: 0 additions & 6 deletions conanfile.txt

This file was deleted.

Loading

0 comments on commit 2f5bff0

Please sign in to comment.