Compare commits

...

23 Commits

Author SHA1 Message Date
0c1b9f085a Update actions/cache action to v4 2024-01-18 10:24:50 +01:00
55468e246a Update actions/cache action to v3.3.3 2024-01-12 11:00:11 +01:00
95661f2991 Update dependency catch2 to v3.5.1 2024-01-01 12:06:41 +01:00
c955c044a5 Update ilammy/msvc-dev-cmd action to v1.13.0 2024-01-01 12:05:27 +01:00
e0d3787aa5 Update dependency catch2 to v3.5.0 2023-12-13 12:22:02 +01:00
460264e842 Update actions/cache action to v3.3.2 2023-09-09 21:13:28 +02:00
a4c4b81764 Update actions/checkout action to v4 2023-09-04 15:58:07 +02:00
02c99649b4 Update sonarsource/sonarcloud-github-c-cpp action to v2 2023-08-12 10:49:13 +02:00
7eeb15195f Update dependency catch2 to v3.4.0 2023-07-14 13:01:42 +02:00
a6b293700b Update actions/cache action to v3.3.1 2023-03-13 18:30:04 +01:00
58ee6db187 Update actions/cache action to v3.3.0 2023-03-10 10:57:44 +01:00
9d249c0cbd Update dependency catch2 to v3.3.2 2023-03-10 10:57:03 +01:00
3961ca7a42 🐛 Fixed CI build 2023-03-10 10:51:09 +01:00
2239878804 Update actions/cache action to v3.2.6 2023-02-21 15:34:18 +01:00
7402a71147 Update renovate.json 2023-02-16 12:30:32 +01:00
2d6b71fabe 👷 Fixed windows CI 2023-02-16 12:29:54 +01:00
c2719797e6 🐛 Fixed missing conan profiles 2023-02-16 12:29:54 +01:00
d4190e7ba5 ⬆️ Updated catch2 to 3.3 2023-02-16 12:29:54 +01:00
e39895cf6f 🔧 Updated sonarscan output 2023-02-16 12:29:54 +01:00
e3753d5d05 Update actions/checkout action to v3 2023-02-16 11:15:51 +01:00
040c52dcfe Add renovate.json 2023-02-16 11:03:32 +01:00
0dc0920b22 🎉 Added test coverage to sonarscan 2022-05-13 10:51:50 +02:00
f508e54ab0 🎉 Added sonarcloud scan 2022-05-12 13:29:13 +02:00
24 changed files with 447 additions and 55 deletions

View File

@ -1,21 +1,106 @@
name: Build & Test
on: [ push, pull_request ]
jobs:
build:
name: Testing on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
steps:
- uses: actions/checkout@v1
name: Build
- name: Configure
run: cmake -DBUILD_TEST=ON .
on: [push, pull_request]
jobs:
build-msvc:
name: Windows
env:
BUILD_TOOLS_PATH: C:\Program Files\Conan\conan
CONAN_USER_HOME_SHORT: None
runs-on: windows-latest
steps:
- run: echo $env:BUILD_TOOLS_PATH | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- uses: actions/checkout@v4
- name: Cache conan
uses: actions/cache@v4.0.0
with:
key: conan-win-${{ hashFiles('conanfile.txt') }}
path: ~/.conan2/
- name: Install dependencies
run: choco install conan ninja -y
- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1.13.0
- name: Build
run: cmake --build .
run: |
conan install . -b missing -pr:b=tools/conan-profiles/vs-22-release-ninja -pr=tools/conan-profiles/vs-22-release-ninja
cmake --preset conan-release -DBUILD_TEST=ON
ninja
- name: Test
run: ctest -C Debug .
run: ctest -j2 --output-on-failure
- name: Clean Conan pkgs
run: conan cache clean "*" -sbd
build-gcc:
name: Linux
env:
CONAN_SYSREQUIRES_MODE: "enabled"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache conan
uses: actions/cache@v4.0.0
with:
key: conan-linux-${{ hashFiles('conanfile.txt') }}
path: ~/.conan2/
- name: Install dependencies
run: |
sudo apt-get update
curl "https://raw.githubusercontent.com/AnotherFoxGuy/ci-scripts/main/install-cmake.sh" | sudo bash
curl "https://raw.githubusercontent.com/AnotherFoxGuy/ci-scripts/main/install-conan2.0.sh" | sudo bash
sudo apt-get -y install ninja-build
- name: Configure
run: |
conan profile detect --force
conan install . -s build_type=Release -b missing -pr:b=default -c tools.cmake.cmaketoolchain:generator="Ninja"
cmake --preset conan-release -DBUILD_TEST=ON
- name: Build
run: |
ninja
- name: Test
run: ctest -j2 --output-on-failure
- name: Clean Conan pkgs
run: conan cache clean "*" -sbd
build-appleclang:
name: MacOS
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Cache conan
uses: actions/cache@v4.0.0
with:
key: conan-mac-${{ hashFiles('conanfile.txt') }}
path: ~/.conan2/
- name: Install dependencies
run: brew install conan ninja
- name: Build
run: |
conan profile detect --force
conan install . -s build_type=Release -b missing -pr:b=default -c tools.cmake.cmaketoolchain:generator="Ninja"
cmake --preset conan-release -DBUILD_TEST=ON
ninja
shell: bash
- name: Test
run: ctest -j2 --output-on-failure
shell: bash
- name: Clean Conan pkgs
run: conan cache clean "*" -sbd

