|
5 | 5 | branches: |
6 | 6 | - main |
7 | 7 | - release/* |
| 8 | + - develop |
8 | 9 | types: |
9 | 10 | - opened |
10 | 11 | - synchronize |
11 | 12 | - reopened |
| 13 | + - labeled |
12 | 14 | workflow_dispatch: |
13 | 15 |
|
14 | 16 | permissions: |
15 | 17 | contents: read |
| 18 | + packages: read |
| 19 | + |
| 20 | +env: |
| 21 | + GHCR_IMAGE: ghcr.io/${{ github.repository_owner }}/cfdesktop-build-env |
16 | 22 |
|
17 | 23 | jobs: |
18 | | - linux-build-test: |
19 | | - name: Linux build and tests |
| 24 | + check-trigger: |
| 25 | + name: Check CI trigger |
| 26 | + runs-on: ubuntu-latest |
| 27 | + outputs: |
| 28 | + should_run: ${{ steps.check.outputs.should_run }} |
| 29 | + run_clang: ${{ steps.check.outputs.run_clang }} |
| 30 | + run_msvc: ${{ steps.check.outputs.run_msvc }} |
| 31 | + steps: |
| 32 | + - name: Determine CI scope |
| 33 | + id: check |
| 34 | + run: | |
| 35 | + BASE="${{ github.base_ref }}" |
| 36 | + LABELS="${{ join(github.event.pull_request.labels.*.name, ',') }}" |
| 37 | +
|
| 38 | + echo "should_run=true" >> "$GITHUB_OUTPUT" |
| 39 | +
|
| 40 | + # Clang: build-clang label or main/release (always full) |
| 41 | + if echo "$LABELS" | grep -qw "build-clang" || [[ "$BASE" != "develop" ]]; then |
| 42 | + echo "run_clang=true" >> "$GITHUB_OUTPUT" |
| 43 | + else |
| 44 | + echo "run_clang=false" >> "$GITHUB_OUTPUT" |
| 45 | + fi |
| 46 | +
|
| 47 | + # MSVC: build-msvc label or main/release (always full) |
| 48 | + if echo "$LABELS" | grep -qw "build-msvc" || [[ "$BASE" != "develop" ]]; then |
| 49 | + echo "run_msvc=true" >> "$GITHUB_OUTPUT" |
| 50 | + else |
| 51 | + echo "run_msvc=false" >> "$GITHUB_OUTPUT" |
| 52 | + fi |
| 53 | +
|
| 54 | + echo "--- CI Scope ---" |
| 55 | + echo "Base branch: $BASE" |
| 56 | + echo "Labels: $LABELS" |
| 57 | + echo "GCC: always" |
| 58 | + echo "Clang: $(echo "$LABELS" | grep -qE 'build-(clang|all-platform)' && echo 'yes' || { [[ "$BASE" != "develop" ]] && echo 'yes' || echo 'no'; })" |
| 59 | + echo "MSVC: $(echo "$LABELS" | grep -qE 'build-(msvc|all-platform)' && echo 'yes' || { [[ "$BASE" != "develop" ]] && echo 'yes' || echo 'no'; })" |
| 60 | +
|
| 61 | + linux-gcc: |
| 62 | + name: Linux GCC |
| 63 | + needs: check-trigger |
| 64 | + if: needs.check-trigger.outputs.should_run == 'true' |
20 | 65 | runs-on: ubuntu-latest |
21 | 66 |
|
22 | 67 | steps: |
23 | 68 | - name: Checkout |
24 | 69 | uses: actions/checkout@v4 |
25 | 70 |
|
26 | | - - name: Build Docker image |
| 71 | + - name: Normalize Docker image name |
| 72 | + run: echo "GHCR_IMAGE=$(echo '${{ env.GHCR_IMAGE }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV" |
| 73 | + |
| 74 | + - name: Log in to GHCR |
| 75 | + uses: docker/login-action@v3 |
| 76 | + with: |
| 77 | + registry: ghcr.io |
| 78 | + username: ${{ github.actor }} |
| 79 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 80 | + |
| 81 | + - name: Pull pre-built Docker image |
| 82 | + run: | |
| 83 | + if docker pull ${{ env.GHCR_IMAGE }}:latest; then |
| 84 | + echo "GHCR_PULL_FAILED=false" >> "$GITHUB_ENV" |
| 85 | + else |
| 86 | + echo "::warning::GHCR image pull failed, falling back to local Docker build." |
| 87 | + echo "GHCR_PULL_FAILED=true" >> "$GITHUB_ENV" |
| 88 | + fi |
| 89 | +
|
| 90 | + - name: Build Docker image (fallback) |
| 91 | + if: env.GHCR_PULL_FAILED == 'true' |
27 | 92 | run: | |
| 93 | + echo "::warning::GHCR image not available, building locally..." |
28 | 94 | docker build \ |
| 95 | + --progress=plain \ |
29 | 96 | --platform linux/amd64 \ |
30 | 97 | --build-arg QT_ARCH=linux_gcc_64 \ |
| 98 | + --build-arg CI=true \ |
31 | 99 | -f scripts/docker/Dockerfile.build \ |
32 | | - -t cfdesktop-build \ |
| 100 | + -t ${{ env.GHCR_IMAGE }}:latest \ |
33 | 101 | . |
34 | 102 |
|
35 | | - - name: Configure, build, and test |
| 103 | + - name: Cache ccache |
| 104 | + uses: actions/cache@v4 |
| 105 | + with: |
| 106 | + path: .ccache/gcc |
| 107 | + key: ccache-linux-gcc-${{ github.sha }} |
| 108 | + restore-keys: | |
| 109 | + ccache-linux-gcc- |
| 110 | +
|
| 111 | + - name: Restore GCC build directory |
| 112 | + uses: actions/cache/restore@v4 |
| 113 | + with: |
| 114 | + path: out/build_ci |
| 115 | + key: build-linux-gcc-${{ github.sha }} |
| 116 | + restore-keys: | |
| 117 | + build-linux-gcc- |
| 118 | +
|
| 119 | + - name: Configure and build |
| 120 | + run: | |
| 121 | + docker run --rm \ |
| 122 | + --platform linux/amd64 \ |
| 123 | + -e QT_QPA_PLATFORM=offscreen \ |
| 124 | + -e CCACHE_DIR=/project/.ccache/gcc \ |
| 125 | + -e CCACHE_BASEDIR=/project \ |
| 126 | + -e CCACHE_COMPILERCHECK=content \ |
| 127 | + -e CCACHE_NOHASHDIR=true \ |
| 128 | + -v "$PWD:/project" \ |
| 129 | + -w /project \ |
| 130 | + ${{ env.GHCR_IMAGE }}:latest \ |
| 131 | + 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' |
| 132 | +
|
| 133 | + - name: Save GCC build cache |
| 134 | + if: success() |
| 135 | + uses: actions/cache/save@v4 |
| 136 | + with: |
| 137 | + path: out/build_ci |
| 138 | + key: build-linux-gcc-${{ github.sha }} |
| 139 | + |
| 140 | + - name: Run tests |
36 | 141 | run: | |
37 | 142 | docker run --rm \ |
38 | 143 | --platform linux/amd64 \ |
39 | 144 | -e QT_QPA_PLATFORM=offscreen \ |
40 | 145 | -v "$PWD:/project" \ |
41 | 146 | -w /project \ |
42 | | - cfdesktop-build \ |
43 | | - bash -lc "bash scripts/build_helpers/linux_develop_build.sh ci -c build_ci_config.ini && bash scripts/build_helpers/linux_run_tests.sh ci -c build_ci_config.ini" |
| 147 | + ${{ env.GHCR_IMAGE }}:latest \ |
| 148 | + bash -lc 'bash scripts/build_helpers/linux_run_tests.sh ci -c build_ci_config.ini' |
| 149 | +
|
| 150 | + - name: Show ccache stats |
| 151 | + if: always() |
| 152 | + run: | |
| 153 | + docker run --rm \ |
| 154 | + --platform linux/amd64 \ |
| 155 | + -e CCACHE_DIR=/project/.ccache/gcc \ |
| 156 | + -v "$PWD:/project" \ |
| 157 | + -w /project \ |
| 158 | + ${{ env.GHCR_IMAGE }}:latest \ |
| 159 | + bash -lc 'ccache -s || true' || true |
| 160 | +
|
| 161 | + linux-clang: |
| 162 | + name: Linux Clang |
| 163 | + needs: check-trigger |
| 164 | + if: needs.check-trigger.outputs.run_clang == 'true' |
| 165 | + runs-on: ubuntu-latest |
| 166 | + |
| 167 | + steps: |
| 168 | + - name: Checkout |
| 169 | + uses: actions/checkout@v4 |
| 170 | + |
| 171 | + - name: Normalize Docker image name |
| 172 | + run: echo "GHCR_IMAGE=$(echo '${{ env.GHCR_IMAGE }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV" |
| 173 | + |
| 174 | + - name: Log in to GHCR |
| 175 | + uses: docker/login-action@v3 |
| 176 | + with: |
| 177 | + registry: ghcr.io |
| 178 | + username: ${{ github.actor }} |
| 179 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 180 | + |
| 181 | + - name: Pull pre-built Docker image |
| 182 | + run: | |
| 183 | + if docker pull ${{ env.GHCR_IMAGE }}:latest; then |
| 184 | + echo "GHCR_PULL_FAILED=false" >> "$GITHUB_ENV" |
| 185 | + else |
| 186 | + echo "::warning::GHCR image pull failed, falling back to local Docker build." |
| 187 | + echo "GHCR_PULL_FAILED=true" >> "$GITHUB_ENV" |
| 188 | + fi |
| 189 | +
|
| 190 | + - name: Build Docker image (fallback) |
| 191 | + if: env.GHCR_PULL_FAILED == 'true' |
| 192 | + run: | |
| 193 | + echo "::warning::GHCR image not available, building locally..." |
| 194 | + docker build \ |
| 195 | + --progress=plain \ |
| 196 | + --platform linux/amd64 \ |
| 197 | + --build-arg QT_ARCH=linux_gcc_64 \ |
| 198 | + --build-arg CI=true \ |
| 199 | + -f scripts/docker/Dockerfile.build \ |
| 200 | + -t ${{ env.GHCR_IMAGE }}:latest \ |
| 201 | + . |
| 202 | +
|
| 203 | + - name: Cache ccache |
| 204 | + uses: actions/cache@v4 |
| 205 | + with: |
| 206 | + path: .ccache/clang |
| 207 | + key: ccache-linux-clang-${{ github.sha }} |
| 208 | + restore-keys: | |
| 209 | + ccache-linux-clang- |
| 210 | +
|
| 211 | + - name: Restore Clang build directory |
| 212 | + uses: actions/cache/restore@v4 |
| 213 | + with: |
| 214 | + path: out/build_ci_clang |
| 215 | + key: build-linux-clang-${{ github.sha }} |
| 216 | + restore-keys: | |
| 217 | + build-linux-clang- |
| 218 | +
|
| 219 | + - name: Configure and build |
| 220 | + run: | |
| 221 | + docker run --rm \ |
| 222 | + --platform linux/amd64 \ |
| 223 | + -e QT_QPA_PLATFORM=offscreen \ |
| 224 | + -e CCACHE_DIR=/project/.ccache/clang \ |
| 225 | + -e CCACHE_BASEDIR=/project \ |
| 226 | + -e CCACHE_COMPILERCHECK=content \ |
| 227 | + -e CCACHE_NOHASHDIR=true \ |
| 228 | + -v "$PWD:/project" \ |
| 229 | + -w /project \ |
| 230 | + ${{ env.GHCR_IMAGE }}:latest \ |
| 231 | + 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' |
| 232 | +
|
| 233 | + - name: Save Clang build cache |
| 234 | + if: success() |
| 235 | + uses: actions/cache/save@v4 |
| 236 | + with: |
| 237 | + path: out/build_ci_clang |
| 238 | + key: build-linux-clang-${{ github.sha }} |
| 239 | + |
| 240 | + - name: Run tests |
| 241 | + run: | |
| 242 | + docker run --rm \ |
| 243 | + --platform linux/amd64 \ |
| 244 | + -e QT_QPA_PLATFORM=offscreen \ |
| 245 | + -v "$PWD:/project" \ |
| 246 | + -w /project \ |
| 247 | + ${{ env.GHCR_IMAGE }}:latest \ |
| 248 | + bash -lc 'bash scripts/build_helpers/linux_run_tests.sh ci -c build_ci_clang_config.ini' |
| 249 | +
|
| 250 | + - name: Show ccache stats |
| 251 | + if: always() |
| 252 | + run: | |
| 253 | + docker run --rm \ |
| 254 | + --platform linux/amd64 \ |
| 255 | + -e CCACHE_DIR=/project/.ccache/clang \ |
| 256 | + -v "$PWD:/project" \ |
| 257 | + -w /project \ |
| 258 | + ${{ env.GHCR_IMAGE }}:latest \ |
| 259 | + bash -lc 'ccache -s || true' || true |
| 260 | +
|
| 261 | + windows-msvc: |
| 262 | + name: Windows MSVC |
| 263 | + needs: check-trigger |
| 264 | + if: needs.check-trigger.outputs.run_msvc == 'true' |
| 265 | + runs-on: windows-latest |
| 266 | + |
| 267 | + env: |
| 268 | + QT_VERSION: 6.8.1 |
| 269 | + QT_ARCH: win64_msvc2022_64 |
| 270 | + QT_DIR: C:\Qt\6.8.1\msvc2022_64 |
| 271 | + CCACHE_DIR: ${{ github.workspace }}\.ccache\msvc |
| 272 | + |
| 273 | + steps: |
| 274 | + - name: Checkout |
| 275 | + uses: actions/checkout@v4 |
| 276 | + |
| 277 | + - name: Setup MSVC developer environment |
| 278 | + uses: ilammy/msvc-dev-cmd@v1 |
| 279 | + |
| 280 | + - name: Setup Python |
| 281 | + uses: actions/setup-python@v5 |
| 282 | + with: |
| 283 | + python-version: '3.x' |
| 284 | + |
| 285 | + - name: Install ccache |
| 286 | + shell: pwsh |
| 287 | + run: | |
| 288 | + if (-not (Get-Command ccache -ErrorAction SilentlyContinue)) { |
| 289 | + choco install ccache -y --no-progress |
| 290 | + } |
| 291 | + ccache --version |
| 292 | +
|
| 293 | + - name: Cache ccache |
| 294 | + uses: actions/cache@v4 |
| 295 | + with: |
| 296 | + path: .ccache\msvc |
| 297 | + key: ccache-windows-msvc-${{ github.sha }} |
| 298 | + restore-keys: | |
| 299 | + ccache-windows-msvc- |
| 300 | +
|
| 301 | + - name: Configure ccache |
| 302 | + shell: pwsh |
| 303 | + run: | |
| 304 | + New-Item -ItemType Directory -Force -Path $env:CCACHE_DIR | Out-Null |
| 305 | + ccache --set-config="cache_dir=$env:CCACHE_DIR" |
| 306 | + ccache --set-config=max_size=5G |
| 307 | + ccache --set-config=compiler_check=content |
| 308 | + ccache --set-config=compression=true |
| 309 | + ccache --set-config=compression_level=1 |
| 310 | + ccache -z |
| 311 | + ccache -s |
| 312 | +
|
| 313 | + - name: Cache Qt installation |
| 314 | + id: cache-qt |
| 315 | + uses: actions/cache@v4 |
| 316 | + with: |
| 317 | + path: ${{ env.QT_DIR }} |
| 318 | + key: qt-${{ env.QT_VERSION }}-${{ env.QT_ARCH }}-v1 |
| 319 | + |
| 320 | + - name: Install aqtinstall |
| 321 | + if: steps.cache-qt.outputs.cache-hit != 'true' |
| 322 | + run: pip install aqtinstall |
| 323 | + |
| 324 | + - name: Install Qt |
| 325 | + if: steps.cache-qt.outputs.cache-hit != 'true' |
| 326 | + run: | |
| 327 | + python -m aqt install-qt windows desktop ${{ env.QT_VERSION }} ${{ env.QT_ARCH }} ` |
| 328 | + -O C:\Qt ` |
| 329 | + -m qt5compat qtserialport qtimageformats |
| 330 | +
|
| 331 | + - name: Save Qt cache immediately |
| 332 | + if: steps.cache-qt.outputs.cache-hit != 'true' |
| 333 | + uses: actions/cache/save@v4 |
| 334 | + with: |
| 335 | + path: ${{ env.QT_DIR }} |
| 336 | + key: qt-${{ env.QT_VERSION }}-${{ env.QT_ARCH }}-v1 |
| 337 | + |
| 338 | + - name: Restore MSVC build directory |
| 339 | + uses: actions/cache/restore@v4 |
| 340 | + with: |
| 341 | + path: out\build_ci_windows |
| 342 | + key: build-windows-msvc-${{ github.sha }} |
| 343 | + restore-keys: | |
| 344 | + build-windows-msvc- |
| 345 | +
|
| 346 | + - name: Configure and build |
| 347 | + shell: pwsh |
| 348 | + env: |
| 349 | + Qt6_DIR: ${{ env.QT_DIR }}\lib\cmake\Qt6 |
| 350 | + CCACHE_BASEDIR: ${{ github.workspace }} |
| 351 | + CCACHE_COMPILERCHECK: content |
| 352 | + CCACHE_NOHASHDIR: true |
| 353 | + run: | |
| 354 | + ccache -z |
| 355 | + pwsh -NoLogo -NoProfile -ExecutionPolicy Bypass -File scripts/build_helpers/windows_fast_develop_build.ps1 -Config ci |
| 356 | +
|
| 357 | + - name: Save MSVC build cache |
| 358 | + if: success() |
| 359 | + uses: actions/cache/save@v4 |
| 360 | + with: |
| 361 | + path: out\build_ci_windows |
| 362 | + key: build-windows-msvc-${{ github.sha }} |
| 363 | + |
| 364 | + - name: Run tests |
| 365 | + shell: pwsh |
| 366 | + env: |
| 367 | + Qt6_DIR: ${{ env.QT_DIR }}\lib\cmake\Qt6 |
| 368 | + QT_QPA_PLATFORM: offscreen |
| 369 | + run: | |
| 370 | + pwsh -NoLogo -NoProfile -ExecutionPolicy Bypass -File scripts/build_helpers/windows_run_tests.ps1 -Config ci |
| 371 | +
|
| 372 | + - name: Show ccache stats |
| 373 | + if: always() |
| 374 | + shell: pwsh |
| 375 | + run: | |
| 376 | + if (Get-Command ccache -ErrorAction SilentlyContinue) { |
| 377 | + ccache -s |
| 378 | + } |
44 | 379 |
|
45 | 380 | docs-build: |
46 | 381 | name: VitePress docs build |
| 382 | + needs: check-trigger |
| 383 | + if: needs.check-trigger.outputs.should_run == 'true' |
47 | 384 | runs-on: ubuntu-latest |
48 | 385 |
|
49 | 386 | steps: |
|
0 commit comments