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
35 changes: 35 additions & 0 deletions .github/actions/setup_cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

name: 'setup_cache'
description: 'sets up the shared cache'
inputs:
compiler:
required: true
type: string
build_type:
required: true
type: string
generator:
required: true
type: string
developer_mode:
required: true
type: string


runs:
using: "composite"
steps:
- name: Cache
uses: actions/cache@v2
with:
# You might want to add .ccache to your cache configuration?
path: |
~/.cache/pip
${{ env.HOME }}/.cache/vcpkg/archives
${{ env.XDG_CACHE_HOME }}/vcpkg/archives
${{ env.LOCALAPPDATA }}\vcpkg\archives
${{ env.APPDATA }}\vcpkg\archives
key: ${{ runner.os }}-${{ inputs.compiler }}-${{ inputs.build_type }}-${{ inputs.generator }}-${{ inputs.developer_mode }}-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('./vcpkg.json')}}
restore-keys: |
${{ runner.os }}-${{ inputs.compiler }}-${{ inputs.build_type }}

174 changes: 101 additions & 73 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
name: ci
on:
pull_request:
release:
types: [published]

push:
tags:
branches:
- main
- develop

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
# Conan cache environment variables
CONAN_SYSREQUIRES_MODE: enabled
CONAN_USER_HOME: "${{ github.workspace }}/conan-cache"
CONAN_USER_HOME_SHORT: "${{ github.workspace }}/conan-cache/short"
CLANG_TIDY_VERSION: "15.0.2"
VERBOSE: 1

jobs:
Test:
Expand All @@ -32,116 +33,145 @@ jobs:
- macos-10.15
- windows-2019
compiler:
# you can specify the version after `-` like "llvm-13.0.0".
- llvm
- gcc-8
# you can specify the version after `-` like "llvm-15.0.2".
- llvm-15.0.2
- gcc-11
generator:
- "Ninja Multi-Config"
build_type:
- Release
- Debug
developer_mode:
package_maintainer_mode:
- ON
- OFF
large_tests:
build_shared:
- OFF

exclude:
# mingw is determined by this author to be too buggy to support
- os: windows-2019
compiler: gcc-8
# These have anonalous failures, not sure what is up with no access to a physical Mac.
- os: macos-10.15
compiler: gcc-8
build_type: Debug
developer_mode: ON
compiler: gcc-11

include:
# Add appropriate variables for gcov version required. This will intentionally break
# if you try to use a compiler that does not have gcov set
- compiler: gcc-11
gcov_executable: gcov
enable_ipo: On

- compiler: llvm-15.0.2
enable_ipo: Off
gcov_executable: "llvm-cov gcov"

- os: macos-10.15
compiler: llvm
build_type: Release
developer_mode: ON
enable_ipo: Off
enable_cppcheck: OFF
enable_clang_tidy: OFF

- os: ubuntu-20.04
enable_clang_tidy: On
enable_cppcheck: On


include:
# setup gcov variables for extra compiler versions
- compiler: llvm
gcov: "llvm-cov gcov"
- compiler: gcc-8
gcov: "gcov-8"

# setup preferred package generators
- developer_mode: OFF
build_type: Release
# Set up preferred package generators, for given build configurations
- build_type: Release
package_maintainer_mode: OFF
package_generator: TBZ2


# This exists solely to make sure a non-multiconfig build works
- os: ubuntu-20.04
compiler: gcc
gcov: gcov
compiler: gcc-11
generator: "Unix Makefiles"
build_type: Debug
developer_mode: On
gcov_executable: gcov
package_maintainer_mode: On
enable_ipo: Off
enable_clang_tidy: On
enable_cppcheck: On

- os: windows-2019

# Windows msvc builds
- os: windows-2022
compiler: msvc
generator: "Visual Studio 16 2019"
generator: "Visual Studio 17 2022"
build_type: Debug
developer_mode: On
- os: windows-2019
package_maintainer_mode: On
enable_ipo: On
enable_clang_tidy: Off
enable_cppcheck: Off


- os: windows-2022
compiler: msvc
generator: "Visual Studio 16 2019"
generator: "Visual Studio 17 2022"
build_type: Release
developer_mode: On
- os: windows-2019
package_maintainer_mode: On
enable_ipo: On
enable_clang_tidy: Off
enable_cppcheck: Off


- os: windows-2022
compiler: msvc
generator: "Visual Studio 16 2019"
generator: "Visual Studio 17 2022"
build_type: Debug
developer_mode: Off
- os: windows-2019
package_maintainer_mode: Off
enable_clang_tidy: Off
enable_cppcheck: Off


- os: windows-2022
compiler: msvc
generator: "Visual Studio 16 2019"
generator: "Visual Studio 17 2022"
build_type: Release
developer_mode: Off
package_maintainer_mode: Off
package_generator: ZIP
enable_clang_tidy: Off
enable_cppcheck: Off


