-
Notifications
You must be signed in to change notification settings - Fork 38
163 lines (138 loc) · 5.32 KB
/
cpp.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: C++ API
on:
pull_request:
branches: [ main ]
jobs:
build:
name: Build
runs-on: ubuntu-20.04
steps:
- name: Fetch the package's repository
uses: actions/checkout@v4
- name: Setup CMake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.18'
- name: Setup ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ secrets.CCACHE_CACHE_VERSION }}|ubuntu-20.04-gcc-release
create-symlink: true
- name: Configure CMake
working-directory: ${{github.workspace}}
run: cmake -B build -DCMAKE_BUILD_TYPE=Release library/cpp
- name: Build
working-directory: ${{github.workspace}}
run: |
echo "::add-matcher::./.github/problem-matchers/gcc.json"
cmake --build build --parallel --config Release
echo "::remove-matcher owner=problem-matcher-gcc::"
test:
name: Test
needs: build
runs-on: ubuntu-20.04
steps:
- name: Fetch the package's repository
uses: actions/checkout@v4
- name: Setup CMake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.18'
- name: Setup ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ secrets.CCACHE_CACHE_VERSION }}|ubuntu-20.04-gcc-release
create-symlink: true
- name: Setup GTest
run: |
sudo apt-get update
sudo apt-get install -yq --no-install-recommends libgtest-dev
- name: Configure CMake
working-directory: ${{github.workspace}}
run: cmake -B build -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTING=ON library/cpp
- name: Build tests
working-directory: ${{github.workspace}}
run: |
echo "::add-matcher::./.github/problem-matchers/gcc.json"
cmake --build build --parallel --config Release
echo "::remove-matcher owner=problem-matcher-gcc::"
- name: Run tests
working-directory: ${{github.workspace}}
run: |
all_tests_passed=1
for f in `find build/test/src/*/test_* -executable`; do
$f --gtest_color=yes || all_tests_passed=0
done
if [ $all_tests_passed -ne 1 ]; then
echo "Not all tests passed!"
exit 1
fi
clang-tidy:
name: Clang tidy
needs: [ build ]
runs-on: ubuntu-20.04
steps:
- name: Fetch the package's repository
uses: actions/checkout@v4
- name: Setup CMake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.18'
- name: Setup clang-tidy and system deps
run: |
sudo apt-get update
sudo apt-get install -q -y --no-install-recommends clang-tidy
# NOTE: The following deps are installed s.t. clang-tidy correctly treats them as system deps
sudo apt-get install -q -y --no-install-recommends libeigen3-dev libgoogle-glog-dev libboost-dev
- name: Configure CMake
working-directory: ${{github.workspace}}
run: cmake -B build -DCMAKE_BUILD_TYPE=Release library/cpp
- name: Run clang-tidy
working-directory: ${{github.workspace}}/build
run: |
echo "::add-matcher::./.github/problem-matchers/clang-tidy.json"
run-clang-tidy -quiet -header-filter="*include/wavemap/*"
echo "::remove-matcher owner=problem-matcher-clang-tidy::"
valgrind:
name: Valgrind memcheck
needs: test
runs-on: ubuntu-20.04
steps:
- name: Fetch the package's repository
uses: actions/checkout@v4
- name: Setup CMake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.18'
- name: Setup ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ secrets.CCACHE_CACHE_VERSION }}|ubuntu-20.04-gcc-release
create-symlink: true
- name: Setup GTest and Valgrind
run: |
sudo apt-get update
sudo apt-get install -yq --no-install-recommends libgtest-dev valgrind
- name: Configure CMake
working-directory: ${{github.workspace}}
run: cmake -B build -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTING=ON library/cpp
- name: Build tests
working-directory: ${{github.workspace}}
run: |
echo "::add-matcher::./.github/problem-matchers/gcc.json"
cmake --build build --parallel --config Release
echo "::remove-matcher owner=problem-matcher-gcc::"
- name: Check unit tests with Valgrind memcheck
working-directory: ${{github.workspace}}
run: |
all_tests_passed=1
echo "::add-matcher::./.github/problem-matchers/valgrind.json"
for f in `find build/test/src/*/test_* -executable`; do
valgrind --tool=memcheck --leak-check=full --leak-resolution=high --num-callers=20 --track-origins=yes --show-possibly-lost=no --errors-for-leak-kinds=definite,indirect --error-exitcode=1 --xml=yes --xml-file=valgrind-log.xml $f --gtest_color=yes || all_tests_passed=0
grep -Poz '(?<=<error>)(.*\n)*.*(?=</error>)' valgrind-log.xml || true
done
echo "::remove-matcher owner=problem-matcher-valgrind::"
if [ $all_tests_passed -ne 1 ]; then
echo "Not all tests passed!"
exit 1
fi