summaryrefslogtreecommitdiff
path: root/.github/workflows/build-linux.yml
blob: 38b55845d0d7a97b81d2c81303fb4902e0451877 (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
name: Build Linux

on:
  workflow_call:
    inputs:
      version:
        description: "WSJT-X version string"
        required: true
        type: string
      hamlib_branch:
        description: "Hamlib branch to build"
        required: false
        type: string
        default: "4.7.0"
      arch:
        description: "Linux target architecture: x86_64 or aarch64"
        required: false
        type: string
        default: "x86_64"

jobs:
  build:
    runs-on: ${{ inputs.arch == 'aarch64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
    steps:
      - uses: actions/checkout@v6

      - name: Install dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y \
            build-essential cmake gfortran \
            libfftw3-dev libboost-all-dev \
            qtbase5-dev qttools5-dev qtmultimedia5-dev libqt5serialport5-dev \
            libqt5sql5-sqlite libqt5websockets5-dev \
            libqt5multimedia5-plugins \
            libusb-1.0-0-dev libudev-dev libreadline-dev \
            autoconf automake libtool pkg-config \
            texinfo \
            dpkg-dev fakeroot \
            asciidoctor \
            rpm

      - name: Cache pFUnit
        id: pfunit-cache
        uses: actions/cache@v5
        with:
          path: pfunit-prefix
          key: pfunit-linux-${{ inputs.arch }}-v4.9.0-${{ hashFiles('.github/workflows/build-linux.yml') }}

      - name: Build pFUnit
        if: steps.pfunit-cache.outputs.cache-hit != 'true'
        run: |
          git clone --depth 1 --branch v4.9.0 --recursive \
            https://github.com/Goddard-Fortran-Ecosystem/pFUnit.git pfunit-src
          cmake -S pfunit-src -B pfunit-build \
            -DSKIP_MPI=YES \
            -DSKIP_OPENMP=YES \
            -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
            -DCMAKE_INSTALL_PREFIX="${GITHUB_WORKSPACE}/pfunit-prefix"
          cmake --build pfunit-build -j$(nproc)
          cmake --install pfunit-build

      - name: Locate pFUnit config
        id: pfunit
        run: |
          CONFIG=$(find "${GITHUB_WORKSPACE}/pfunit-prefix" -name PFUNITConfig.cmake | head -1)
          if [ -z "$CONFIG" ]; then
            echo "ERROR: PFUNITConfig.cmake not found under pfunit-prefix"
            find "${GITHUB_WORKSPACE}/pfunit-prefix" -maxdepth 3 -type d
            exit 1
          fi
          PFUNIT_DIR="$(dirname "$CONFIG")"
          echo "Found PFUNITConfig.cmake at: $CONFIG"
          echo "dir=${PFUNIT_DIR}" >> "$GITHUB_OUTPUT"

      - name: Cache Hamlib
        id: hamlib-cache
        uses: actions/cache@v5
        with:
          path: hamlib-prefix
          key: hamlib-linux-${{ inputs.arch }}-${{ inputs.hamlib_branch }}-${{ hashFiles('.github/workflows/build-linux.yml') }}

      - name: Build Hamlib
        if: steps.hamlib-cache.outputs.cache-hit != 'true'
        run: |
          git clone --depth 1 --branch "${{ inputs.hamlib_branch }}" \
            https://github.com/Hamlib/Hamlib.git hamlib-src
          cd hamlib-src
          ./bootstrap
          ./configure \
            --prefix="${GITHUB_WORKSPACE}/hamlib-prefix" \
            --disable-shared --enable-static \
            --without-cxx-binding \
            CFLAGS="-g -O2 -fPIC -fdata-sections -ffunction-sections" \
            LDFLAGS="-Wl,--gc-sections"
          make -j$(nproc)
          make install

      - name: Configure
        run: |
          cmake -S . -B wsjtx-build \
            -DCMAKE_PREFIX_PATH="${GITHUB_WORKSPACE}/hamlib-prefix;${GITHUB_WORKSPACE}/pfunit-prefix" \
            -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
            -DWSJT_SKIP_MANPAGES=ON \
            -DWSJT_BUILD_TESTS=ON \
            -DPFUNIT_DIR="${{ steps.pfunit.outputs.dir }}" \
            -Wno-dev

      - name: Build
        run: cmake --build wsjtx-build -j$(nproc)

      - name: Run tests
        id: ctest
        run: ctest --output-on-failure --output-junit ctest-results.xml
        working-directory: wsjtx-build
        env:
          QT_QPA_PLATFORM: offscreen

      - name: Publish test summary
        if: always() && steps.ctest.conclusion != 'skipped'
        working-directory: wsjtx-build
        run: python3 ../.github/scripts/publish-ctest-summary.py "Linux ${{ inputs.arch }}" >> "$GITHUB_STEP_SUMMARY"

      - name: Upload test results
        if: always() && steps.ctest.conclusion != 'skipped'
        uses: actions/upload-artifact@v7
        with:
          name: ctest-results-linux-${{ inputs.arch }}
          path: wsjtx-build/ctest-results.xml
          if-no-files-found: ignore

      - name: Verify binary
        run: |
          file wsjtx-build/jt9
          file wsjtx-build/jt9 | grep -q "ELF 64-bit"

      # CMakeLists.txt:1989-2012 enables CPack's DEB generator when
      # dpkg-buildpackage is on the path (provided by dpkg-dev, installed
      # above). The DEB generator ignores CPACK_PACKAGE_FILE_NAME and
      # uses its own CPACK_DEBIAN_FILE_NAME (default <pkg>_<ver>_<arch>.deb
      # → wsjtx_3.0.1_amd64.deb regardless). Override that variable to
      # align the filename with the AppImage/installer naming used by
      # the rest of the pipeline.
      - name: Package .deb
        env:
          VERSION: ${{ inputs.version }}
          ARCH: ${{ inputs.arch }}
        run: |
          cd wsjtx-build
          cpack -G DEB \
            -D "CPACK_DEBIAN_FILE_NAME=wsjtx-${VERSION}-linux-${ARCH}.deb"
          DEB="wsjtx-${VERSION}-linux-${ARCH}.deb"
          if [ ! -f "$DEB" ]; then
            echo "::error::cpack -G DEB produced no .deb at expected path: $DEB"
            ls -la *.deb 2>/dev/null || true
            exit 1
          fi
          ls -lh "$DEB"
          file "$DEB"
          dpkg-deb --info "$DEB" | head -20

      - name: Upload .deb
        uses: actions/upload-artifact@v7
        with:
          name: wsjtx-${{ inputs.version }}-linux-${{ inputs.arch }}-deb
          path: wsjtx-build/wsjtx-${{ inputs.version }}-linux-${{ inputs.arch }}.deb
          if-no-files-found: error

      # RPM builds via the same CPack scaffolding the .deb step above
      # uses. CMakeLists.txt:2014-2026 already auto-detects rpmbuild and
      # sets the Fedora-style dependency list (qt5-qtbase >= 5.9, fftw-
      # libs-single, boost-log, etc.); only the workflow side was
      # missing. `-G RPM` is explicit so this step doesn't accidentally
      # rebuild the .deb already produced above.
      - name: Package RPM
        working-directory: wsjtx-build
        run: |
          cpack -G RPM
          ls -lh *.rpm

      - name: Smoke-test RPM
        working-directory: wsjtx-build
        run: |
          RPM=$(ls *.rpm | head -1)
          echo "Querying $RPM"
          rpm -qpi "$RPM"
          rpm -qpR "$RPM"
          rpm -qpl "$RPM" | head -40
          # Confirm the core binaries are in the package.
          rpm -qpl "$RPM" | grep -qE '/bin/wsjtx$'
          rpm -qpl "$RPM" | grep -qE '/bin/jt9$'

      - name: Upload RPM
        uses: actions/upload-artifact@v7
        with:
          name: wsjtx-${{ inputs.version }}-linux-${{ inputs.arch }}-rpm
          path: wsjtx-build/*.rpm
          if-no-files-found: error

      - name: Install to AppDir
        run: |
          cmake --install wsjtx-build --prefix "${GITHUB_WORKSPACE}/AppDir/usr"
          # linuxdeploy's desktop/icon integration needs these exact paths.
          test -x AppDir/usr/bin/wsjtx
          test -x AppDir/usr/bin/jt9
          test -x AppDir/usr/bin/ft8code
          test -f AppDir/usr/share/applications/wsjtx.desktop
          test -f AppDir/usr/share/pixmaps/wsjtx_icon.png

      - name: Package AppImage
        env:
          VERSION: ${{ inputs.version }}
          ARCH: ${{ inputs.arch }}
          # Core linuxdeploy is pinned to a dated release + SHA256 verify
          # so an undetected upstream change fails the build instead of
          # shipping. The Qt5 plugin stays on the rolling "continuous"
          # channel because upstream has not cut a dated release since
          # 1-alpha-20250213-1, which carries a filesystem_error bug on
          # ubuntu-24.04 / Qt5.15 (missing qt5/plugins/mediaservice dir).
          # When upstream publishes a newer dated plugin release, pin +
          # verify it here too.
          LINUXDEPLOY_TAG: "1-alpha-20251107-1"
        run: |
          case "$ARCH" in
            x86_64)  LINUXDEPLOY_SHA256="c20cd71e3a4e3b80c3483cef793cda3f4e990aca14014d23c544ca3ce1270b4d" ;;
            aarch64) LINUXDEPLOY_SHA256="620095110d693282b8ebeb244a95b5e911cf8f65f76c88b4b47d16ae6346fcff" ;;
            *)       echo "::error::Unknown linuxdeploy arch: $ARCH"; exit 1 ;;
          esac
          curl -fsSL -o linuxdeploy.AppImage \
            "https://github.com/linuxdeploy/linuxdeploy/releases/download/${LINUXDEPLOY_TAG}/linuxdeploy-${ARCH}.AppImage"
          curl -fsSL -o linuxdeploy-plugin-qt.AppImage \
            "https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-${ARCH}.AppImage"
          echo "${LINUXDEPLOY_SHA256}  linuxdeploy.AppImage" | sha256sum -c -
          chmod +x linuxdeploy.AppImage linuxdeploy-plugin-qt.AppImage

          # --appimage-extract-and-run avoids FUSE on the hosted runner.
          export OUTPUT="wsjtx-${VERSION}-linux-${ARCH}.AppImage"
          ./linuxdeploy.AppImage --appimage-extract-and-run \
            --appdir AppDir \
            --plugin qt \
            --output appimage \
            --desktop-file AppDir/usr/share/applications/wsjtx.desktop \
            --icon-file AppDir/usr/share/pixmaps/wsjtx_icon.png

          ls -lh "$OUTPUT"
          file "$OUTPUT"

      - name: Smoke-test AppImage payload
        env:
          VERSION: ${{ inputs.version }}
          ARCH: ${{ inputs.arch }}
        run: |
          APPIMAGE="wsjtx-${VERSION}-linux-${ARCH}.AppImage"
          ./"$APPIMAGE" --appimage-extract >/dev/null
          test -x squashfs-root/usr/bin/wsjtx
          test -x squashfs-root/usr/bin/jt9
          test -x squashfs-root/usr/bin/ft8code
          test -x squashfs-root/usr/bin/wsprd
          file squashfs-root/usr/bin/wsjtx | grep -q "ELF 64-bit"
          # Qt5 libs should have been bundled by linuxdeploy-plugin-qt.
          ls squashfs-root/usr/lib/ | grep -q "^libQt5Core\.so"
          ls squashfs-root/usr/lib/ | grep -q "^libQt5Widgets\.so"
          ls squashfs-root/usr/lib/ | grep -q "^libQt5Multimedia\.so"
          # Verify Qt audio backend plugins were bundled. Without them,
          # QAudioDeviceInfo::availableDevices() returns empty at runtime
          # and the user sees "no audio devices" — observed in v3.0.1 on
          # Linux Lite. linuxdeploy-plugin-qt only WARNS when these are
          # absent on the build host, it doesn't fail.
          # Linux shared objects are conventionally `lib*.so` so the
          # bundled plugins are libqtaudio_alsa.so and libqtmedia_pulse.so.
          audio_plugins=$(find squashfs-root -path '*/plugins/audio/*.so' 2>/dev/null)
          if [ -z "$audio_plugins" ]; then
            echo "::error::No Qt audio backend plugins (qtaudio_alsa/qtaudio_pulse) bundled in AppImage."
            echo "::error::Install libqt5multimedia5-plugins on the build host so linuxdeploy-plugin-qt can find them."
            echo "AppImage plugin tree:"
            find squashfs-root -path '*/plugins/*' -name '*.so' 2>/dev/null | head -20
            exit 1
          fi
          echo "Qt audio plugins bundled:"
          echo "$audio_plugins"
          rm -rf squashfs-root

      - name: Upload AppImage
        uses: actions/upload-artifact@v7
        with:
          name: wsjtx-${{ inputs.version }}-linux-${{ inputs.arch }}-AppImage
          path: wsjtx-${{ inputs.version }}-linux-${{ inputs.arch }}.AppImage
          if-no-files-found: error

      - name: Upload build artifacts
        uses: actions/upload-artifact@v7
        with:
          name: wsjtx-${{ inputs.version }}-linux-${{ inputs.arch }}
          path: |
            wsjtx-build/jt9
            wsjtx-build/wsprd
            wsjtx-build/wsjtx