Merge pull request #38 from Rookfighter/feature/add-code-coverage #45
This file contains 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
name: CMake | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
format: | |
name: Check Code Format | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check Format | |
run: 'find test/ examples/ include/ -iname "*.h" -o -iname "*.cpp" -print0 | xargs -0 clang-format --dry-run --Werror' | |
coverage: | |
name: Generate Code Coverage | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Install LCOV | |
run: | | |
sudo apt update | |
sudo apt install -y lcov | |
- name: Configure | |
run: cmake -S . -B ${{runner.workspace}}/build -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DGENERATE_COVERAGE=ON -DINICPP_CXX_STANDARD=17 | |
- name: Build | |
run: cmake --build ${{runner.workspace}}/build --config Debug | |
- name: Test | |
run: ctest -C Debug --output-on-failure --test-dir ${{runner.workspace}}/build | |
- name: Generate Coverage | |
run: | | |
lcov --capture --directory ${{runner.workspace}}/build --include '*/inicpp.h' --output-file ${{runner.workspace}}/lcov.info | |
lcov --list ${{runner.workspace}}/lcov.info | |
- name: Codecov | |
uses: codecov/codecov-action@v4 | |
env: | |
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}} | |
with: | |
file: ${{runner.workspace}}/lcov.info | |
verbose: true | |
fail_ci_if_error: true | |
build: | |
name: "${{matrix.config.name}} C++${{matrix.cxx}}" | |
runs-on: ${{matrix.config.os}} | |
strategy: | |
matrix: | |
config: | |
- os: ubuntu-latest | |
name: Ubuntu Debug | |
build_type: Debug | |
- os: ubuntu-latest | |
name: Ubuntu Release | |
build_type: Release | |
- os: windows-latest | |
name: Windows Debug | |
build_type: Debug | |
- os: windows-latest | |
name: Windows Release | |
build_type: Release | |
- os: macos-latest | |
name: Mac OS Debug | |
build_type: Debug | |
- os: macos-latest | |
name: Mac OS Release | |
build_type: Release | |
cxx: | |
- 11 | |
- 17 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Configure | |
run: cmake -S . -B ${{runner.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.config.build_type}} -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON -DINICPP_CXX_STANDARD=${{matrix.cxx}} | |
- name: Build | |
run: cmake --build ${{runner.workspace}}/build --config ${{matrix.config.build_type}} | |
- name: Test | |
run: ctest -C ${{matrix.config.build_type}} --output-on-failure --test-dir ${{runner.workspace}}/build |