78
.github/workflows/sonarcloud.yml vendored Normal file
View File

@ -0,0 +1,78 @@
name: sonarcloud scan
on:
push:
branches:
- master
- dev
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: sonarcloud scan
runs-on: ubuntu-latest
env:
CONAN_SYSREQUIRES_MODE: "enabled"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install sonar-scanner and build-wrapper
uses: sonarsource/sonarcloud-github-c-cpp@v2
id: sonarscan
- name: Download and set up sonar-scanner
run: |
wget -nv https://cdn.anotherfoxguy.com/sonar-scanner/mofilereader -O run-sonar-scanner
sudo chmod 777 run-sonar-scanner
- name: Prepare cfamily cache timestamp
id: cfamily_cache_timestamp
shell: cmake -P {0}
run: |
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
message("::set-output name=timestamp::${current_date}")
- name: cfamily cache files
uses: actions/cache@v4.0.0
with:
path: cfamily-cache
key: cfamily-cache-${{ steps.cfamily_cache_timestamp.outputs.timestamp }}
restore-keys: |
cfamily-cache-
- name: Cache conan
uses: actions/cache@v4.0.0
with:
key: conan-linux-${{ hashFiles('conanfile.txt') }}
path: ~/.conan2/
- name: Install dependencies
run: |
curl "https://raw.githubusercontent.com/AnotherFoxGuy/ci-scripts/main/install-cmake.sh" | sudo bash
curl "https://raw.githubusercontent.com/AnotherFoxGuy/ci-scripts/main/install-conan2.0.sh" | sudo bash
- name: Configure
run: |
conan profile detect --force
conan install . -s build_type=Release -b missing -pr:b=default
cmake --preset conan-release -DBUILD_TEST=ON -DENABLE_COVERAGE=ON
- name: Run build-wrapper
run: build-wrapper-linux-x86-64 --out-dir bw-output make -j4
- name: Test
continue-on-error: true
run: ctest -j2 --output-on-failure
- name: Generate coverage
run: make gcov
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_SCANNER_EXE: ${{ steps.sonarscan.outputs.sonar-scanner-binary }}
run: ./run-sonar-scanner
- name: Clean Conan pkgs
run: conan cache clean "*" -sbd

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ docs/
build/
_build/
*.html
CMakeUserPresets.json

View File

@ -3,9 +3,10 @@
#-------------------------------------------------------
cmake_minimum_required(VERSION 3.0)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_BINARY_DIR}" "${CMAKE_SOURCE_DIR}/cmake")
include(CMakeCM)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)
project(moFileReader)

131
cmake/CMakeCM.cmake Normal file
View File

