-
Notifications
You must be signed in to change notification settings - Fork 1
232 lines (197 loc) · 6.58 KB
/
cppstd.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# Copyright (C) 2024 Roberto Rossini <[email protected]>
# SPDX-License-Identifier: MIT
name: Test compatibility with newer C++ standards
on:
push:
branches: [main]
paths:
- ".github/workflows/build-conan-deps.yml"
- ".github/workflows/cppstd.yml"
- ".github/workflows/evict-gha-cache.yml"
- "cmake/**"
- "examples/**"
- "src/**"
- "test/scripts/**"
- "test/units/**"
- "CMakeLists.txt"
- "conanfile.py"
pull_request:
paths:
- ".github/workflows/build-conan-deps.yml"
- ".github/workflows/cppstd.yml"
- ".github/workflows/evict-gha-cache.yml"
- "cmake/**"
- "examples/**"
- "src/**"
- "test/scripts/**"
- "test/units/**"
- "CMakeLists.txt"
- "conanfile.py"
# https://stackoverflow.com/a/72408109
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
build-conan-deps-cpp20:
name: Build Conan deps
uses: paulsengroup/hictk/.github/workflows/build-conan-deps.yml@main
with:
os: ubuntu-24.04
cppstd: 20
build-conan-deps-cpp23:
name: Build Conan deps
uses: paulsengroup/hictk/.github/workflows/build-conan-deps.yml@main
with:
os: ubuntu-24.04
cppstd: 23
build-project:
runs-on: ubuntu-latest
name: Build project
needs:
- build-conan-deps-cpp20
- build-conan-deps-cpp23
container:
image: ghcr.io/paulsengroup/ci-docker-images/ubuntu-24.04-cxx-clang-19
options: "--user=root"
outputs:
ccache-old-cache-key: ${{ steps.cache-ccache.outputs.cache-matched-key }}
env:
CCACHE_DIR: "/opt/ccache-cache"
CCACHE_COMPILERCHECK: "content"
CCACHE_COMPRESSLEVEL: "1"
CCACHE_MAXSIZE: "150M"
CONAN_HOME: "/opt/conan/"
strategy:
fail-fast: false
matrix:
cppstd:
- 20
- 23
steps:
- uses: actions/checkout@v4
- name: Fix permissions
run: |
chown -R $(id -u):$(id -g) $PWD
- name: Generate cache key
id: generate-cache-key
run: |
conanfile_hash="${{ hashFiles('conanfile.py') }}"
# This can be used by to always update a cache entry (useful e.g. for ccache)
current_date="$(date '+%s')"
ccache_key_prefix="ccache-cppstd-${{ matrix.cppstd }}-$conanfile_hash"
echo "ccache-key=${ccache_key_prefix}-$GITHUB_REF-${current_date}" | tee -a "$GITHUB_OUTPUT"
echo "ccache-restore-key-1=$ccache_key_prefix-$GITHUB_REF" | tee -a "$GITHUB_OUTPUT"
echo "ccache-restore-key-2=$ccache_key_prefix" | tee -a "$GITHUB_OUTPUT"
- name: Restore Conan cache (C++20)
if: matrix.cppstd == '20'
uses: actions/cache/restore@v4
with:
key: ${{ needs.build-conan-deps-cpp20.outputs.conan-key }}
path: ${{ env.CONAN_HOME }}/p
fail-on-cache-miss: true
- name: Restore CMake configs (C++20)
if: matrix.cppstd == '20'
uses: actions/cache/restore@v4
with:
key: ${{ needs.build-conan-deps-cpp20.outputs.cmake-prefix-debug-key }}
path: /tmp/cmake-prefix-dbg.tar
fail-on-cache-miss: true
- name: Restore Conan cache (C++23)
if: matrix.cppstd == '23'
uses: actions/cache/restore@v4
with:
key: ${{ needs.build-conan-deps-cpp23.outputs.conan-key }}
path: ${{ env.CONAN_HOME }}/p
fail-on-cache-miss: true
- name: Restore CMake configs (C++23)
if: matrix.cppstd == '23'
uses: actions/cache/restore@v4
with:
key: ${{ needs.build-conan-deps-cpp23.outputs.cmake-prefix-debug-key }}
path: /tmp/cmake-prefix-dbg.tar
fail-on-cache-miss: true
- name: Extract CMake configs
run: |
mkdir conan-env
tar -xf /tmp/cmake-prefix-dbg.tar -C conan-env/ --strip-components=1
- name: Install Python headers
run: |
apt-get update
apt-get install -y python3.12-dev
- name: Configure project
run: |
find src test \
-type f \
-name CMakeLists.txt \
-exec sed -i 's/set(CMAKE_CXX_STANDARD 17)/set(CMAKE_CXX_STANDARD ${{ matrix.cppstd }})/' {} +
cmake -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_PREFIX_PATH="$PWD/conan-env" \
-DHICTK_ENABLE_TESTING=ON \
-DHICTK_ENABLE_FUZZY_TESTING=ON \
-DHICTK_BUILD_TOOLS=OFF \
-DHICTK_BUILD_EXAMPLES=ON \
-DHICTK_DOWNLOAD_TEST_DATASET=OFF \
-DHICTK_ENABLE_GIT_VERSION_TRACKING=OFF \
-S . \
-B build
- name: Restore Ccache folder
id: cache-ccache
uses: actions/cache/restore@v4
with:
key: ${{ steps.generate-cache-key.outputs.ccache-restore-key-1 }}
restore-keys: ${{ steps.generate-cache-key.outputs.ccache-restore-key-2 }}
path: ${{ env.CCACHE_DIR }}
- name: Reset Ccache stats
run: ccache --zero-stats
- name: Build project
run: cmake --build build -j $(nproc)
- name: Print Ccache statistics (pre-cleanup)
run: |
ccache --show-stats \
--show-compression \
--verbose
- name: Cleanup Ccache folder
run: |
ccache --evict-older-than=14400s # 4h
ccache --recompress=19 --recompress-threads="$(nproc)"
ccache --cleanup
- name: Print Ccache statistics (post-cleanup)
run: |
ccache --show-stats \
--show-compression \
--verbose
- name: Save Ccache folder
uses: actions/cache/save@v4
with:
key: ${{ steps.generate-cache-key.outputs.ccache-key }}
path: ${{ env.CCACHE_DIR }}
env:
ZSTD_CLEVEL: 1
clean-stale-cache:
needs: [build-project]
uses: paulsengroup/hictk/.github/workflows/evict-gha-cache.yml@main
name: Clean stale Ccache cache
strategy:
fail-fast: false
matrix:
cppstd:
- 20
- 23
permissions:
actions: write
if: needs.build-project.outputs.ccache-old-cache-key != ''
with:
cache-key: "${{ needs.build-project.outputs.ccache-old-cache-key }}"
cppstd-status-check:
name: Status Check (cppstd)
if: ${{ always() }}
runs-on: ubuntu-latest
needs:
- build-project
steps:
- name: Collect job results
if: needs.build-project.result != 'success'
run: exit 1