-
Notifications
You must be signed in to change notification settings - Fork 2.1k
143 lines (124 loc) · 4.79 KB
/
linux.yml
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: Linux
on: [push, pull_request]
jobs:
build-linux:
defaults:
run:
shell: bash
name: GCC-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}
runs-on: ubuntu-22.04
strategy:
fail-fast: true
matrix:
build_type: [Release, Debug]
lib: [shared, static]
std: [14, 17, 20]
steps:
- uses: actions/checkout@v3
- name: Setup Dependencies
run: |
sudo apt-get update
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \
build-essential \
cmake \
lcov \
libgflags-dev \
libunwind-dev \
ninja-build
- name: Cache GTest
id: cache-gtest
uses: actions/cache@v3
with:
path: gtest/
key: ${{runner.os}}-gtest-1.11
- name: Download GTest
if: steps.cache-gtest.outputs.cache-hit != 'true'
run: |
wget https://github.com/google/googletest/archive/refs/tags/release-1.11.0.tar.gz
tar xvf release-1.11.0.tar.gz
- name: Build GTest
if: steps.cache-gtest.outputs.cache-hit != 'true'
run: |
cmake -S googletest-release-1.11.0 -B build-googletest \
-DBUILD_SHARED_LIBS=${{matrix.shared}} \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/gtest \
-G Ninja
cmake --build build-googletest --target install
- name: Setup Environment
if: matrix.build_type == 'Debug'
run: |
echo 'CXXFLAGS=--coverage' >> $GITHUB_ENV
echo 'GTest_ROOT=${{github.workspace}}/gtest' >> $GITHUB_ENV
- name: Configure
env:
CXXFLAGS: -Wall -Wextra -Wsign-conversion -Wtautological-compare -Wformat-nonliteral -Wundef -Werror ${{env.CXXFLAGS}}
run: |
cmake -S . -B build_${{matrix.build_type}} \
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install \
-G Ninja \
-Werror
- name: Build
run: |
cmake --build build_${{matrix.build_type}} \
--config ${{matrix.build_type}}
- name: Install
run: |
cmake --build build_${{matrix.build_type}} \
--config ${{matrix.build_type}} \
--target install
cmake build_${{matrix.build_type}} \
-DCMAKE_INSTALL_INCLUDEDIR=${{runner.workspace}}/foo/include \
-DCMAKE_INSTALL_LIBDIR=${{runner.workspace}}/foo/lib \
-DCMAKE_INSTALL_DATAROOTDIR=${{runner.workspace}}/foo/share
cmake --build build_${{matrix.build_type}} \
--config ${{matrix.build_type}} \
--target install
- name: Test CMake Package (relative GNUInstallDirs)
run: |
cmake -S src/package_config_unittest/working_config \
-B build_${{matrix.build_type}}_package \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_PREFIX_PATH=${{github.workspace}}/install \
-G Ninja
cmake --build build_${{matrix.build_type}}_package \
--config ${{matrix.build_type}}
- name: Test CMake Package (absolute GNUInstallDirs)
run: |
cmake -S src/package_config_unittest/working_config \
-B build_${{matrix.build_type}}_package_foo \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_PREFIX_PATH=${{runner.workspace}}/foo \
-G Ninja
cmake --build build_${{matrix.build_type}}_package_foo \
--config ${{matrix.build_type}}
- name: Test
run: |
ctest --test-dir build_${{matrix.build_type}} -j$(nproc) --output-on-failure
- name: Generate Coverage
if: matrix.build_type == 'Debug'
run: |
lcov --directory . --capture --output-file coverage.info
lcov --remove coverage.info \
'${{github.workspace}}/gtest/*' \
'*/src/*_unittest.cc' \
'*/src/googletest.h' \
'*/src/mock-log.h' \
'/usr/*' \
--output-file coverage.info
for file in src/glog/*.h.in; do
name=$(basename ${file})
name_we=${name%.h.in}
sed -i "s|build_${{matrix.build_type}}/glog/${name_we}.h\$|${file}|g" coverage.info
done
lcov --list coverage.info
- name: Upload Coverage to Codecov
if: matrix.build_type == 'Debug'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true