@ -0,0 +1,131 @@
macro(_cmcm_set_if_undef varname)
if (NOT DEFINED "${varname}")
set(__default "${ARGN}")
else ()
set(__default "${${varname}}")
endif ()
set("${varname}" "${__default}" CACHE STRING "" FORCE)
endmacro()
# This is the base URL to resolve `LOCAL` modules
_cmcm_set_if_undef(CMCM_LOCAL_RESOLVE_URL "https://AnotherFoxGuy.com/CMakeCM")
# This is the directory where CMakeCM will store its downloaded modules
_cmcm_set_if_undef(CMCM_MODULE_DIR "${CMAKE_BINARY_DIR}/_cmcm-modules")
function(cmcm_module name)
set(options)
set(args REMOTE LOCAL VERSION)
set(list_args ALSO)
cmake_parse_arguments(ARG "${options}" "${args}" "${list_args}" "${ARGV}")
if (NOT ARG_REMOTE AND NOT ARG_LOCAL)
message(FATAL_ERROR "Either LOCAL or REMOTE is required for cmcm_module")
endif ()
if (NOT ARG_VERSION)
message(FATAL_ERROR "Expected a VERSION for cmcm_module")
endif ()
file(MAKE_DIRECTORY "${CMCM_MODULE_DIR}")
file(WRITE "${CMCM_MODULE_DIR}/${name}"
"_cmcm_include_module([[${name}]] [[${ARG_REMOTE}]] [[${ARG_LOCAL}]] [[${ARG_VERSION}]] [[${ARG_ALSO}]])\n"
)
endfunction()
macro(_cmcm_include_module name remote local version also)
set(__module_name "${name}")
set(__remote "${remote}")
set(__local "${local}")
set(__version "${version}")
get_filename_component(__resolved_dir "${CMCM_MODULE_DIR}/resolved" ABSOLUTE)
get_filename_component(__resolved "${__resolved_dir}/${__module_name}" ABSOLUTE)
get_filename_component(__resolved_stamp "${CMCM_MODULE_DIR}/resolved/${__module_name}.whence" ABSOLUTE)
set(__whence_string "${CMCM_LOCAL_RESOLVE_URL}::${__remote}${__local}.${__version}")
set(__download FALSE)
if (EXISTS "${__resolved}")
file(READ "${__resolved_stamp}" __stamp)
if (NOT __stamp STREQUAL __whence_string)
set(__download TRUE)
endif ()
else ()
set(__download TRUE)
endif ()
if (__download)
file(MAKE_DIRECTORY "${__resolved_dir}")
if (__remote)
set(__url "${__remote}")
else ()
set(__url "${CMCM_LOCAL_RESOLVE_URL}/${__local}")
endif ()
message(STATUS "[CMakeCM] Downloading new module ${__module_name}")
file(DOWNLOAD
"${__url}"
"${__resolved}"
STATUS __st
)
list(GET __st 0 __rc)
list(GET __st 1 __msg)
if (__rc)
message(FATAL_ERROR "Error while downloading file from '${__url}' to '${__resolved}' [${__rc}]: ${__msg}")
endif ()
file(WRITE "${__resolved_stamp}" "${__whence_string}")
endif ()
include("${__resolved}")
endmacro()
list(INSERT CMAKE_MODULE_PATH 0 "${CMCM_MODULE_DIR}")
cmcm_module(FindFilesystem.cmake
LOCAL modules/FindFilesystem.cmake
VERSION 1
)
cmcm_module(CMakeRC.cmake
REMOTE https://cdn.statically.io/gh/vector-of-bool/cmrc/a64bea50/CMakeRC.cmake
VERSION 2
)
cmcm_module(FindBikeshed.cmake
LOCAL modules/FindBikeshed.cmake
VERSION 1
)
cmcm_module(cotire.cmake
REMOTE https://cdn.statically.io/gh/sakra/cotire/cotire-1.8.1/CMake/cotire.cmake
VERSION 1.8.1
)
cmcm_module(C++Concepts.cmake
LOCAL modules/C++Concepts.cmake
VERSION 1
)
cmcm_module(codecov.cmake
LOCAL modules/codecov.cmake
VERSION 2
)
cmcm_module(FindGcov.cmake
LOCAL modules/FindGcov.cmake
VERSION 2
)
cmcm_module(FindLcov.cmake
LOCAL modules/FindLcov.cmake
VERSION 2
)
cmcm_module(JSONParser.cmake
LOCAL modules/JSONParser.cmake
VERSION 1
)
cmcm_module(libman.cmake
REMOTE https://cdn.statically.io/gh/vector-of-bool/libman/85c5d23e700a9ed6b428aa78cfa556f60b925477/cmake/libman.cmake
VERSION 1
)
cmcm_module(UseLATEX.cmake
REMOTE https://gitlab.kitware.com/kmorel/UseLATEX/raw/Version2.7.2/UseLATEX.cmake
VERSION 2.7.2
)
cmcm_module(conan.cmake
REMOTE https://cdn.statically.io/gh/conan-io/cmake-conan/0.18.1/conan.cmake
VERSION 0.18.1
)

