-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (86 loc) · 3.05 KB
/
build_cmake.yml
File metadata and controls
101 lines (86 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: CMake
on:
pull_request:
push:
branches:
- main
- master
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: RelWithDebInfo
# Conan cache environment variables
CONAN_SYSREQUIRES_MODE: enabled
CONAN_USER_HOME: "${{ github.workspace }}/conan-cache"
CONAN_USER_HOME_SHORT: "${{ github.workspace }}/conan-cache/short"
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
defaults:
run:
shell: bash
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
include:
- os: ubuntu-latest
ENABLE_COVERAGE: ON
- os: windows-latest
# Windows works differently
ENABLE_COVERAGE: OFF
- os: macos-latest
ENABLE_COVERAGE: ON
steps:
- uses: actions/checkout@v2
- name: Cache
uses: actions/cache@v2
env:
cache-name: cache-conan-modules
with:
path: |
${{ env.CONAN_USER_HOME }}
~/.cache/pip
key: ${{ runner.os }}-${{ env.BUILD_TYPE }}-${{ hashFiles('CMakeLists.txt') }}-${{ hashFiles('cmake/Conan.cmake') }}
- name: Install conan
run: |
pip3 install wheel setuptools gcovr
pip3 install conan --upgrade
- name: Install / Configure dependencies
shell: bash
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
echo "Ubuntu - Fix Conan Path"
sudo update-alternatives --install /usr/bin/conan conan /home/runner/.local/bin/conan 10
sudo update-alternatives --config conan
elif [ "$RUNNER_OS" == "Windows" ]; then
echo "Using chocolatey to install OpenCppCoverage"
choco install opencppcoverage
# Add to Path
echo "C:/Program Files/OpenCppCoverage" >> $GITHUB_PATH
fi;
- name: Configure CMake
run: |
cmake -S . -B ./build -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE -DENABLE_COVERAGE:BOOL=${{ matrix.ENABLE_COVERAGE }}
- name: Build
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build ./build --config $BUILD_TYPE
- name: Unix - Test and coverage
if: runner.os != 'Windows'
working-directory: ./build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: |
ctest -C $BUILD_TYPE
gcovr -j $(nproc) --delete --root ../ --print-summary --xml-pretty --xml coverage.xml .
- name: Windows - Test and coverage
if: runner.os == 'Windows'
working-directory: ./build
run: |
OpenCppCoverage.exe --sources cpp_starter_project --export_type cobertura:coverage.xml --cover_children -- ctest -C $BUILD_TYPE
- name: Publish to codecov
uses: codecov/codecov-action@v2
with:
flags: ${{ runner.os }}
name: ${{ runner.os }}-coverage
files: ./build/coverage.xml