-
Notifications
You must be signed in to change notification settings - Fork 0
388 lines (315 loc) · 10.9 KB
/
Copy pathci.yml
File metadata and controls
388 lines (315 loc) · 10.9 KB
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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
name: CI
on:
push:
branches:
- main
- dev
- release/**
pull_request:
branches:
- main
- dev
- release/**
workflow_dispatch:
permissions:
contents: read
concurrency:
group: rix-auth-ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
VIX_VERSION: v2.6.1
BUILD_JOBS: 2
jobs:
build-test-install:
name: ${{ matrix.os }} / ${{ matrix.build_type }} / tests=${{ matrix.tests }} / examples=${{ matrix.examples }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
build_type: Debug
tests: ON
examples: OFF
- os: ubuntu-24.04
build_type: Release
tests: ON
examples: ON
- os: macos-14
build_type: Release
tests: ON
examples: ON
- os: windows-2022
build_type: Release
tests: ON
examples: OFF
steps:
- name: Checkout rix/auth
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup CMake and Ninja
uses: lukka/get-cmake@latest
- name: Setup MSVC
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
- name: Install Windows dependencies
if: runner.os == 'Windows'
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
choco install pkgconfiglite -y
git clone https://github.com/microsoft/vcpkg "$env:GITHUB_WORKSPACE/vcpkg"
& "$env:GITHUB_WORKSPACE/vcpkg/bootstrap-vcpkg.bat"
& "$env:GITHUB_WORKSPACE/vcpkg/vcpkg.exe" install `
fmt:x64-windows `
spdlog:x64-windows `
nlohmann-json:x64-windows `
openssl:x64-windows `
zlib:x64-windows `
brotli:x64-windows `
sqlite3:x64-windows `
libmysql:x64-windows `
sdl2:x64-windows `
sdl2-image:x64-windows `
gtest:x64-windows
"VCPKG_ROOT=$env:GITHUB_WORKSPACE/vcpkg" | Out-File -FilePath $env:GITHUB_ENV -Append
"CMAKE_TOOLCHAIN_FILE=$env:GITHUB_WORKSPACE/vcpkg/scripts/buildsystems/vcpkg.cmake" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Install Linux dependencies
if: runner.os == 'Linux'
shell: bash
run: |
set -euxo pipefail
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential \
cmake \
ninja-build \
git \
curl \
ca-certificates \
tar \
zip \
unzip \
pkg-config \
libasio-dev \
libssl-dev \
zlib1g-dev \
libbrotli-dev \
libsqlite3-dev \
nlohmann-json3-dev \
libfmt-dev \
libspdlog-dev \
libmysqlcppconn-dev \
libsdl2-dev \
libsdl2-image-dev \
libgl1-mesa-dev \
libgtest-dev
- name: Install macOS dependencies
if: runner.os == 'macOS'
shell: bash
run: |
set -euxo pipefail
brew update
brew install \
cmake \
ninja \
git \
curl \
pkg-config \
openssl@3 \
zlib \
brotli \
sqlite \
nlohmann-json \
spdlog \
fmt \
mysql-client \
sdl2 \
sdl2_image \
googletest
- name: Clean workspace
shell: bash
run: |
set -euxo pipefail
rm -rf \
build \
install \
smoke-rix-auth \
logs
- name: Install Vix SDK Unix
if: runner.os != 'Windows'
shell: bash
run: |
set -euxo pipefail
curl -fsSL https://vixcpp.com/install.sh | VIX_VERSION="${VIX_VERSION}" VIX_INSTALL_KIND=sdk sh
test -f "$HOME/.local/lib/cmake/Vix/VixConfig.cmake"
test -f "$HOME/.local/include/vix.hpp"
echo "VIX_PREFIX=$HOME/.local" >> "$GITHUB_ENV"
- name: Install Vix SDK Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
$vixPrefix = "$env:GITHUB_WORKSPACE/deps/vix-sdk"
$asset = "vix-sdk-windows-x86_64.zip"
$url = "https://github.com/vixcpp/vix/releases/download/$env:VIX_VERSION/$asset"
New-Item -ItemType Directory -Force -Path "$env:GITHUB_WORKSPACE/deps" | Out-Null
Invoke-WebRequest -Uri "$url" -OutFile "$asset"
New-Item -ItemType Directory -Force -Path "$vixPrefix" | Out-Null
Expand-Archive -Path "$asset" -DestinationPath "$vixPrefix" -Force
if (!(Test-Path "$vixPrefix/lib/cmake/Vix/VixConfig.cmake")) {
Write-Host "VixConfig.cmake not found in SDK"
Get-ChildItem -Recurse "$vixPrefix" | Select-Object FullName
exit 1
}
if (!(Test-Path "$vixPrefix/include/vix.hpp")) {
Write-Host "vix.hpp not found in SDK"
Get-ChildItem -Recurse "$vixPrefix" | Select-Object FullName
exit 1
}
"VIX_PREFIX=$vixPrefix" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Show Vix SDK prefix
shell: bash
run: |
set -euxo pipefail
echo "VIX_PREFIX=$VIX_PREFIX"
test -n "$VIX_PREFIX"
test -f "$VIX_PREFIX/lib/cmake/Vix/VixConfig.cmake"
test -f "$VIX_PREFIX/include/vix.hpp"
- name: Configure rix/auth
shell: bash
run: |
set -euxo pipefail
CMAKE_ARGS=(
-S . -B build -G Ninja
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
"-DCMAKE_PREFIX_PATH=$VIX_PREFIX"
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install"
-DRIX_AUTH_BUILD_TESTS=${{ matrix.tests }}
-DRIX_AUTH_BUILD_EXAMPLES=${{ matrix.examples }}
-DRIX_AUTH_INSTALL=ON
-DRIX_AUTH_ENABLE_LOCAL_DEPS=OFF
)
if [ "${{ runner.os }}" = "Windows" ]; then
CMAKE_ARGS+=(
"-DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE"
-DVCPKG_TARGET_TRIPLET=x64-windows
)
fi
cmake "${CMAKE_ARGS[@]}"
- name: Build rix/auth
shell: bash
run: |
set -euxo pipefail
cmake --build build --config ${{ matrix.build_type }} -j"${BUILD_JOBS}"
- name: Run rix/auth tests
if: matrix.tests == 'ON'
shell: bash
run: |
set -euxo pipefail
ctest --test-dir build --build-config ${{ matrix.build_type }} --output-on-failure
- name: Install rix/auth
shell: bash
run: |
set -euxo pipefail
cmake --install build --config ${{ matrix.build_type }}
- name: Validate installed rix/auth package tree
shell: bash
run: |
set -euxo pipefail
test -d install/include/rix/auth
test -f install/lib/cmake/rix_auth/RixAuthConfig.cmake
test -f install/lib/cmake/rix_auth/RixAuthConfigVersion.cmake
test -f install/lib/cmake/rix_auth/RixAuthTargets.cmake
find install/include -maxdepth 5 -type f | sort > installed-rix-auth-headers.txt
find install/lib/cmake -maxdepth 5 -type f | sort > installed-rix-auth-cmake.txt
sed -n '1,120p' installed-rix-auth-headers.txt
cat installed-rix-auth-cmake.txt
- name: Smoke test installed rix/auth package
shell: bash
run: |
set -euxo pipefail
rm -rf smoke-rix-auth
mkdir -p smoke-rix-auth
cat > smoke-rix-auth/CMakeLists.txt <<'CMAKE_EOF'
cmake_minimum_required(VERSION 3.20)
project(rix_auth_consumer LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
find_package(RixAuth CONFIG REQUIRED)
add_executable(app main.cpp)
target_link_libraries(app PRIVATE rix::auth)
CMAKE_EOF
cat > smoke-rix-auth/main.cpp <<'CPP_EOF'
#include <rix/auth/AuthConfig.hpp>
#include <rix/auth/PasswordHasher.hpp>
int main()
{
rixlib::auth::AuthConfig config;
rixlib::auth::PasswordHasher hasher{config};
auto hash = hasher.hash("correct-password");
if (hash.failed())
{
return 1;
}
if (!hasher.verify("correct-password", hash.value()))
{
return 2;
}
return 0;
}
CPP_EOF
SMOKE_ARGS=(
-S smoke-rix-auth -B smoke-rix-auth/build -G Ninja
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
"-DCMAKE_PREFIX_PATH=${{ github.workspace }}/install;$VIX_PREFIX"
)
if [ "${{ runner.os }}" = "Windows" ]; then
SMOKE_ARGS+=(
"-DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE"
-DVCPKG_TARGET_TRIPLET=x64-windows
)
fi
cmake "${SMOKE_ARGS[@]}"
cmake --build smoke-rix-auth/build --config ${{ matrix.build_type }} -j"${BUILD_JOBS}"
if [ "${{ runner.os }}" = "Windows" ]; then
./smoke-rix-auth/build/app.exe
else
./smoke-rix-auth/build/app
fi
- name: Collect logs
if: always()
shell: bash
run: |
set +e
OUT="logs/${{ matrix.os }}-${{ matrix.build_type }}"
mkdir -p "$OUT"
echo "runner.os=${{ runner.os }}" > "$OUT/context.txt"
echo "matrix.os=${{ matrix.os }}" >> "$OUT/context.txt"
echo "matrix.build_type=${{ matrix.build_type }}" >> "$OUT/context.txt"
echo "VIX_PREFIX=${VIX_PREFIX:-}" >> "$OUT/context.txt"
for file in \
build/CMakeCache.txt \
build/CMakeFiles/CMakeOutput.log \
build/CMakeFiles/CMakeError.log \
build/CMakeFiles/CMakeConfigureLog.yaml \
build/Testing/Temporary/LastTest.log \
smoke-rix-auth/build/CMakeCache.txt \
smoke-rix-auth/build/CMakeFiles/CMakeOutput.log \
smoke-rix-auth/build/CMakeFiles/CMakeError.log
do
if [ -f "$file" ]; then
mkdir -p "$OUT/$(dirname "$file")"
cp -f "$file" "$OUT/$file"
fi
done
find "$OUT" -type f | sort || true
- name: Upload logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: rix-auth-logs-${{ matrix.os }}-${{ matrix.build_type }}
path: logs/**/*
if-no-files-found: ignore