View File

@ -1,17 +0,0 @@
set(Catch2_FOUND TRUE)
set(CATCH2_VERSION "v2.13.7")
set(CATCH2_INCLUDEDIR "${CMAKE_BINARY_DIR}/catch-${CATCH2_VERSION}")
list(APPEND CMAKE_MODULE_PATH "${CATCH2_INCLUDEDIR}")
if (NOT EXISTS "${CATCH2_INCLUDEDIR}/catch.hpp")
file(MAKE_DIRECTORY "${CATCH2_INCLUDEDIR}")
message(STATUS "Downloading catch.hpp from https://github.com/catchorg/Catch2/")
file(DOWNLOAD "https://github.com/catchorg/Catch2/releases/download/${CATCH2_VERSION}/catch.hpp" "${CATCH2_INCLUDEDIR}/catch.hpp")
file(DOWNLOAD "https://cdn.statically.io/gh/catchorg/Catch2/${CATCH2_VERSION}/contrib/Catch.cmake" "${CATCH2_INCLUDEDIR}/Catch.cmake")
file(DOWNLOAD "https://cdn.statically.io/gh/catchorg/Catch2/${CATCH2_VERSION}/contrib/CatchAddTests.cmake" "${CATCH2_INCLUDEDIR}/CatchAddTests.cmake")
file(DOWNLOAD "https://cdn.statically.io/gh/catchorg/Catch2/${CATCH2_VERSION}/contrib/ParseAndAddCatchTests.cmake" "${CATCH2_INCLUDEDIR}/ParseAndAddCatchTests.cmake")
endif ()
add_library(Catch2::Catch2 INTERFACE IMPORTED)
set_target_properties(Catch2::Catch2 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CATCH2_INCLUDEDIR}")

View File

@ -1,14 +0,0 @@
from conans import ConanFile
class MofilereaderConan(ConanFile):
name = "MofileReader"
version = "1.1.0"
license = "MIT"
url = "https://github.com/AnotherFoxGuy/MofileReader/"
description = "This API lets you read .mo-Files and use their content just as you would do with GNUs gettext."
settings = "os", "compiler", "build_type", "arch"
exports_sources = "include*"
def package(self):
self.copy("*.hpp", "include", "include")

12
conanfile.txt Normal file
View File

@ -0,0 +1,12 @@
[requires]
catch2/3.5.1
[generators]
CMakeDeps
CMakeToolchain
[imports]
bin, *.dll -> bin @ keep_path=False
lib, *.dll -> bin @ keep_path=False
lib, *.dylib -> bin @ keep_path=False
lib, *.so* -> bin @ keep_path=False

9
renovate.json Normal file
View File

@ -0,0 +1,9 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
],
"conan": {
"enabled": true
}
}

16
sonar-project.properties Normal file
View File

