summaryrefslogtreecommitdiff
path: root/.github/workflows/warm-dependency-caches.yml
blob: 9c38a1a77660d38831135110f10491450dfb6b07 (plain)
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
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
name: Refresh Build Caches

on:
  push:
    branches: [develop]
    paths:
      - ".github/workflows/ci.yml"
      - ".github/workflows/release.yml"
      - ".github/workflows/build-linux.yml"
      - ".github/workflows/build-linux-sanitizers.yml"
      - ".github/workflows/warm-dependency-caches.yml"
      - ".github/actions/build-linux-payload/**"
      - ".github/actions/build-linux-sanitizers/**"
      - ".github/scripts/verify-sanitizer-instrumentation.py"
      - "CMakeLists.txt"
      - "CMake/**"
      - "tests/CMakeLists.txt"
      - "tests/**/CMakeLists.txt"
      - ".github/images/linux-ci/**"
      - ".github/scripts/linux-ci-image-config.sh"
      - ".github/scripts/linux-ci-image-fingerprint.sh"
      - ".github/scripts/linux-ci-image-inputs.sh"
      - ".github/scripts/linux-ccache-compiler-signature.sh"
      - ".github/scripts/select-ccache-key-suffix.sh"
      - ".github/scripts/select-linux-ccache-save.sh"
      - ".github/scripts/run-apt-get.sh"
      - ".github/scripts/build-pfunit-linux.sh"
      - ".github/scripts/build-hamlib-linux.sh"
      - ".github/scripts/tsan-linux-deps-config.sh"
      - ".github/scripts/build-qt-tsan-linux.sh"
      - ".github/scripts/build-boost-tsan-linux.sh"
      - ".github/scripts/build-hamlib-tsan-linux.sh"
      - ".github/scripts/verify-linux-ci-image.sh"
      - ".github/scripts/verify-tsan-deps-linux.sh"
      - ".github/workflows/build-macos.yml"
      - ".github/workflows/build-windows.yml"
      - ".github/actions/warm-macos-deps/**"
      - ".github/actions/build-windows-deps/**"
      - ".github/scripts/build-*-macos.sh"
      - ".github/scripts/build-*-windows.sh"
      - ".github/scripts/*armhf*"
      - ".github/cmake/armhf-toolchain.cmake"
      - ".github/scripts/linux-artifact-validation.sh"
      - ".github/scripts/install-*-macos*.sh"
      - ".github/scripts/macos-qt-cache-key.sh"
      - ".github/scripts/verify-macos-*.sh"
  schedule:
    - cron: "23 10 * * 1"
    - cron: "17 9 1 * *"
  workflow_dispatch:
    inputs:
      targets:
        description: "Platform caches to warm"
        required: false
        type: choice
        options:
          - macos-arm64
          - macos-x86_64
          - macos
          - windows
          - linux
          - linux-arm64
          - linux-armhf
          - linux-asan-ubsan
          - linux-tsan
          - linux-images
          - linux-retention
          - all
        default: macos-arm64
      hamlib_branch:
        description: "Hamlib branch to build"
        required: false
        type: string
        default: "4.7.2"

permissions:
  contents: read

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: false