- os: windows-2022
compiler: msvc
generator: "Visual Studio 17 2022"
build_type: Release
package_maintainer_mode: On
enable_ipo: On
build_shared: On
enable_clang_tidy: Off
enable_cppcheck: Off



steps:
- name: Check for llvm version mismatches
if: ${{ contains(matrix.compiler, 'llvm') && !contains(matrix.compiler, env.CLANG_TIDY_VERSION) }}
uses: actions/github-script@v3
with:
script: |
core.setFailed('There is a mismatch between configured llvm compiler and clang-tidy version chosen')

- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Cache
uses: actions/cache@v2

- name: Setup Cache
uses: ./.github/actions/setup_cache
with:
path: |
~/vcpkg
./build/vcpkg_installed
${{ env.CONAN_USER_HOME }}
~/.cache/pip
${{ env.HOME }}/.cache/vcpkg/archives
${{ env.XDG_CACHE_HOME }}/vcpkg/archives
${{ env.LOCALAPPDATA }}\vcpkg\archives
${{ env.APPDATA }}\vcpkg\archives
key: ${{ runner.os }}-${{ matrix.compiler }}-${{matrix.build_type}}-${{matrix.generator}}-${{matrix.developer_mode}}-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('./conanfile.txt')}}-${{ hashFiles('./vcpkg.json')}}
restore-keys: |
${{ runner.os }}-${{ matrix.compiler }}-${{matrix.build_type}}-${{matrix.generator}}-${{matrix.developer_mode}}

- run: pip3 install conan cmake ninja
compiler: ${{ matrix.compiler }}
build_type: ${{ matrix.build_type }}
package_maintainer_mode: ${{ matrix.package_maintainer_mode }}
generator: ${{ matrix.generator }}

- name: Setup Cpp
uses: aminya/setup-cpp@v1
with:
compiler: ${{ matrix.compiler }}
vcvarsall: ${{ contains(matrix.os, 'windows' )}}

cmake: false
ninja: false
conan: false
cmake: true
ninja: true
vcpkg: false
ccache: true
clangtidy: true
clangtidy: ${{ env.CLANG_TIDY_VERSION }}


cppcheck: true

Expand All @@ -150,7 +180,7 @@ jobs:

- name: Configure CMake
run: |
cmake -S . -B ./build -G "${{matrix.generator}}" -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -DENABLE_DEVELOPER_MODE:BOOL=${{matrix.developer_mode}} -DENABLE_LARGE_TESTS:BOOL=${{matrix.large_tests}} -DOPT_ENABLE_COVERAGE:BOOL=${{ matrix.build_type == 'Debug' }} -DGIT_SHA:STRING=${{ github.sha }}
cmake -S . -B ./build -G "${{matrix.generator}}" -Djson2cpp_ENABLE_CLANG_TIDY:BOOL=${{ matrix.enable_clang_tidy }} -Djson2cpp_ENABLE_CPPCHECK:BOOL=${{ matrix.enable_cppcheck }} -Djson2cpp_ENABLE_IPO=${{matrix.enable_ipo }} -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -Djson2cpp_PACKAGING_MAINTAINER_MODE:BOOL=${{matrix.package_maintainer_mode}} -Djson2cpp_ENABLE_COVERAGE:BOOL=${{ matrix.build_type == 'Debug' }} -DGIT_SHA:STRING=${{ github.sha }}

- name: Build
# Execute the build. You can specify a specific target with "--target <NAME>"
Expand All @@ -164,19 +194,15 @@ jobs:
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: |
ctest -C ${{matrix.build_type}}
pwd
which gcov
gcov --version
gcovr --version
gcovr -j ${{env.nproc}} --root ../ --print-summary --xml-pretty --xml coverage.xml . --verbose --gcov-executable '${{matrix.gcov}}'
gcovr -j ${{env.nproc}} --delete --root ../ --print-summary --xml-pretty --xml coverage.xml . --gcov-executable '${{ matrix.gcov_executable }}'

- name: Windows - Test and coverage
if: runner.os == 'Windows'
working-directory: ./build
run: |
OpenCppCoverage.exe --export_type cobertura:coverage.xml --cover_children -- ctest -C ${{matrix.build_type}}

- name: Build Package
- name: CPack
if: matrix.package_generator != ''
working-directory: ./build
run: |
Expand All @@ -190,13 +216,15 @@ jobs:
files: |
build/*-*${{ matrix.build_type }}*-*.*


- name: Publish Tagged Release
uses: softprops/action-gh-release@v1
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.package_generator != '' }}
with:
files: |
build/*-*${{ matrix.build_type }}*-*.*


- name: Publish to codecov
uses: codecov/codecov-action@v2
with:
Expand Down
Loading