@ -0,0 +1,16 @@
sonar.host.url=https://sonarcloud.io
sonar.projectKey=AnotherFoxGuy_MofileReader
sonar.organization=anotherfoxguy-github
# This is the name and version displayed in the SonarCloud UI.
sonar.projectName=MofileReader
sonar.projectVersion=1.2.0
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
sonar.sources=.
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
sonar.cfamily.gcov.reportsPath=test
sonar.cfamily.build-wrapper-output=bw-output

View File

@ -1,13 +1,17 @@
project(moFileReaderTest)
find_package(Catch2 REQUIRED)
include(CTest)
include(Catch)
include(codecov)
add_executable(${PROJECT_NAME} main.cpp test.cpp link_test.cpp)
add_executable(${PROJECT_NAME} test.cpp link_test.cpp)
target_include_directories(moFileReaderTest PRIVATE ${CMAKE_SOURCE_DIR}/include)
target_link_libraries(${PROJECT_NAME} PRIVATE Catch2::Catch2)
target_link_libraries(${PROJECT_NAME} PRIVATE Catch2::Catch2WithMain)
catch_discover_tests(${PROJECT_NAME})
add_coverage(${PROJECT_NAME})
coverage_evaluate()
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD

View File

@ -1,4 +1,4 @@
#include "catch.hpp"
#include <catch2/catch_all.hpp>
#include "moFileReader.hpp"
using namespace moFileLib;

View File

@ -1,2 +0,0 @@
#define CATCH_CONFIG_MAIN
#include "catch.hpp"

View File

@ -1,4 +1,4 @@
#include "catch.hpp"
#include <catch2/catch_all.hpp>
#include "moFileReader.hpp"
using namespace moFileLib;

View File

@ -0,0 +1,8 @@
[settings]
os=Windows
arch=x86_64
compiler=msvc
compiler.version=192
compiler.runtime=dynamic
compiler.runtime_type=Debug
build_type=Debug

View File

@ -0,0 +1,10 @@
[settings]
os=Windows
arch=x86_64
compiler=msvc
compiler.version=192
compiler.runtime=dynamic
compiler.runtime_type=Debug
build_type=Debug
[conf]
tools.cmake.cmaketoolchain:generator=Ninja

View File

@ -0,0 +1,8 @@
[settings]
os=Windows
arch=x86_64
compiler=msvc
compiler.version=192
compiler.runtime=dynamic
compiler.runtime_type=Release
build_type=Release

View File

@ -0,0 +1,10 @@
[settings]
os=Windows
arch=x86_64
compiler=msvc
compiler.version=192
compiler.runtime=dynamic
compiler.runtime_type=Release
build_type=Release
[conf]
tools.cmake.cmaketoolchain:generator=Ninja

View File

@ -0,0 +1,8 @@
[settings]
os=Windows
os_build=Windows
arch=x86_64
arch_build=x86_64
compiler=Visual Studio
compiler.version=16
build_type=RelWithDebInfo

View File

@ -0,0 +1,8 @@
[settings]
os=Windows
arch=x86_64
compiler=msvc
compiler.version=193
compiler.runtime=dynamic
compiler.runtime_type=Debug
build_type=Debug

View File

@ -0,0 +1,10 @@
[settings]
os=Windows
arch=x86_64
compiler=msvc
compiler.version=193
compiler.runtime=dynamic
compiler.runtime_type=Debug
build_type=Debug
[conf]
tools.cmake.cmaketoolchain:generator=Ninja

View File

@ -0,0 +1,8 @@
[settings]
os=Windows
arch=x86_64
compiler=msvc
compiler.version=193
compiler.runtime=dynamic
compiler.runtime_type=Release
build_type=Release

View File

@ -0,0 +1,10 @@
[settings]
os=Windows
arch=x86_64
compiler=msvc
compiler.version=193
compiler.runtime=dynamic
compiler.runtime_type=Release
build_type=Release
[conf]
tools.cmake.cmaketoolchain:generator=Ninja

View File

@ -0,0 +1,8 @@
[settings]
os=Windows
arch=x86_64
compiler=msvc
compiler.version=193
compiler.runtime=dynamic
compiler.runtime_type=RelWithDebInfo
build_type=RelWithDebInfo