summaryrefslogtreecommitdiff
path: root/.github/workflows/ci.yml
blob: 3b96564affdc5635af3e87010eb7eea86054609e (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
name: CI

on:
  push:
    branches: [develop, "release/**"]
  pull_request:
    branches: [develop, "release/**"]
    # `labeled` is added to the defaults (opened/synchronize/reopened) so
    # that applying `full-ci`, `sanitizers`, or `thread-sanitizer` to an
    # already-open PR triggers
    # a fresh run that includes the requested opt-in jobs (see the gates below).
    types: [opened, synchronize, reopened, labeled]
  workflow_dispatch:
    inputs:
      recache:
        description: "Force recompilation and persist refreshed ccache objects on develop"
        required: false
        type: boolean
        default: false
      save_ccache:
        description: "Persist Linux ccache objects without forcing recompilation on develop"
        required: false
        type: boolean
        default: false
      armhf_image_tag:
        description: "Immutable paired ARMHF image tag; empty resolves the promoted generation"
        required: false
        type: string
        default: ""

concurrency:
  group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions:
  contents: read
  packages: read

jobs:
  # Single source of truth for the project version string: read it from
  # release-state.txt so CI and release builds cannot disagree. Strip the
  # optional fourth tweak segment (3.0.0.0 → 3.0.0) to match the 3-part
  # shape release.yml derives from build/v<X.Y.Z> tags.
  prepare:
    if: >-
      github.repository != 'WSJTX/wsjtx' ||
      github.event_name != 'push' ||
      !startsWith(github.ref, 'refs/heads/release/')
    runs-on: ubuntu-latest
    timeout-minutes: 10
    outputs:
      version: ${{ steps.v.outputs.version }}
      linux_image_tag: ${{ steps.linux-image.outputs.image_tag }}
      armhf_image_tag: ${{ steps.armhf-image.outputs.image_tag }}
      save_linux_ccache: ${{ steps.ccache-policy.outputs.save_ccache }}
      build_linux_packages: ${{ steps.packaging-policy.outputs.build_packages }}
    steps:
      - uses: actions/checkout@v7
      - name: Validate workflow job timeouts
        run: .github/scripts/validate-workflow-timeouts.py
      - name: Run CI policy self-tests
        run: |
          .github/scripts/validate-ci-inputs.sh --self-test
          .github/scripts/is-linux-ci-image-input.sh --self-test
          .github/scripts/select-ccache-key-suffix.sh --self-test
          .github/scripts/select-linux-ccache-save.sh --self-test
          .github/scripts/select-linux-packaging.sh --self-test
          .github/scripts/test-linux-ccache-compiler-signature.sh
          .github/scripts/test-verify-linux-ci-image.sh
          python3 -m unittest discover -s .github/scripts/tests -p 'test_*.py'
      - id: v
        run: |
          STATE=$(python3 .github/scripts/release-policy.py read-state)
          VERSION=$(jq -r .version <<<"$STATE")
          echo "Derived version from release-state.txt: $VERSION"
          echo "version=$VERSION" >> "$GITHUB_OUTPUT"
      # PRs can consume develop caches, so only trusted develop executions may
      # publish the Linux cache shared with later pull-request builds.
      - id: ccache-policy
        name: Select Linux ccache save policy
        env:
          EVENT_NAME: ${{ github.event_name }}
          REQUEST_SAVE_CCACHE: ${{ inputs.save_ccache || false }}
          RECACHE: ${{ inputs.recache || false }}
        run: .github/scripts/select-linux-ccache-save.sh
      # Routine PRs and develop pushes build and test without packaging.
      # Full CI, manual runs, and release-branch pushes also validate packages.
      - id: packaging-policy
        name: Select Linux packaging policy
        env:
          EVENT_NAME: ${{ github.event_name }}
          FULL_CI: ${{ contains(github.event.pull_request.labels.*.name, 'full-ci') }}
        run: .github/scripts/select-linux-packaging.sh
      - id: linux-image
        name: Resolve Linux CI image generation
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: .github/scripts/resolve-linux-ci-image-tag.py
      - id: armhf-image
        name: Resolve ARMHF CI image generation
        if: >-
          github.event_name == 'workflow_dispatch' ||
          contains(github.event.pull_request.labels.*.name, 'full-ci')
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          REQUESTED_TAG: ${{ inputs.armhf_image_tag || '' }}
        run: |
          if [[ -n "$REQUESTED_TAG" ]]; then
            echo "Using requested ARMHF CI image generation: $REQUESTED_TAG"
            echo "image_tag=$REQUESTED_TAG" >> "$GITHUB_OUTPUT"
          else
            RESOLVE_ARMHF=true .github/scripts/resolve-linux-ci-image-tag.py
          fi

  # Two-tier CI to conserve Actions minutes. The default path runs one Linux
  # x86_64 smoke leg; sanitizer and broader platform coverage are opt-in.
  #
  #   * Default (every push / PR to develop): Linux x86_64 only -- `linux`.
  #   * ASan + UBSan: runs on PRs carrying `sanitizers` or `full-ci`.
  #   * TSan: runs only on PRs carrying `thread-sanitizer`.
  #   * Opt-in matrix (`linux-arm`, `linux-armhf`, macos, macos-intel, windows): runs when a
  #     PR carries the `full-ci` label, or when the workflow is started manually
  #     ("Run workflow" / workflow_dispatch). Release builds are unaffected --
  #     they run the full matrix via release.yml on build/v* tags.
  #
  # Every non-prepare leg also `needs: linux`, so a break that fails
  # everywhere fails fast on the cheapest runner before any costly leg
  # starts, instead of burning them in parallel. `prepare` stays in `needs`
  # for its version output.
  macos:
    needs: [prepare, linux]
    # Opt-in only -- see the two-tier note above.
    if: >-
      github.event_name == 'workflow_dispatch' ||
      contains(github.event.pull_request.labels.*.name, 'full-ci')
    uses: ./.github/workflows/build-macos.yml
    with:
      version: ${{ needs.prepare.outputs.version }}
      hamlib_branch: "4.7.2"
      arch: "arm64"
      runner: "macos-15"
      deployment_target: "11.0"
      recache: ${{ inputs.recache || false }}

  macos-intel:
    needs: [prepare, linux]
    # Opt-in only -- see the two-tier note above.
    if: >-
      github.event_name == 'workflow_dispatch' ||
      contains(github.event.pull_request.labels.*.name, 'full-ci')
    uses: ./.github/workflows/build-macos.yml
    with:
      version: ${{ needs.prepare.outputs.version }}
      hamlib_branch: "4.7.2"
      arch: "x86_64"
      runner: "macos-15-intel"
      deployment_target: "10.13"
      recache: ${{ inputs.recache || false }}

  linux:
    needs: [prepare]
    uses: ./.github/workflows/build-linux.yml
    with:
      version: ${{ needs.prepare.outputs.version }}
      hamlib_branch: "4.7.2"
      arch: "x86_64"
      image_tag: ${{ needs.prepare.outputs.linux_image_tag }}
      allow_stale_image: true
      recache: ${{ inputs.recache || false }}
      save_ccache: ${{ needs.prepare.outputs.save_linux_ccache == 'true' }}
      validate_fortran_fallback: ${{ github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'full-ci') }}
      build_packages: ${{ needs.prepare.outputs.build_linux_packages == 'true' }}
    secrets: inherit

  linux-sanitizers:
    name: Linux x86_64 ASan + UBSan
    needs: [prepare, linux]
    if: >-
      contains(github.event.pull_request.labels.*.name, 'full-ci') ||
      contains(github.event.pull_request.labels.*.name, 'sanitizers')
    uses: ./.github/workflows/build-linux-sanitizers.yml
    with:
      hamlib_branch: "4.7.2"
      sanitizer: asan-ubsan
      image_tag: ${{ needs.prepare.outputs.linux_image_tag }}
      allow_stale_image: true
      recache: ${{ inputs.recache || false }}
      advisory: true

  linux-tsan:
    name: Linux x86_64 TSan
    needs: [prepare, linux]
    if: contains(github.event.pull_request.labels.*.name, 'thread-sanitizer')
    uses: ./.github/workflows/build-linux-sanitizers.yml
    with:
      hamlib_branch: "4.7.2"
      sanitizer: tsan
      recache: ${{ inputs.recache || false }}
      advisory: true

  linux-arm:
    needs: [prepare, linux]
    # Opt-in only -- see the two-tier note above.
    if: >-
      github.event_name == 'workflow_dispatch' ||
      contains(github.event.pull_request.labels.*.name, 'full-ci')
    uses: ./.github/workflows/build-linux.yml
    with:
      version: ${{ needs.prepare.outputs.version }}
      hamlib_branch: "4.7.2"
      arch: "aarch64"
      image_tag: ${{ needs.prepare.outputs.linux_image_tag }}
      allow_stale_image: true
      recache: ${{ inputs.recache || false }}
      save_ccache: ${{ needs.prepare.outputs.save_linux_ccache == 'true' }}
      build_packages: ${{ needs.prepare.outputs.build_linux_packages == 'true' }}
    secrets: inherit

  linux-armhf:
    needs: [prepare, linux]
    # Opt-in only, like the other targets beyond Linux x86_64.
    if: >-
      github.event_name == 'workflow_dispatch' ||
      contains(github.event.pull_request.labels.*.name, 'full-ci')
    uses: ./.github/workflows/build-linux.yml
    with:
      version: ${{ needs.prepare.outputs.version }}
      hamlib_branch: "4.7.2"
      arch: "armhf"
      image_tag: ${{ needs.prepare.outputs.armhf_image_tag }}
      allow_stale_image: true
      recache: ${{ inputs.recache || false }}
      save_ccache: ${{ needs.prepare.outputs.save_linux_ccache == 'true' }}
      build_packages: ${{ needs.prepare.outputs.build_linux_packages == 'true' }}
    secrets: inherit

  windows:
    needs: [prepare, linux]
    # Opt-in only -- see the two-tier note above.
    if: >-
      github.event_name == 'workflow_dispatch' ||
      contains(github.event.pull_request.labels.*.name, 'full-ci')
    uses: ./.github/workflows/build-windows.yml
    with:
      version: ${{ needs.prepare.outputs.version }}
      hamlib_branch: "4.7.2"
      recache: ${{ inputs.recache || false }}