-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
218 lines (193 loc) · 5.92 KB
/
.gitlab-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
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
---
workflow:
name: "Build and test BuildCache"
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_TAG && $CI_COMMIT_TAG =~ /^v[0-9]+.*/
variables:
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/releases/${CI_COMMIT_TAG}"
PACKAGE_FILE_LINUX: "buildcache-linux.tar.gz"
PACKAGE_FILE_WINDOWS: "buildcache-windows.zip"
PACKAGE_FILE_MACOS: "buildcache-macos.zip"
stages:
- build
- upload
- release
- doxygen
build_linux:
stage: build
image: ubuntu:20.04
variables:
CTEST_OUTPUT_ON_FAILURE: "ON"
before_script:
- apt-get update
- |
DEBIAN_FRONTEND=noninteractive apt-get install -y \
build-essential \
clang-format \
clang-tidy \
cmake \
g++ \
git \
ninja-build
script:
# Prepare build.
- mkdir -p build
- cd build
- cmake -S ../src -B . -DCMAKE_BUILD_TYPE=Release -G Ninja -DDISABLE_SSL=on
# Build.
- cmake --build .
# Run unit tests.
- ctest -j 3
# Run system tests.
- ../test_scripts/run_file_lock_stresstest.sh
- ../test_scripts/build_with_buildcache.sh
# Run static checks
- cd ..
- test_scripts/run_linters.py -p build
# Install & package.
- cmake --install build --prefix buildcache --strip
- tar -cv -I "gzip -9" -f ${PACKAGE_FILE_LINUX} buildcache
artifacts:
expose_as: 'BuildCache Linux'
name: 'buildcache-linux'
paths:
- ${PACKAGE_FILE_LINUX}
build_windows:
stage: build
tags:
- saas-windows-medium-amd64
variables:
CTEST_OUTPUT_ON_FAILURE: "ON"
MSVC_PATH: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools"
before_script:
# "Run" vsdevcmd.bat in PowerShell, to set up MSVC environment variables.
# See: https://github.com/microsoft/vswhere/issues/150#issuecomment-485381959
- |
if ($MSVC_PATH -and (Test-Path "$MSVC_PATH\Common7\Tools\vsdevcmd.bat")) {
$json = $(& "${env:COMSPEC}" /s /c "`"$MSVC_PATH\Common7\Tools\vsdevcmd.bat`" -no_logo -arch=x64 && pwsh -Command `"Get-ChildItem env: | Select-Object Key,Value | ConvertTo-Json`"")
if ($LASTEXITCODE -ne 0) {
Write-Error "($LASTEXITCODE) $MSVC_PATH\Common7\Tools\vsdevcmd.bat: $json"
} else {
$($json | ConvertFrom-Json) | ForEach-Object {
$k, $v = $_.Key, $_.Value
Set-Content env:\"$k" "$v"
}
}
}
script:
# Prepare build.
- New-Item -ItemType Directory -Path build -Force
- cd build
- cmake -S ../src -B . -G "Visual Studio 17 2022" -A x64
# Build.
- cmake --build . --config Release
# Run unit tests.
- ctest -j 3 -C Release
# Install & package.
- cd ..
- cmake --install build --prefix buildcache --strip
- 7z a -tzip -mx=9 $Env:PACKAGE_FILE_WINDOWS buildcache
artifacts:
expose_as: 'BuildCache Windows'
name: 'buildcache-windows'
paths:
- ${PACKAGE_FILE_WINDOWS}
build_macos:
stage: build
tags:
- saas-macos-medium-m1
image: macos-13-xcode-14
variables:
HOMEBREW_NO_AUTO_UPDATE: 1
CTEST_OUTPUT_ON_FAILURE: "ON"
before_script:
# Install necessary packages.
- brew install cmake ninja p7zip
script:
# Prepare build.
- mkdir -p build
- cd build
- cmake -S ../src -B . -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"
# Build.
- cmake --build .
# Run unit tests.
- ctest -j 5
# Run system tests.
- ../test_scripts/run_file_lock_stresstest.sh
- ../test_scripts/build_with_buildcache.sh
# Install & package.
- cd ..
- cmake --install build --prefix buildcache --strip
- 7z a -tzip -mx=9 ${PACKAGE_FILE_MACOS} buildcache
artifacts:
expose_as: 'BuildCache macOS'
name: 'buildcache-macOS'
paths:
# For some reason ${PACKAGE_FILE_MACOS} does not work here. Is it a bug?
- buildcache-macos.zip
upload_job:
rules:
- if: $CI_COMMIT_TAG && $CI_COMMIT_TAG =~ /^v[0-9]+.*/
stage: upload
image: curlimages/curl:latest
needs:
- job: build_linux
artifacts: true
- job: build_windows
artifacts: true
- job: build_macos
artifacts: true
script:
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "${PACKAGE_FILE_LINUX}" "${PACKAGE_REGISTRY_URL}/${PACKAGE_FILE_LINUX}"
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "${PACKAGE_FILE_WINDOWS}" "${PACKAGE_REGISTRY_URL}/${PACKAGE_FILE_WINDOWS}"
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "${PACKAGE_FILE_MACOS}" "${PACKAGE_REGISTRY_URL}/${PACKAGE_FILE_MACOS}"
release_job:
rules:
- if: $CI_COMMIT_TAG && $CI_COMMIT_TAG =~ /^v[0-9]+.*/
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
needs:
- job: upload_job
script:
- echo 'Running release_job'
release:
tag_name: '$CI_COMMIT_TAG'
name: 'Release $CI_COMMIT_TAG'
description: 'Release for tag $CI_COMMIT_TAG'
assets:
links:
- name: "${PACKAGE_FILE_LINUX}"
filepath: "/${PACKAGE_FILE_LINUX}"
url: "${PACKAGE_REGISTRY_URL}/${PACKAGE_FILE_LINUX}"
- name: "${PACKAGE_FILE_WINDOWS}"
filepath: "/${PACKAGE_FILE_WINDOWS}"
url: "${PACKAGE_REGISTRY_URL}/${PACKAGE_FILE_WINDOWS}"
- name: "${PACKAGE_FILE_MACOS}"
filepath: "/${PACKAGE_FILE_MACOS}"
url: "${PACKAGE_REGISTRY_URL}/${PACKAGE_FILE_MACOS}"
pages:
rules:
- if: $CI_COMMIT_TAG && $CI_COMMIT_TAG =~ /^v[0-9]+.*/
stage: doxygen
image: ubuntu:23.04
before_script:
- apt-get update
- |
DEBIAN_FRONTEND=noninteractive apt-get install -y \
build-essential \
cmake \
doxygen \
g++
script:
# Prepare build.
- cmake -S src -B build
# Generate doxygen documentation.
- cmake --build build --target doc
artifacts:
paths:
- build/doc/html
publish: build/doc/html