-
Notifications
You must be signed in to change notification settings - Fork 1
405 lines (350 loc) · 12.4 KB
/
Copy pathcpp-check.yml
File metadata and controls
405 lines (350 loc) · 12.4 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
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
name: C++ Check
on:
pull_request:
branches:
- main
- release/*
- develop
types:
- opened
- synchronize
- reopened
- labeled
workflow_dispatch:
permissions:
contents: read
packages: read
env:
GHCR_IMAGE: ghcr.io/${{ github.repository_owner }}/cfdesktop-build-env
jobs:
check-trigger:
name: Check CI trigger
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.check.outputs.should_run }}
run_clang: ${{ steps.check.outputs.run_clang }}
run_msvc: ${{ steps.check.outputs.run_msvc }}
steps:
- name: Determine CI scope
id: check
run: |
BASE="${{ github.base_ref }}"
LABELS="${{ join(github.event.pull_request.labels.*.name, ',') }}"
echo "should_run=true" >> "$GITHUB_OUTPUT"
# Clang: build-clang label or main/release (always full)
if echo "$LABELS" | grep -qw "build-clang" || [[ "$BASE" != "develop" ]]; then
echo "run_clang=true" >> "$GITHUB_OUTPUT"
else
echo "run_clang=false" >> "$GITHUB_OUTPUT"
fi
# MSVC: build-msvc label or main/release (always full)
if echo "$LABELS" | grep -qw "build-msvc" || [[ "$BASE" != "develop" ]]; then
echo "run_msvc=true" >> "$GITHUB_OUTPUT"
else
echo "run_msvc=false" >> "$GITHUB_OUTPUT"
fi
echo "--- CI Scope ---"
echo "Base branch: $BASE"
echo "Labels: $LABELS"
echo "GCC: always"
echo "Clang: $(echo "$LABELS" | grep -qE 'build-(clang|all-platform)' && echo 'yes' || { [[ "$BASE" != "develop" ]] && echo 'yes' || echo 'no'; })"
echo "MSVC: $(echo "$LABELS" | grep -qE 'build-(msvc|all-platform)' && echo 'yes' || { [[ "$BASE" != "develop" ]] && echo 'yes' || echo 'no'; })"
linux-gcc:
name: Linux GCC
needs: check-trigger
if: needs.check-trigger.outputs.should_run == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Normalize Docker image name
run: echo "GHCR_IMAGE=$(echo '${{ env.GHCR_IMAGE }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull pre-built Docker image
run: |
if docker pull ${{ env.GHCR_IMAGE }}:latest; then
echo "GHCR_PULL_FAILED=false" >> "$GITHUB_ENV"
else
echo "::warning::GHCR image pull failed, falling back to local Docker build."
echo "GHCR_PULL_FAILED=true" >> "$GITHUB_ENV"
fi
- name: Build Docker image (fallback)
if: env.GHCR_PULL_FAILED == 'true'
run: |
echo "::warning::GHCR image not available, building locally..."
docker build \
--progress=plain \
--platform linux/amd64 \
--build-arg QT_ARCH=linux_gcc_64 \
--build-arg CI=true \
-f scripts/docker/Dockerfile.build \
-t ${{ env.GHCR_IMAGE }}:latest \
.
- name: Cache ccache
uses: actions/cache@v4
with:
path: .ccache/gcc
key: ccache-linux-gcc-${{ github.sha }}
restore-keys: |
ccache-linux-gcc-
- name: Restore GCC build directory
uses: actions/cache/restore@v4
with:
path: out/build_ci
key: build-linux-gcc-${{ github.sha }}
restore-keys: |
build-linux-gcc-
- name: Configure and build
run: |
docker run --rm \
--platform linux/amd64 \
-e QT_QPA_PLATFORM=offscreen \
-e CCACHE_DIR=/project/.ccache/gcc \
-e CCACHE_BASEDIR=/project \
-e CCACHE_COMPILERCHECK=content \
-e CCACHE_NOHASHDIR=true \
-v "$PWD:/project" \
-w /project \
${{ env.GHCR_IMAGE }}:latest \
bash -lc 'ccache --max-size=5G; ccache --set-config=compression=true; ccache --set-config=compression_level=1; ccache -z; bash scripts/build_helpers/linux_fast_develop_build.sh ci -c build_ci_config.ini'
- name: Save GCC build cache
if: success()
uses: actions/cache/save@v4
with:
path: out/build_ci
key: build-linux-gcc-${{ github.sha }}
- name: Run tests
run: |
docker run --rm \
--platform linux/amd64 \
-e QT_QPA_PLATFORM=offscreen \
-v "$PWD:/project" \
-w /project \
${{ env.GHCR_IMAGE }}:latest \
bash -lc 'bash scripts/build_helpers/linux_run_tests.sh ci -c build_ci_config.ini'
- name: Show ccache stats
if: always()
run: |
docker run --rm \
--platform linux/amd64 \
-e CCACHE_DIR=/project/.ccache/gcc \
-v "$PWD:/project" \
-w /project \
${{ env.GHCR_IMAGE }}:latest \
bash -lc 'ccache -s || true' || true
linux-clang:
name: Linux Clang
needs: check-trigger
if: needs.check-trigger.outputs.run_clang == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Normalize Docker image name
run: echo "GHCR_IMAGE=$(echo '${{ env.GHCR_IMAGE }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull pre-built Docker image
run: |
if docker pull ${{ env.GHCR_IMAGE }}:latest; then
echo "GHCR_PULL_FAILED=false" >> "$GITHUB_ENV"
else
echo "::warning::GHCR image pull failed, falling back to local Docker build."
echo "GHCR_PULL_FAILED=true" >> "$GITHUB_ENV"
fi
- name: Build Docker image (fallback)
if: env.GHCR_PULL_FAILED == 'true'
run: |
echo "::warning::GHCR image not available, building locally..."
docker build \
--progress=plain \
--platform linux/amd64 \
--build-arg QT_ARCH=linux_gcc_64 \
--build-arg CI=true \
-f scripts/docker/Dockerfile.build \
-t ${{ env.GHCR_IMAGE }}:latest \
.
- name: Cache ccache
uses: actions/cache@v4
with:
path: .ccache/clang
key: ccache-linux-clang-${{ github.sha }}
restore-keys: |
ccache-linux-clang-
- name: Restore Clang build directory
uses: actions/cache/restore@v4
with:
path: out/build_ci_clang
key: build-linux-clang-${{ github.sha }}
restore-keys: |
build-linux-clang-
- name: Configure and build
run: |
docker run --rm \
--platform linux/amd64 \
-e QT_QPA_PLATFORM=offscreen \
-e CCACHE_DIR=/project/.ccache/clang \
-e CCACHE_BASEDIR=/project \
-e CCACHE_COMPILERCHECK=content \
-e CCACHE_NOHASHDIR=true \
-v "$PWD:/project" \
-w /project \
${{ env.GHCR_IMAGE }}:latest \
bash -lc 'ccache --max-size=5G; ccache --set-config=compression=true; ccache --set-config=compression_level=1; ccache -z; bash scripts/build_helpers/linux_fast_develop_build.sh ci -c build_ci_clang_config.ini'
- name: Save Clang build cache
if: success()
uses: actions/cache/save@v4
with:
path: out/build_ci_clang
key: build-linux-clang-${{ github.sha }}
- name: Run tests
run: |
docker run --rm \
--platform linux/amd64 \
-e QT_QPA_PLATFORM=offscreen \
-v "$PWD:/project" \
-w /project \
${{ env.GHCR_IMAGE }}:latest \
bash -lc 'bash scripts/build_helpers/linux_run_tests.sh ci -c build_ci_clang_config.ini'
- name: Show ccache stats
if: always()
run: |
docker run --rm \
--platform linux/amd64 \
-e CCACHE_DIR=/project/.ccache/clang \
-v "$PWD:/project" \
-w /project \
${{ env.GHCR_IMAGE }}:latest \
bash -lc 'ccache -s || true' || true
windows-msvc:
name: Windows MSVC
needs: check-trigger
if: needs.check-trigger.outputs.run_msvc == 'true'
runs-on: windows-latest
env:
QT_VERSION: 6.8.1
QT_ARCH: win64_msvc2022_64
QT_DIR: C:\Qt\6.8.1\msvc2022_64
CCACHE_DIR: ${{ github.workspace }}\.ccache\msvc
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup MSVC developer environment
uses: ilammy/msvc-dev-cmd@v1
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install ccache
shell: pwsh
run: |
if (-not (Get-Command ccache -ErrorAction SilentlyContinue)) {
choco install ccache -y --no-progress
}
ccache --version
- name: Cache ccache
uses: actions/cache@v4
with:
path: .ccache\msvc
key: ccache-windows-msvc-${{ github.sha }}
restore-keys: |
ccache-windows-msvc-
- name: Configure ccache
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path $env:CCACHE_DIR | Out-Null
ccache --set-config="cache_dir=$env:CCACHE_DIR"
ccache --set-config=max_size=5G
ccache --set-config=compiler_check=content
ccache --set-config=compression=true
ccache --set-config=compression_level=1
ccache -z
ccache -s
- name: Cache Qt installation
id: cache-qt
uses: actions/cache@v4
with:
path: ${{ env.QT_DIR }}
key: qt-${{ env.QT_VERSION }}-${{ env.QT_ARCH }}-v1
- name: Install aqtinstall
if: steps.cache-qt.outputs.cache-hit != 'true'
run: pip install aqtinstall
- name: Install Qt
if: steps.cache-qt.outputs.cache-hit != 'true'
run: |
python -m aqt install-qt windows desktop ${{ env.QT_VERSION }} ${{ env.QT_ARCH }} `
-O C:\Qt `
-m qt5compat qtserialport qtimageformats
- name: Save Qt cache immediately
if: steps.cache-qt.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ${{ env.QT_DIR }}
key: qt-${{ env.QT_VERSION }}-${{ env.QT_ARCH }}-v1
- name: Restore MSVC build directory
uses: actions/cache/restore@v4
with:
path: out\build_ci_windows
key: build-windows-msvc-${{ github.sha }}
restore-keys: |
build-windows-msvc-
- name: Configure and build
shell: pwsh
env:
Qt6_DIR: ${{ env.QT_DIR }}\lib\cmake\Qt6
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPILERCHECK: content
CCACHE_NOHASHDIR: true
run: |
ccache -z
pwsh -NoLogo -NoProfile -ExecutionPolicy Bypass -File scripts/build_helpers/windows_fast_develop_build.ps1 -Config ci
- name: Save MSVC build cache
if: success()
uses: actions/cache/save@v4
with:
path: out\build_ci_windows
key: build-windows-msvc-${{ github.sha }}
- name: Run tests
shell: pwsh
env:
Qt6_DIR: ${{ env.QT_DIR }}\lib\cmake\Qt6
QT_QPA_PLATFORM: offscreen
run: |
pwsh -NoLogo -NoProfile -ExecutionPolicy Bypass -File scripts/build_helpers/windows_run_tests.ps1 -Config ci
- name: Show ccache stats
if: always()
shell: pwsh
run: |
if (Get-Command ccache -ErrorAction SilentlyContinue) {
ccache -s
}
docs-build:
name: VitePress docs build
needs: check-trigger
if: needs.check-trigger.outputs.should_run == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.33.3
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build docs
run: pnpm build