-
Notifications
You must be signed in to change notification settings - Fork 0
186 lines (154 loc) · 6.35 KB
/
ci.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# NOTE: This workflow is in the test_cpp_cache repository with full comments
name: Continuous Integration
on:
push:
branches:
- main
- develop
- 'feature/*'
- 'bugfix/*'
- 'release/*'
- 'hotfix/*'
paths-ignore:
- 'docs/**'
- 'LICENSE'
- 'LICENSE.txt'
- 'README.md'
pull_request:
branches:
- main
- develop
paths-ignore:
- 'docs/**'
- 'LICENSE'
- 'LICENSE.txt'
- 'README.md'
env:
BUILD_TYPE: Release
SCCACHE_GHA_ENABLED: "true"
CACHE_VCPKG_LIBRARIES: "fmt catch2"
jobs:
test:
name: ${{ matrix.config.os }} ${{ matrix.config.compiler }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
# Reference: https://github.com/actions/runner-images
- { os: "ubuntu-24.04", compiler: "gcc", cmake_gen: "Ninja Multi-Config", cmake_cxx: "/usr/bin/g++-14", cmake_cxx_launcher: "ccache" }
- { os: "ubuntu-24.04", compiler: "llvm", cmake_gen: Ninja Multi-Config, cmake_cxx: "/usr/lib/llvm-18/bin/clang++", cmake_cxx_launcher: "ccache" }
# project won't compile using g++ on macos-15; can use macos-14 instead
#- { os: "macos-15", compiler: "gcc", cmake_gen: "Ninja Multi-Config", cmake_cxx: "g++-14", cmake_cxx_launcher: "ccache" }
- { os: "macos-14", compiler: "gcc", cmake_gen: "Ninja Multi-Config", cmake_cxx: "g++-14", cmake_cxx_launcher: "ccache" }
- { os: "macos-15", compiler: "llvm", cmake_gen: "Ninja Multi-Config", cmake_cxx: "$(brew --prefix llvm@18)/bin/clang++", cmake_cxx_launcher: "ccache" }
- { os: windows-2022, compiler: "msvc", cmake_gen: "Ninja Multi-Config", cmake_cxx: "cl", cmake_cxx_launcher: "sccache" }
- { os: windows-2022, compiler: "llvm", cmake_gen: "Ninja Multi-Config", cmake_cxx: "clang++", cmake_cxx_launcher: "sccache" }
- { os: windows-2022, compiler: "gcc", cmake_gen: "Ninja Multi-Config", cmake_cxx: "g++", cmake_cxx_launcher: "sccache" }
#- { os: "macos-14", compiler: "llvm", cmake_gen: "Ninja Multi-Config", cmake_cxx: "clang++", cmake_cxx_launcher: "ccache" }
steps:
- uses: actions/checkout@v4
# Reference: https://github.com/hendrikmuhs/ccache-action
- name: Cache (non-Windows)
if: runner.os != 'Windows'
uses: hendrikmuhs/[email protected]
with:
key: ${{ runner.os }}-${{ matrix.config.compiler }}-${{ env.BUILD_TYPE }}
# Reference: https://github.com/Mozilla-Actions/sccache-action
- name: Cache (Windows)
if: runner.os == 'Windows'
uses: mozilla-actions/[email protected]
# Reference: https://github.com/aminya/setup-cpp
- name: Install C++ Tools
uses: aminya/setup-cpp@v1
with:
vcvarsall: ${{ runner.os == 'Windows' && matrix.config.compiler == 'msvc' }}
ninja: true
# Reference: https://cmake.org/cmake/help/latest/manual/cmake.1.html
- name: Configure CMake
run: cmake -B ./build -G "${{matrix.config.cmake_gen}}" -DCMAKE_CXX_COMPILER="${{matrix.config.cmake_cxx}}" -DCMAKE_CXX_COMPILER_LAUNCHER="${{matrix.config.cmake_cxx_launcher}}"
- name: Build
run: cmake --build ./build --config ${{env.BUILD_TYPE}}
# Reference: https://cmake.org/cmake/help/latest/manual/ctest.1.html
- name: Test
working-directory: ./build
run: ctest -C ${{env.BUILD_TYPE}}
vcpkg:
runs-on: ubuntu-24.04
steps:
- name: Generate hash for libraries
id: generate-hash
run: |
HASH=$(echo -n "${{ env.CACHE_VCPKG_LIBRARIES }}" | sha256sum | cut -d' ' -f1)
echo "CACHE_VCPKG_LIBRARIES_HASH=${HASH}" >> $GITHUB_ENV
- name: vcpkg cache
uses: actions/cache@v4
with:
path: |
~/vcpkg
key:
${{ runner.os }}-vcpkg-${{ env.CACHE_VCPKG_LIBRARIES_HASH }}
# Reference: https://github.com/aminya/setup-cpp
- name: Install vcpkg
uses: aminya/setup-cpp@v1
with:
vcpkg: true
- name: Install vcpkg dependencies
run: vcpkg install ${{ env.CACHE_VCPKG_LIBRARIES }}
#run: vcpkg install fmt catch2
# # Taken from doctest github
coverage:
needs: vcpkg
runs-on: ubuntu-24.04
env:
BUILD_TYPE: Debug
steps:
- uses: actions/checkout@v4
- name: vcpkg cache
uses: actions/cache@v4
with:
path: |
~/vcpkg
key: ${{ runner.os }}-vcpkg-${{ env.CACHE_VCPKG_LIBRARIES_HASH }}
- name: Install C++ Tools
run: sudo apt-get install -y ninja-build lcov
- name: Configure CMake
run: cmake -B ./build -G "Ninja Multi-Config" -D CMAKE_CXX_FLAGS="-fprofile-arcs -ftest-coverage" -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake
- name: Build
run: cmake --build ./build --config ${{ env.BUILD_TYPE }}
- name: Test
run: ctest --test-dir ./build --no-tests=error
- name: LCOV
run: |
mkdir coverage
lcov -c -d ./build/ -o coverage/lcov.info --include "*include/caff*"
- name: Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/lcov.info
fail_ci_if_error: true
# Taken from doctest github
clang-tidy:
needs: vcpkg
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-24.04
env:
BUILD_TYPE: Debug
steps:
- uses: actions/checkout@v4
- name: vcpkg cache
uses: actions/cache@v4
with:
path: |
~/vcpkg
key: ${{ runner.os }}-vcpkg-${{ env.CACHE_VCPKG_LIBRARIES_HASH }}
- name: Install Ninja
run: sudo apt-get install -y ninja-build
# -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake
# -warnings-as-errors=*
# ;-header-filter=include/caff/.*
- name: Configure CMake
run: cmake -B ./build -S . -G "Ninja Multi-Config" -D CMAKE_CXX_COMPILER=/usr/lib/llvm-18/bin/clang++ -D CMAKE_EXPORT_COMPILE_COMMANDS=ON -D CMAKE_CXX_CLANG_TIDY="clang-tidy-18;-header-filter=include/caff/.*" -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake
- name: Build
run: cmake --build ./build --config ${{ env.BUILD_TYPE }}