generated from MaximTiberiu/oop-template
-
Notifications
You must be signed in to change notification settings - Fork 0
299 lines (259 loc) · 9.52 KB
/
cmake.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
name: C++ CI
on:
push:
branches: [ '*' ] # NOTE: replace/update with appropriate branch name(s)
tags: [ '*' ]
pull_request:
types: [closed]
branches: [ '*' ] # NOTE: replace/update with appropriate branch name(s)
workflow_dispatch:
inputs:
build_type:
description: Build type
required: false
default: 'Debug'
type: choice
options:
- Debug
- Release
- RelWithDebInfo
- MinSizeRel
env:
BUILD_TYPE: ${{ inputs.build_type || 'Debug' }}
SRC_EXECUTABLE_NAME: "Password-Keeper-src"
TEST_EXECUTABLE_NAME: "Password-Keeper-Test-Runner"
INPUT_FILENAME: "tastatura.txt"
BIN_DIR: "bin" # update in cmake/Options.cmake:6 if changing name here
BUILD_DIR: "build"
EXT_DIR: "ext"
GEN_DIR: "generated"
DB_NAME: ${{ secrets.DB_NAME }}
DB_USER: ${{ secrets.DB_USER }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
DB_HOST: ${{ secrets.DB_HOST }}
DB_PORT: ${{ secrets.DB_PORT }}
defaults:
run:
# Use a bash shell, so we can use the same syntax for environment variable
# access regardless of the host operating system
# https://github.com/saxbophone/CPP20-Cross-Platform-Template
shell: bash
jobs:
cppcheck:
name: "Cppcheck"
# concurrency:
# group: "Cppcheck"
runs-on: ubuntu-22.04
timeout-minutes: 5
env:
# check https://github.com/danmar/cppcheck/releases for latest version
# NOTE: consider updating this value in scripts/build_cppcheck.sh:4 when changing this value
CPPCHECK_VER: "2.14.2"
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Run cppcheck
uses: ./.github/actions/cppcheck
clang-tidy:
name: "Clang-Tidy"
# concurrency:
# group: "Clang-Tidy"
runs-on: ubuntu-22.04
timeout-minutes: 5
env:
CLANG_VER: 18
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Run clang-tidy
uses: ./.github/actions/clang-tidy
build:
name: ${{ matrix.name }}
# concurrency:
# group: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
timeout-minutes: 15
permissions:
attestations: write
contents: write
id-token: write
env:
CC: ${{ matrix.c }}
CXX: ${{ matrix.cxx }}
VSCMD_SKIP_SENDTELEMETRY: 1
# NOTE: replace with another version if this one does not work
# For more versions, see https://winlibs.com or
# https://github.com/brechtsanders/winlibs_mingw/releases/
MINGW_VER: "13.3.0posix-11.0.1-msvcrt-r1/winlibs-x86_64-posix-seh-gcc-13.3.0-mingw-w64msvcrt-11.0.1-r1.7z"
# Example:
# MINGW_VER: "13.3.0posix-11.0.1-ucrt-r1/winlibs-x86_64-posix-seh-gcc-13.3.0-mingw-w64ucrt-11.0.1-r1.7z"
# MINGW_VER: "14.1.0posix-18.1.7-12.0.0-ucrt-r2/winlibs-x86_64-posix-seh-gcc-14.1.0-mingw-w64ucrt-12.0.0-r2.7z"
# MINGW_VER: "14.1.0posix-18.1.7-12.0.0-msvcrt-r2/winlibs-x86_64-posix-seh-gcc-14.1.0-mingw-w64msvcrt-12.0.0-r2.7z"
strategy:
fail-fast: false
matrix:
include:
# - os: ubuntu-22.04
# c: clang-18
# cxx: clang++-18
# clang_ver: "18"
# clang_ver_full: "18.1.8"
# name: "MSan: Ubuntu 22.04 Clang 18"
# cmake_flags: "-DUSE_MSAN=ON"
# cmake_generator: Ninja
# # This env runs memory sanitizers
# runs_msan: true
- os: ubuntu-22.04
c: gcc-12
cxx: g++-12
name: "ASan: Ubuntu 22.04 GCC 12"
cmake_flags: "-DUSE_ASAN=ON"
cmake_generator: Ninja
# This env runs address sanitizers
runs_asan: true
# this is used to add a suffix to the archive name since we use the same compiler version
asan_name: "-asan"
- os: ubuntu-22.04
c: gcc-12
cxx: g++-12
name: "Valgrind: Ubuntu 22.04 GCC 12"
# cmake_flags:
cmake_generator: Ninja
# This env runs valgrind
runs_valgrind: true
- os: macos-14
c: clang
cxx: clang++
name: "macOS 14 Apple Clang 15"
cmake_flags: "-DUSE_ASAN=OFF"
# cmake_generator:
# This env runs address sanitizers
runs_asan: false
- os: macos-14
c: gcc-13
cxx: g++-13
name: "macOS 14 GCC 13"
# cmake_flags:
# cmake_generator: Ninja
# - os: windows-2022
# c: cl
# cxx: cl
# name: "ASan: Windows 2022 MSVC 19.41"
# cmake_flags: "-DUSE_ASAN=ON"
# # Ninja is not faster on MSVC because... MSVC
# # cmake_generator: "Ninja"
# # cmake_generator: "Ninja Multi-Config"
# # This env runs address sanitizers
# runs_asan: true
- os: windows-2022
c: gcc
cxx: g++
name: "Windows 2022 MinGW GCC 13"
# cmake_flags:
cmake_generator: Ninja
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install PostgreSQL
uses: ./.github/actions/install-postgres
- name: Set timestamp and zip name
run: |
echo "TIMESTAMP=$(date +%Y-%m-%d-%H-%M-%S)" >> ${GITHUB_ENV}
# use the full name as prefix: {user_name}_{repo_name} (replace / with _)
echo "ZIP_NAME=$(echo "${GITHUB_REPOSITORY}_${{ env.BUILD_TYPE }}_${{ matrix.os }}_${{ matrix.cxx }}${{ matrix.asan_name }}" | sed 's|/|_|')" >> ${GITHUB_ENV}
# or use only the repo name (github does not have a predefined environment variable for this)
# the regex splits by / and keeps everything after / without the / character
# echo "ZIP_NAME=$(echo "${GITHUB_REPOSITORY}_${{ env.BUILD_TYPE }}_${{ matrix.os }}_${{ matrix.cxx }}${{ matrix.asan_name }}" | sed -E 's|.+/(.+)|\1|')" >> ${GITHUB_ENV}
- name: Install packages
uses: ./.github/actions/install-packages
- name: Configure CMake
uses: ./.github/actions/configure-cmake
with:
custom_flags: ${{ matrix.cmake_flags }}
warnings_as_errors: 'ON'
- name: Build
run: |
bash ./scripts/cmake.sh build -t ${{ env.BUILD_TYPE }}
- name: Install
# Use CMake to "install" build artifacts (only interested in CMake registered targets) to our custom artifacts directory
run: |
bash ./scripts/cmake.sh install -i artifacts -t ${{ env.BUILD_TYPE }}
- name: Move artifacts
run: |
mkdir ${{ env.ZIP_NAME }}
mv artifacts/${{ env.BIN_DIR }}/* ${{ env.ZIP_NAME }}
ls -la ${{ env.ZIP_NAME }}
- name: Process artifacts
uses: ./.github/actions/process-artifacts
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.ZIP_NAME }}_${{ env.TIMESTAMP }}
path: ${{ env.ZIP_NAME }}
retention-days: 30
- name: Runtime checks
uses: ./.github/actions/runtime-checks
- name: Create release
uses: ./.github/actions/create-release
if: startsWith(github.ref, 'refs/tags/')
test:
name: "Test"
runs-on: ubuntu-latest
needs: build
timeout-minutes: 5
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: pipeline_test_user
POSTGRES_PASSWORD: pipeline_test_password
POSTGRES_DB: pipeline_test_password_keeper
options: >-
--health-cmd "pg_isready -U pipeline_test_user"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
env:
DB_HOST: localhost
DB_NAME: pipeline_test_password_keeper
DB_USER: pipeline_test_user
DB_PASSWORD: pipeline_test_password
DB_PORT: 5432
RUNS_TESTS: 1
steps:
- name: "Checkout code"
uses: actions/checkout@v4
- name: "Set up GCC"
run: sudo apt-get install -y build-essential gcc
- name: "Install dependencies"
run: |
sudo apt-get update
sudo apt-get install -y postgresql
- name: "Install CMake and Ninja"
run: |
sudo apt-get install -y cmake ninja-build
- name: "Build project"
run: |
cmake -S . -B build -G Ninja -DCMAKE_C_COMPILER=gcc-12 -DCMAKE_CXX_COMPILER=g++-12 -DRUN_TESTS=ON -DSKIP_BUILD_TEST=ON
cmake --build build
- name: "Postgres setup"
run: |
export PGPASSWORD=pipeline_test_password
psql -h localhost -U pipeline_test_user -d pipeline_test_password_keeper -c "CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
passwordSalt VARCHAR(150) NOT NULL,
passwordHash VARCHAR(150) NOT NULL
);"
- name: "Run tests"
env:
DB_HOST: ${{ env.DB_HOST }}
DB_NAME: ${{ env.DB_NAME }}
DB_USER: ${{ env.DB_USER }}
DB_PASSWORD: ${{ env.DB_PASSWORD }}
DB_PORT: ${{ env.DB_PORT }}
run: |
cd build
ctest --verbose --no-compress-output