-
Notifications
You must be signed in to change notification settings - Fork 3
333 lines (303 loc) · 11.7 KB
/
build-and-test.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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
name: Build and Test
on:
- push
env:
CCACHE_VERSION: 4.8
BUILD_TYPE: Release
jobs:
build-and-test:
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Windows-MSVC",
os: windows-latest,
cc: "cl",
cxx: "cl",
}
- {
name: "Ubuntu-GCC",
os: ubuntu-latest,
cc: "gcc",
cxx: "g++"
}
- {
name: "Ubuntu-Clang",
os: ubuntu-latest,
cc: "clang",
cxx: "clang++"
}
- {
name: "macOS-Clang",
os: macos-latest,
cc: "clang",
cxx: "clang++"
}
steps:
- name: Checkout
uses: actions/checkout@v3.5.2
- name: Setup VS env
uses: egor-tensin/vs-shell@v2
if: startsWith(runner.os, 'Windows')
with:
arch: x64
# Work around https://github.com/actions/runner-images/issues/8659
- name: "Remove GCC 13 from runner image (workaround)"
shell: bash
if: startsWith(runner.os, 'Linux')
run: |
sudo rm -f /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-jammy.list
sudo apt-get update
sudo apt-get install -y --allow-downgrades libc6=2.35-0ubuntu3.4 libc6-dev=2.35-0ubuntu3.4 libstdc++6=12.3.0-1ubuntu1~22.04 libgcc-s1=12.3.0-1ubuntu1~22.04
- name: Setup Ninja
uses: ashutoshvarma/setup-ninja@master
with:
version: 1.11.1
- name: Check for AVX2/512
shell: bash
id: check_cpu
continue-on-error: true
run: |
runner_os=${{ runner.os }}
set +e
case ${runner_os} in
macOS)
sysctl hw.model
sysctl kern.version
sysctl machdep.cpu.leaf7_features > leaf7_features.txt
cat leaf_features.txt
grep -q -E '\s+AVX2\s+' leaf7_features.txt
[[ $? == 0 ]] && has_avx2=1 || has_avx2=0
grep -q -E '\s+AVX512\s+' leaf7_features.txt
[[ $? == 0 ]] && has_avx512=1 || has_avx512=0
;;
Linux)
lscpu
grep -q -E '^flags\s*:.*\bavx2\b' /proc/cpuinfo
[[ $? == 0 ]] && has_avx2=1 || has_avx2=0
grep -q -E '^flags\s*:.*\bavx512f\b' /proc/cpuinfo
[[ $? == 0 ]] && has_avx512=1 || has_avx512=0
;;
Windows)
aria2c "https://download.sysinternals.com/files/Coreinfo.zip" -o CoreInfo.zip
unzip CoreInfo.zip
rm CoreInfo.zip
./CoreInfo64.exe -accepteula -f | iconv -t utf-8 > coreinfo.txt
cat coreinfo.txt
grep -q -E '^AVX2\s+\*' coreinfo.txt
[[ $? == 0 ]] && has_avx2=1 || has_avx2=0
grep -q -E '^AVX-512-F\s+\*' coreinfo.txt
[[ $? == 0 ]] && has_avx512=1 || has_avx512=0
;;
esac
echo "has_avx2=${has_avx2}" >> $GITHUB_OUTPUT
echo "has_avx512=${has_avx512}" >> $GITHUB_OUTPUT
#- name: show cpu support
# run: |
# echo avx2=${{ steps.check_cpu.outputs.has_avx2 }}
# echo avx512=${{ steps.check_cpu.outputs.has_avx512 }}
- name: Download ccache
id: ccache
shell: bash
run: |
runner_os=${{ runner.os }}
case ${runner_os} in
macOS)
aria2c https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}-darwin.tar.gz -o ccache.tar.gz
tar xf ccache.tar.gz --strip-components=1 ccache-${CCACHE_VERSION}-darwin/ccache
rm ccache.tar.gz
;;
Linux)
aria2c https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}-linux-x86_64.tar.xz -o ccache.tar.xz
tar xf ccache.tar.xz --strip-components=1 ccache-${CCACHE_VERSION}-linux-x86_64/ccache
rm ccache.tar.xz
;;
Windows)
aria2c https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}-windows-x86_64.zip -o ccache.zip
unzip -j ccache.zip ccache-${CCACHE_VERSION}-windows-x86_64/ccache.exe
rm ccache.zip
;;
esac
- name: Prepare ccache timestamp
id: ccache_timestamp
shell: bash
run: |
echo "timestamp=$(date -u '+%Y-%m-%d-%H;%M;%S')" > $GITHUB_OUTPUT
- name: ccache cache files
uses: actions/cache@v3.3.1
with:
path: |
.ccache
.cpm
key: ${{ matrix.config.name }}-ccache-${{ steps.ccache_timestamp.outputs.timestamp }}
restore-keys: |
${{ matrix.config.name }}-ccache-
- name: Configure
shell: bash
run: |
export CC=${{ matrix.config.cc }} CXX=${{ matrix.config.cxx }}
export PATH="${GITHUB_WORKSPACE}:$PATH"
export CPM_SOURCE_CACHE="${GITHUB_WORKSPACE}/.cpm"
cmake -S . -B build -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DVXSORT_CCACHE=ON -G Ninja
- name: Build
shell: bash
run: |
export NINJA_STATUS="[%f/%t %o/sec]"
export PATH="${GITHUB_WORKSPACE}:$PATH"
export CCACHE_BASEDIR="${GITHUB_WORKSPACE}" CCACHE_DIR="${GITHUB_WORKSPACE}/.ccache" CCACHE_COMPRESS="true" CCACHE_COMPRESSLEVEL="6" CCACHE_MAXSIZE="600M" CCACHE_COMPILERCHECK="content"
export CPM_SOURCE_CACHE="${GITHUB_WORKSPACE}/.cpm"
ccache -p
ccache -z
cmake --build build
ccache -s
- name: Upload .ccache to cache
uses: actions/cache/save@v3
if: always()
with:
path: |
.ccache
.cpm
key: ${{ matrix.config.name }}-ccache-${{ steps.ccache_timestamp.outputs.timestamp }}
- name: Run tests
shell: bash
working-directory: build
if: steps.check_cpu.outputs.has_avx2 == 1 || steps.check_cpu.outputs.has_avx512 == 1
run: |
export GTEST_OUTPUT="xml:junit/"
set +e
ctest -J $(nproc)
rc=$?
echo ctest returned $?
if [[ $? != 0 ]]; then
echo Error log:
echo ==========
cat ./Testing/Temporary/LastTest.log
fi
- name: Test Report
uses: dorny/test-reporter@v1
if: steps.check_cpu.outputs.has_avx2 == 1 || steps.check_cpu.outputs.has_avx512 == 1
env:
NODE_OPTIONS: --max-old-space-size=4096
with:
name: tests/${{ matrix.config.name}}
path: build/tests/junit/*.xml
reporter: java-junit
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v3
with:
name: tests-${{ matrix.config.name}}
path: build/tests/junit/*.xml
publish-test-results:
name: "Publish Tests Results"
needs: build-and-test
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
contents: read
issues: read
if: always()
steps:
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
id: test
with:
files: "artifacts/**/*.xml"
- name: Set badge properties
id: badgeprops
shell: bash
run: |
conclusion="${{ fromJSON( steps.test.outputs.json ).conclusion }}"
num_suites="${{ fromJSON( steps.test.outputs.json ).stats.suites }}"
num_tests="${{ fromJSON( steps.test.outputs.json ).stats.tests }}"
num_runs="${{ fromJSON( steps.test.outputs.json ).stats.runs }}"
num_tests_skip="${{ fromJSON( steps.test.outputs.json ).stats.tests_skip }}"
num_runs_skip="${{ fromJSON( steps.test.outputs.json ).stats.runs_skip }}"
runs_error="${{ fromJSON( steps.test.outputs.json ).stats.runs_error }}"
runs_fail="${{ fromJSON( steps.test.outputs.json ).stats.runs_fail }}"
tests_fail="${{ fromJSON( steps.test.outputs.json ).stats.tests_fail }}"
tests_error="${{ fromJSON( steps.test.outputs.json ).stats.tests_error }}"
case "${conclusion}" in
success)
color="31c653"
conclusion_suite_text="${conclusion}"
conclusion_test_text="${conclusion}"
conclusion_run_text="${conclusion}"
;;
failure)
color="800000"
conclusion_suite_text="${conclusion}"
conclusion_test_text="${conclusion} (${tests_error})"
conclusion_run_text="${conclusion} (${runs_error})"
;;
neutral)
color="696969"
conclusion_suite_text="${conclusion}"
conclusion_test_text="${conclusion}"
conclusion_run_text="${conclusion}"
;;
esac
cat << EOF >> $GITHUB_OUTPUT
color=${color}
suites_badge_text=${num_suites}: ${conclusion_suite_text}
tests_badge_text=$(printf "%'d" ${num_tests}) ($(printf "%'d" ${num_tests_skip}) skipped): ${conclusion_test_text}
runs_badge_text=$(printf "%'d" ${num_runs}) ($(printf "%'d" ${num_runs_skip}) skipped): ${conclusion_run_text}
EOF
- name: Create suites badge
uses: emibcn/badge-action@d6f51ff11b5c3382b3b88689ae2d6db22d9737d1
with:
label: Suites
status: '${{ steps.badgeprops.outputs.suites_badge_text }}'
color: ${{ steps.badgeprops.outputs.color }}
path: vxsort-suites-badge.svg
- name: Create tests badge
uses: emibcn/badge-action@d6f51ff11b5c3382b3b88689ae2d6db22d9737d1
with:
label: Tests
status: '${{ steps.badgeprops.outputs.tests_badge_text }}'
color: ${{ steps.badgeprops.outputs.color }}
path: vxsort-tests-badge.svg
- name: Create runs badge
uses: emibcn/badge-action@d6f51ff11b5c3382b3b88689ae2d6db22d9737d1
with:
label: Executions
status: '${{ steps.badgeprops.outputs.runs_badge_text }}'
color: ${{ steps.badgeprops.outputs.color }}
path: vxsort-runs-badge.svg
- name: Upload suites badge to Gist
# Upload only for master branch
if: >
github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'master' ||
github.event_name != 'workflow_run' && github.ref == 'refs/heads/master'
uses: andymckay/append-gist-action@1fbfbbce708a39bd45846f0955ed5521f2099c6d
with:
token: ${{ secrets.GIST_TOKEN }}
gistURL: https://gist.githubusercontent.com/damageboy/dfd9d01f2c710f96b444532b92539321
file: vxsort-suites-badge.svg
- name: Upload tests badge to Gist
# Upload only for master branch
if: >
github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'master' ||
github.event_name != 'workflow_run' && github.ref == 'refs/heads/master'
uses: andymckay/append-gist-action@1fbfbbce708a39bd45846f0955ed5521f2099c6d
with:
token: ${{ secrets.GIST_TOKEN }}
gistURL: https://gist.githubusercontent.com/damageboy/dfd9d01f2c710f96b444532b92539321
file: vxsort-tests-badge.svg
- name: Upload runs badge to Gist
# Upload only for master branch
if: >
github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'master' ||
github.event_name != 'workflow_run' && github.ref == 'refs/heads/master'
uses: andymckay/append-gist-action@1fbfbbce708a39bd45846f0955ed5521f2099c6d
with:
token: ${{ secrets.GIST_TOKEN }}
gistURL: https://gist.githubusercontent.com/damageboy/dfd9d01f2c710f96b444532b92539321
file: vxsort-runs-badge.svg