jobs:
  detect:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    permissions:
      contents: read
      packages: read
    outputs:
      linux_images: ${{ steps.detect.outputs.linux_images }}
      linux_arm64: ${{ steps.detect.outputs.linux_arm64 }}
      linux_armhf: ${{ steps.detect.outputs.linux_armhf }}
      linux_asan_ubsan: ${{ steps.detect.outputs.linux_asan_ubsan }}
      retention: ${{ steps.detect.outputs.retention }}
      windows: ${{ steps.detect.outputs.windows }}
      macos_arm64: ${{ steps.detect.outputs.macos_arm64 }}
      macos_x86_64: ${{ steps.detect.outputs.macos_x86_64 }}
      image_set: ${{ steps.detect.outputs.image_set }}
      hamlib_branch: ${{ steps.detect.outputs.hamlib_branch }}
      version: ${{ steps.detect.outputs.version }}
    steps:
      - uses: actions/checkout@v7
        with:
          fetch-depth: 2

      - id: detect
        name: Select cache warmers
        shell: bash
        env:
          EVENT_NAME: ${{ github.event_name }}
          SCHEDULE: ${{ github.event.schedule }}
          BEFORE_SHA: ${{ github.event.before }}
          CURRENT_SHA: ${{ github.sha }}
          TARGETS: ${{ inputs.targets || '' }}
          HAMLIB_BRANCH: ${{ inputs.hamlib_branch || '4.7.2' }}
        run: |
          set -euo pipefail
          .github/scripts/validate-ci-inputs.sh

          normal_images=false
          tsan_images=false
          retention=false
          linux_arm64=false
          linux_armhf=false
          linux_asan_ubsan=false
          windows=false
          macos_arm64=false
          macos_x86_64=false

          enable_cache_all() {
            linux_arm64=true
            linux_armhf=true
            linux_asan_ubsan=true
            windows=true
            macos_arm64=true
            macos_x86_64=true
          }

          enable_all() {
            normal_images=true
            retention=true
            enable_cache_all
          }

          case "$EVENT_NAME" in
            schedule)
              retention=true
              # Refresh the promoted image monthly only when no newer refresh occurred.
              if [ "$SCHEDULE" = "17 9 1 * *" ] && \
                python3 .github/scripts/should-refresh-linux-ci-images.py --max-age-days 30; then
                normal_images=true
                tsan_images=true
              elif [ "$SCHEDULE" = "23 10 * * 1" ]; then
                enable_cache_all
              fi
              ;;
            workflow_dispatch)
              case "$TARGETS" in
                all)
                  enable_all
                  ;;
                linux|linux-images)
                  normal_images=true
                  linux_arm64=true
                  ;;
                linux-arm64)
                  linux_arm64=true
                  ;;
                linux-armhf)
                  linux_armhf=true
                  ;;
                linux-asan-ubsan)
                  linux_asan_ubsan=true
                  ;;
                linux-tsan)
                  tsan_images=true
                  ;;
                linux-retention)
                  retention=true
                  ;;
                windows)
                  windows=true
                  ;;
                macos)
                  macos_arm64=true
                  macos_x86_64=true
                  ;;
                macos-arm64)
                  macos_arm64=true
                  ;;
                macos-x86_64)
                  macos_x86_64=true
                  ;;
                *)
                  echo "::error::Unsupported targets input: $TARGETS"
                  exit 2
                  ;;
              esac
              ;;
            push)
              if [ -n "$BEFORE_SHA" ] && [ "$BEFORE_SHA" != "0000000000000000000000000000000000000000" ]; then
                base="$BEFORE_SHA"
              else
                base="${CURRENT_SHA}^"
              fi

              if ! git cat-file -e "${base}^{commit}" 2>/dev/null; then
                git fetch --no-tags --depth=1 origin "$base" || true
              fi

              if git cat-file -e "${base}^{commit}" 2>/dev/null; then
                changed="$(git diff --name-only "$base" "$CURRENT_SHA")"
              else
                echo "::notice::Could not compare $base..$CURRENT_SHA; warming all dependency caches"
                changed=""
                enable_all
                tsan_images=true
              fi

              while IFS= read -r path; do
                [ -n "$path" ] || continue
                case "$path" in
                  .github/workflows/ci.yml|.github/workflows/release.yml|.github/workflows/warm-dependency-caches.yml|.github/scripts/select-ccache-key-suffix.sh)
                    enable_cache_all
                    ;;
                  .github/workflows/build-linux.yml|.github/actions/build-linux-payload/*|.github/scripts/select-linux-ccache-save.sh)
                    linux_arm64=true
                    linux_armhf=true
                    ;;
                  .github/scripts/build-linux-armhf-cross.sh|.github/scripts/audit-armhf-cross-build.sh|.github/cmake/armhf-toolchain.cmake|.github/scripts/linux-artifact-validation.sh)
                    linux_armhf=true
                    ;;
                  CMakeLists.txt|CMake/*|tests/CMakeLists.txt|tests/*/CMakeLists.txt)
                    linux_armhf=true
                    linux_asan_ubsan=true
                    ;;
                  .github/workflows/build-linux-sanitizers.yml|.github/actions/build-linux-sanitizers/*|.github/scripts/verify-sanitizer-instrumentation.py)
                    linux_asan_ubsan=true
                    ;;
                  .github/workflows/build-windows.yml|.github/actions/build-windows-deps/*|.github/scripts/build-boost-windows.sh|.github/scripts/build-pfunit-windows.sh|.github/scripts/build-hamlib-windows.sh)
                    windows=true
                    ;;
                  .github/workflows/build-macos.yml|.github/actions/warm-macos-deps/*|.github/scripts/build-*-macos.sh|.github/scripts/install-*-macos*.sh|.github/scripts/macos-qt-cache-key.sh|.github/scripts/verify-macos-*.sh)
                    macos_arm64=true
                    macos_x86_64=true
                    ;;
                  *)
                    case "$(.github/scripts/is-linux-ci-image-input.sh --classify "$path")" in
                      normal)
                        normal_images=true
                        ;;
                      tsan)
                        tsan_images=true
                        ;;
                      normal-and-tsan)
                        normal_images=true
                        tsan_images=true
                        ;;
                    esac
                    ;;
                esac
              done <<< "$changed"
              ;;
            *)
              echo "::error::Unsupported event: $EVENT_NAME"
              exit 2
              ;;
          esac

          if [ "$normal_images" = true ] && [ "$tsan_images" = true ]; then
            image_set=normal-and-tsan
          elif [ "$normal_images" = true ]; then
            image_set=normal
          elif [ "$tsan_images" = true ]; then
            image_set=tsan
          else
            image_set=none
          fi
          linux_images=false
          if [ "$image_set" != none ]; then
            linux_images=true
          fi

          VERSION=$(awk -F= '$1 == "version" {print $2; exit}' release-state.txt)
          if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
            echo "::error::Could not derive VERSION from release-state.txt"
            exit 1
          fi

          {
            echo "linux_images=$linux_images"
            echo "linux_arm64=$linux_arm64"
            echo "linux_armhf=$linux_armhf"
            echo "linux_asan_ubsan=$linux_asan_ubsan"
            echo "retention=$retention"
            echo "windows=$windows"
            echo "macos_arm64=$macos_arm64"
            echo "macos_x86_64=$macos_x86_64"
            echo "image_set=$image_set"
            echo "hamlib_branch=$HAMLIB_BRANCH"
            echo "version=$VERSION"
          } >> "$GITHUB_OUTPUT"

          {
            echo "## Build cache warmer selection"
            echo
            echo "| Target | Enabled |"
            echo "| --- | --- |"
            echo "| Linux GHCR image set | $image_set |"
            echo "| Linux arm64 ccache | $linux_arm64 |"
            echo "| Linux ARMHF ccache (standalone) | $linux_armhf |"
            echo "| Linux ASan/UBSan ccache (standalone) | $linux_asan_ubsan |"
            echo "| Linux GHCR retention | $retention |"
            echo "| Windows x86_64 | $windows |"
            echo "| macOS arm64 | $macos_arm64 |"
            echo "| macOS x86_64 | $macos_x86_64 |"
          } >> "$GITHUB_STEP_SUMMARY"

          echo "Normal image refreshes warm ARMHF and ASan/UBSan after promotion instead of running the standalone warmers." >> "$GITHUB_STEP_SUMMARY"

  refresh-linux-images:
    needs: detect
    if: needs.detect.outputs.linux_images == 'true'
    uses: ./.github/workflows/publish-linux-ci-images.yml
    permissions:
      contents: read
      packages: write
    with:
      # ARMHF is part of the normal Linux image cohort. The reusable publisher
      # validates and promotes its paired images before dependent builds resolve them.
      promote: true
      include_armhf: true
      image_set: ${{ needs.detect.outputs.image_set }}

  retain-linux-images:
    needs: [detect, refresh-linux-images]
    if: >-
      always() &&
      needs.detect.outputs.retention == 'true' &&
      (needs.refresh-linux-images.result == 'success' ||
       needs.refresh-linux-images.result == 'skipped')
    runs-on: ubuntu-24.04
    timeout-minutes: 10
    permissions:
      contents: read
      packages: write
    concurrency:
      group: linux-ci-image-publishing
      cancel-in-progress: false
    steps:
      - uses: actions/checkout@v7
      - name: Apply GHCR retention
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          APPLY: ${{ github.event_name == 'schedule' }}
        shell: bash
        run: |
          args=(
            --owner WSJTX
            --max-age-days 60
            --keep 3
            --package wsjtx-internal/linux-noble
            --package wsjtx-internal/linux-tsan-noble
            --package wsjtx-internal/linux-arm64-bookworm
            --package wsjtx-internal/linux-armhf-cross-bookworm
            --package wsjtx-internal/linux-armv7-bookworm
          )
          if [ "$APPLY" = true ]; then
            args+=(--apply)
          fi
          .github/scripts/ghcr_retention.py "${args[@]}"

  warm-linux-arm64-ccache:
    needs: detect
    if: >-
      github.ref == 'refs/heads/develop' &&
      needs.detect.outputs.linux_arm64 == 'true' &&
      needs.detect.outputs.image_set != 'normal' &&
      needs.detect.outputs.image_set != 'normal-and-tsan'
    uses: ./.github/workflows/build-linux.yml
    permissions:
      contents: read
      packages: read
    with:
      version: ${{ needs.detect.outputs.version }}
      hamlib_branch: ${{ needs.detect.outputs.hamlib_branch }}
      arch: aarch64
      save_ccache: true

  warm-linux-armhf-ccache:
    needs: detect
    if: >-
      github.ref == 'refs/heads/develop' &&
      needs.detect.outputs.linux_armhf == 'true' &&
      needs.detect.outputs.image_set != 'normal' &&
      needs.detect.outputs.image_set != 'normal-and-tsan'
    uses: ./.github/workflows/build-linux.yml
    permissions:
      contents: read
      packages: read
    concurrency:
      group: armhf-ccache-develop
      cancel-in-progress: false
    with:
      version: ${{ needs.detect.outputs.version }}
      hamlib_branch: ${{ needs.detect.outputs.hamlib_branch }}
      arch: armhf
      armhf_build_only: true
      allow_stale_image: false
      recache: false
      save_ccache: true

  warm-linux-asan-ubsan-ccache:
    needs: detect
    if: >-
      github.ref == 'refs/heads/develop' &&
      needs.detect.outputs.linux_asan_ubsan == 'true' &&
      needs.detect.outputs.image_set != 'normal' &&
      needs.detect.outputs.image_set != 'normal-and-tsan'
    uses: ./.github/workflows/build-linux-sanitizers.yml
    permissions:
      contents: read
      packages: read
    concurrency:
      group: asan-ubsan-ccache-develop
      cancel-in-progress: false
    with:
      hamlib_branch: ${{ needs.detect.outputs.hamlib_branch }}
      sanitizer: asan-ubsan
      run_tests: false
      allow_stale_image: false
      recache: false
      save_ccache: true

  warm-windows-x86_64-deps:
    needs: detect
    if: needs.detect.outputs.windows == 'true'
    runs-on: windows-latest
    timeout-minutes: 60
    steps:
      - name: Disable core.autocrlf before checkout
        shell: pwsh
        run: git config --global core.autocrlf false

      - uses: actions/checkout@v7

      # Boost is source-built by build-windows-deps so the Windows 7 API floor
      # and Boost.Atomic patch stay pinned; do not install MSYS2 Boost here.
      - uses: msys2/setup-msys2@v2
        with:
          msystem: MINGW64
          update: true
          cache: true
          install: >-
            git make tar curl
            mingw-w64-x86_64-gcc
            mingw-w64-x86_64-gcc-fortran
            mingw-w64-x86_64-cmake
            mingw-w64-x86_64-python
            mingw-w64-x86_64-pkg-config
            autoconf automake libtool

      - uses: ./.github/actions/build-windows-deps
        with:
          hamlib_branch: ${{ needs.detect.outputs.hamlib_branch }}
          save_caches: "true"

  warm-windows-ccache:
    needs: [detect, warm-windows-x86_64-deps]
    if: needs.detect.outputs.windows == 'true'
    uses: ./.github/workflows/build-windows.yml
    with:
      version: ${{ needs.detect.outputs.version }}
      hamlib_branch: ${{ needs.detect.outputs.hamlib_branch }}
      save_ccache: true

  warm-macos-arm64-deps:
    needs: detect
    if: needs.detect.outputs.macos_arm64 == 'true'
    runs-on: macos-15
    timeout-minutes: 40
    steps:
      - uses: actions/checkout@v7
      - uses: ./.github/actions/warm-macos-deps
        with:
          arch: arm64
          runner: macos-15
          deployment_target: "11.0"
          hamlib_branch: ${{ needs.detect.outputs.hamlib_branch }}

  warm-macos-x86_64-deps:
    needs: detect
    if: needs.detect.outputs.macos_x86_64 == 'true'
    runs-on: macos-15-intel
    timeout-minutes: 100
    steps:
      - uses: actions/checkout@v7
      - uses: ./.github/actions/warm-macos-deps
        with:
          arch: x86_64
          runner: macos-15-intel
          deployment_target: "10.13"
          hamlib_branch: ${{ needs.detect.outputs.hamlib_branch }}

  warm-macos-arm64-ccache:
    needs: [detect, warm-macos-arm64-deps]
    if: needs.detect.outputs.macos_arm64 == 'true'
    uses: ./.github/workflows/build-macos.yml
    with:
      version: ${{ needs.detect.outputs.version }}
      hamlib_branch: ${{ needs.detect.outputs.hamlib_branch }}
      arch: arm64
      runner: macos-15
      deployment_target: "11.0"
      save_ccache: true

  warm-macos-x86_64-ccache:
    needs: [detect, warm-macos-x86_64-deps]
    if: needs.detect.outputs.macos_x86_64 == 'true'
    uses: ./.github/workflows/build-macos.yml
    with:
      version: ${{ needs.detect.outputs.version }}
      hamlib_branch: ${{ needs.detect.outputs.hamlib_branch }}
      arch: x86_64
      runner: macos-15-intel
      deployment_target: "10.13"
      save_ccache: true

  summary:
    if: always()
    needs:
      - detect
      - refresh-linux-images
      - retain-linux-images
      - warm-linux-arm64-ccache
      - warm-linux-armhf-ccache
      - warm-linux-asan-ubsan-ccache
      - warm-windows-x86_64-deps
      - warm-windows-ccache
      - warm-macos-arm64-deps
      - warm-macos-x86_64-deps
      - warm-macos-arm64-ccache
      - warm-macos-x86_64-ccache
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - name: Summarize cache warmer outcomes
        env:
          JOBS: ${{ toJSON(needs) }}
        run: |
          python3 - <<'PY' >> "$GITHUB_STEP_SUMMARY"
          import json
          import os

          print("## Cache warmer outcomes\n")
          print("| Job | Result |")
          print("| --- | --- |")
          for name, job in json.loads(os.environ["JOBS"]).items():
              print(f"| {name} | {job['result']} |")
          print("\nSkipped jobs did not validate their caches. See each job's cache summary for restore and build details.")
          PY