diff options
| author | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:03 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:03 +0200 |
| commit | 059831534c7e884f0a607ed86b582fd00d821731 (patch) | |
| tree | 76bcb67a78f8aa2654fd34c2ad801a62136b0170 /.github | |
| parent | d83a420f0517d7fc47aeb288a6a0cf4891784fcc (diff) | |
New upstream version 3.2.0~rc1+dfsgupstream/3.2.0_rc1+dfsg
Diffstat (limited to '.github')
97 files changed, 13269 insertions, 1552 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..131106dc --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,44 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**WSJT-X Version** +What version manifests this behavior? +- [ ] WSJT-X 2.7 +- [ ] WSJT-X 3.0.0-rc1 + +**Operating System** +What Operating System, Version, CPU (if applicable) are you using (e.g. Windows 11, MacOs 15.7/M1, Linux Debian 13) + +**What Radio and interface?** +(e.g. Elecraft K3s via USB, Flex 6400 tcpip, QDX+ via USB) + +**Does this happen WITHOUT Transmitting?** +Yes/No + +**Does this happen when transmitting with ZERO power output?** +Yes/No + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. PLEASE, PLEASE, PLEASE use a screenshot tool intead of a phone picture. Windows: Use the Windows Snipping Tool + +**Additional context** +Add any other context about the problem here. For example, if being used with N1MM Logger+, or JTAlert, information about those versions. diff --git a/.github/actions/build-linux-payload/action.yml b/.github/actions/build-linux-payload/action.yml new file mode 100644 index 00000000..f5ce1e0b --- /dev/null +++ b/.github/actions/build-linux-payload/action.yml @@ -0,0 +1,457 @@ +name: "Build Linux payload" +description: >- + Build and test wsjtx for one Linux architecture, with optional package and + artifact production. The caller decides job-container versus explicit Docker + execution; this action runs the shared native pipeline. + +inputs: + arch: + description: "Native Linux target architecture: x86_64 or aarch64" + required: true + version: + description: "WSJT-X version string" + required: true + hamlib_branch: + description: "Hamlib branch to build" + required: true + runtime_base: + description: >- + Runtime profile used to select the GCC 13.4 Bookworm toolchain. + required: false + default: "host" + recache: + description: "Manual ccache refresh; ordinary source changes do not enable it" + required: false + default: "false" + save_ccache: + description: "Save compiled objects for trusted builds" + required: false + default: "false" + validate_fortran_fallback: + description: "Build the x86_64 non-OpenMP common-library sentinel graph" + required: false + default: "false" + build_packages: + description: "Build, validate, and upload Linux packages and executable artifacts" + required: false + default: "true" + release_channel: + description: "Build release channel: DEVEL, RC, or GA" + required: false + default: "DEVEL" + rc_number: + description: "Release candidate number when release_channel is RC" + required: false + default: "" + allow_stale_image: + description: "Allow a previously promoted image when a dependency refresh changed the recipe" + required: false + default: "false" + +runs: + using: "composite" + steps: + - name: Validate workflow inputs + shell: bash + env: + WSJTX_VERSION: ${{ inputs.version }} + HAMLIB_BRANCH: ${{ inputs.hamlib_branch }} + WSJT_RELEASE_CHANNEL: ${{ inputs.release_channel }} + WSJT_RC_NUMBER: ${{ inputs.rc_number }} + ARCH: ${{ inputs.arch }} + VALIDATE_FORTRAN_FALLBACK: ${{ inputs.validate_fortran_fallback }} + run: .github/scripts/validate-ci-inputs.sh + + - name: Verify Linux CI image + id: image + shell: bash + env: + WSJTX_CI_IMAGE_ALLOW_RECIPE_MISMATCH: ${{ inputs.allow_stale_image }} + run: >- + .github/scripts/verify-linux-ci-image.sh + normal "${{ inputs.arch }}" "${{ inputs.hamlib_branch }}" + + - name: Select Noble toolchain + if: inputs.runtime_base == 'host' + shell: bash + run: | + { + echo "CC=gcc" + echo "CXX=g++" + echo "FC=gfortran" + } >> "$GITHUB_ENV" + + - name: Select GCC 13.4 Bookworm toolchain + if: inputs.runtime_base == 'bookworm-gcc13.4' + shell: bash + run: | + CC=/usr/local/bin/gcc + CXX=/usr/local/bin/g++ + FC=/usr/local/bin/gfortran + + for compiler in "$CC" "$CXX" "$FC"; do + if [ ! -x "$compiler" ]; then + echo "::error::Expected compiler not found at $compiler" + exit 1 + fi + version=$("$compiler" -dumpfullversion -dumpversion) + echo "$compiler: $version" + if [ "$version" != "13.4.0" ]; then + echo "::error::Expected GCC 13.4.0, found $version at $compiler" + exit 1 + fi + done + + echo "CC=$CC" >> "$GITHUB_ENV" + echo "CXX=$CXX" >> "$GITHUB_ENV" + echo "FC=$FC" >> "$GITHUB_ENV" + + # Run-unique keys let a refreshed archive become the newest prefix match + # even when an immutable cache already exists for the same commit SHA. + - name: Select ccache key + id: ccache-key + shell: bash + env: + RECACHE: ${{ inputs.recache }} + run: .github/scripts/select-ccache-key-suffix.sh + + - name: Restore ccache + id: ccache + uses: actions/cache/restore@v5 + with: + path: .ccache + key: ccache-linux-${{ inputs.arch }}-${{ steps.image.outputs.ccache_compatibility_id }}-${{ steps.image.outputs.generation }}-${{ github.sha }}${{ steps.ccache-key.outputs.suffix }} + restore-keys: | + ccache-linux-${{ inputs.arch }}-${{ steps.image.outputs.ccache_compatibility_id }}-${{ steps.image.outputs.generation }}- + ccache-linux-${{ inputs.arch }}-${{ steps.image.outputs.ccache_compatibility_id }}- + + - name: Configure ccache + shell: bash + run: | + export CCACHE_DIR="${GITHUB_WORKSPACE}/.ccache" + export CCACHE_COMPILERCHECK="${{ steps.image.outputs.ccache_compiler_check }}" + { + echo "CCACHE_DIR=$CCACHE_DIR" + echo "CCACHE_COMPILERCHECK=$CCACHE_COMPILERCHECK" + } >> "$GITHUB_ENV" + echo "ccache recache: ${{ inputs.recache }}" + if [ "${{ inputs.recache }}" = "true" ]; then + echo "CCACHE_RECACHE=1" >> "$GITHUB_ENV" + echo "Forcing ccache recache for this run" + fi + mkdir -p "${GITHUB_WORKSPACE}/.ccache" + ccache --version + ccache --show-config + ccache --zero-stats + + # Exercise the public CMake default without duplicating its compile graph. + # AUTO resolves to BOTH on the OpenMP-capable Linux x86_64 toolchain. + - name: Configure default Fortran graph + if: inputs.arch == 'x86_64' + shell: bash + run: | + cmake -S . -B cfgmatrix-default \ + -DCMAKE_PREFIX_PATH="${{ steps.image.outputs.hamlib_prefix }};/opt/wsjtx/pfunit" \ + -DWSJT_SKIP_MANPAGES=ON \ + -DPFUNIT_DIR="${{ steps.image.outputs.pfunit_dir }}" \ + -Wno-dev + + - name: Configure build and tests + shell: bash + env: + WSJT_RELEASE_CHANNEL: ${{ inputs.release_channel }} + WSJT_RC_NUMBER: ${{ inputs.rc_number }} + run: | + cmake -S . -B wsjtx-build \ + -DCMAKE_PREFIX_PATH="${{ steps.image.outputs.hamlib_prefix }};/opt/wsjtx/pfunit" \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DWSJT_SKIP_MANPAGES=ON \ + -DWSJT_ENABLE_TESTS=ON \ + -DWSJT_ENABLE_GUI_SMOKE_TESTS=ON \ + -DWSJT_FORTRAN_LIBRARY_VARIANTS=OPENMP_ONLY \ + -DWSJT_RELEASE_CHANNEL="${WSJT_RELEASE_CHANNEL}" \ + -DWSJT_RC_NUMBER="${WSJT_RC_NUMBER}" \ + -DPFUNIT_DIR="${{ steps.image.outputs.pfunit_dir }}" \ + -Wno-dev + + - name: Build and test targets + shell: bash + run: cmake --build wsjtx-build -j$(nproc) + + - name: Show ccache stats + if: always() + shell: bash + run: ccache --show-stats + + # MAP65 retains target-local OpenMP while the shared WSJT Fortran library + # uses its serial variant. Run this fallback graph only on the native leg. + - name: Build non-OpenMP common-library sentinels + if: inputs.arch == 'x86_64' && inputs.validate_fortran_fallback == 'true' + shell: bash + run: | + cmake -S . -B cfgmatrix-NON_OPENMP_ONLY \ + -DCMAKE_PREFIX_PATH="${{ steps.image.outputs.hamlib_prefix }};/opt/wsjtx/pfunit" \ + -DWSJT_SKIP_MANPAGES=ON \ + -DWSJT_FORTRAN_LIBRARY_VARIANTS=NON_OPENMP_ONLY \ + -DPFUNIT_DIR="${{ steps.image.outputs.pfunit_dir }}" \ + -Wno-dev + cmake --build cfgmatrix-NON_OPENMP_ONLY \ + --target jt65sim m65impl qmap_impl test_jtty_pack \ + -j$(nproc) + + - name: Run tests + id: ctest + shell: bash + run: xvfb-run -a -s "-screen 0 1280x1024x24" ctest --parallel 3 --output-on-failure --output-junit ctest-results.xml + working-directory: wsjtx-build + env: + QT_QPA_PLATFORM: xcb + + - name: Publish test summary + if: always() && steps.ctest.conclusion != 'skipped' + shell: bash + 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 + shell: bash + env: + ARCH: ${{ inputs.arch }} + run: | + source .github/scripts/linux-artifact-validation.sh + validate_linux_build_executables wsjtx-build "$ARCH" + + # 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 + if: inputs.build_packages == 'true' + shell: bash + 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" + # sed instead of `| head -20` so dpkg-deb doesn't get SIGPIPE'd by + # head's early close — interacts badly with `bash -o pipefail` under + # Bookworm's dpkg-deb (observed exit 141 on first container run). + dpkg-deb --info "$DEB" | sed -n '1,20p' + source ../.github/scripts/linux-artifact-validation.sh + validate_deb_package "$DEB" + + - name: Upload .deb + if: inputs.build_packages == 'true' + 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 + compression-level: 0 + + # 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 + if: inputs.build_packages == 'true' + shell: bash + working-directory: wsjtx-build + run: | + cpack -G RPM + ls -lh *.rpm + + - name: Smoke-test RPM + if: inputs.build_packages == 'true' + shell: bash + working-directory: wsjtx-build + run: | + rpms=(*.rpm) + RPM=${rpms[0]} + echo "Querying $RPM" + rpm -qpi "$RPM" + rpm -qpR "$RPM" + source ../.github/scripts/linux-artifact-validation.sh + validate_rpm_package "$RPM" + + - name: Upload RPM + if: inputs.build_packages == 'true' + uses: actions/upload-artifact@v7 + with: + name: wsjtx-${{ inputs.version }}-linux-${{ inputs.arch }}-rpm + path: wsjtx-build/*.rpm + if-no-files-found: error + compression-level: 0 + + - name: Install to AppDir + if: inputs.build_packages == 'true' + shell: bash + env: + ARCH: ${{ inputs.arch }} + run: | + cmake --install wsjtx-build --prefix "${GITHUB_WORKSPACE}/AppDir/usr" + source .github/scripts/linux-artifact-validation.sh + validate_linux_application_tree AppDir appdir "$ARCH" + + - name: Package AppImage + if: inputs.build_packages == 'true' + shell: bash + env: + VERSION: ${{ inputs.version }} + ARCH: ${{ inputs.arch }} + # Core linuxdeploy is pinned to a dated release. 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. + LINUXDEPLOY_TAG: "1-alpha-20251107-1" + # Force every AppImage spawned by linuxdeploy (the qt plugin and + # appimagetool, both invoked as AppImages internally) to use + # `--appimage-extract-and-run` instead of expecting FUSE to be + # available. The host runner has libfuse2 installed by default so + # the plain `./linuxdeploy.AppImage --appimage-extract-and-run` + # was enough for x86_64; the Bookworm container has no FUSE and the + # plugin AppImage's first call (`--plugin-api-version`) exits 127 + # without this env var. APPIMAGE_EXTRACT_AND_RUN=1 is the + # AppImage runtime's documented FUSE-less escape hatch. + APPIMAGE_EXTRACT_AND_RUN: "1" + run: | + curl_flags=(--fail --show-error --silent --location --retry 5 --retry-delay 5) + github_api_token='${{ github.token }}' + github_api_curl() { + local api_headers=(-H "User-Agent: wsjtx-ci") + if [ -n "$github_api_token" ]; then + api_headers+=(-H "Authorization: Bearer ${github_api_token}") + env GITHUB_TOKEN="$github_api_token" curl "${curl_flags[@]}" "${api_headers[@]}" "$@" + else + curl "${curl_flags[@]}" "${api_headers[@]}" "$@" + fi + } + case "$ARCH" in + x86_64) + LINUXDEPLOY_SHA256="c20cd71e3a4e3b80c3483cef793cda3f4e990aca14014d23c544ca3ce1270b4d" + ;; + aarch64) + LINUXDEPLOY_SHA256="620095110d693282b8ebeb244a95b5e911cf8f65f76c88b4b47d16ae6346fcff" + ;; + *) echo "::error::Unknown linuxdeploy arch: $ARCH"; exit 1 ;; + esac + + QT_PLUGIN_ASSET_NAME="linuxdeploy-plugin-qt-${ARCH}.AppImage" + QT_PLUGIN_ASSET_ID="$( + github_api_curl -H "Accept: application/vnd.github+json" \ + "https://api.github.com/repos/linuxdeploy/linuxdeploy-plugin-qt/releases/tags/continuous" | + python3 -c 'import json, sys; name = sys.argv[1]; matches = [asset for asset in json.load(sys.stdin)["assets"] if asset["name"] == name]; print(matches[0]["id"]) if matches else sys.exit("asset not found: " + name)' "$QT_PLUGIN_ASSET_NAME" + )" + + # Resolve the current asset ID because the Qt plugin intentionally + # follows upstream's rolling continuous release. + curl "${curl_flags[@]}" -o linuxdeploy.AppImage \ + "https://github.com/linuxdeploy/linuxdeploy/releases/download/${LINUXDEPLOY_TAG}/linuxdeploy-${ARCH}.AppImage" + github_api_curl -H "Accept: application/octet-stream" -o linuxdeploy-plugin-qt.AppImage \ + "https://api.github.com/repos/linuxdeploy/linuxdeploy-plugin-qt/releases/assets/${QT_PLUGIN_ASSET_ID}" + echo "${LINUXDEPLOY_SHA256} linuxdeploy.AppImage" | sha256sum -c - + chmod +x linuxdeploy.AppImage linuxdeploy-plugin-qt.AppImage + + # --appimage-extract-and-run on linuxdeploy itself + the env-var + # above on every child AppImage means the whole pipeline runs + # FUSE-free. + export OUTPUT="wsjtx-${VERSION}-linux-${ARCH}.AppImage" + env -u GITHUB_TOKEN ./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 + if: inputs.build_packages == 'true' + shell: bash + env: + VERSION: ${{ inputs.version }} + ARCH: ${{ inputs.arch }} + run: | + APPIMAGE="wsjtx-${VERSION}-linux-${ARCH}.AppImage" + ./"$APPIMAGE" --appimage-extract >/dev/null + source .github/scripts/linux-artifact-validation.sh + validate_linux_application_tree squashfs-root appimage "$ARCH" + rm -rf squashfs-root + + - name: Runtime-smoke-test AppImage + if: inputs.build_packages == 'true' + id: appimage_runtime_smoke + shell: bash + env: + VERSION: ${{ inputs.version }} + ARCH: ${{ inputs.arch }} + run: | + APPIMAGE="wsjtx-${VERSION}-linux-${ARCH}.AppImage" + LOG="wsjtx-build/appimage-startup-smoke.log" + source .github/scripts/linux-artifact-validation.sh + run_packaged_appimage_startup_smoke "./$APPIMAGE" "$LOG" + + - name: Upload AppImage startup diagnostics + if: inputs.build_packages == 'true' && failure() && steps.appimage_runtime_smoke.outcome == 'failure' + uses: actions/upload-artifact@v7 + with: + name: wsjtx-startup-smoke-linux-${{ inputs.arch }} + path: wsjtx-build/appimage-startup-smoke.log + if-no-files-found: ignore + retention-days: 7 + + - name: Upload AppImage + if: inputs.build_packages == 'true' + 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 + compression-level: 0 + + - name: Upload build artifacts + if: inputs.build_packages == 'true' + uses: actions/upload-artifact@v7 + with: + name: wsjtx-${{ inputs.version }}-linux-${{ inputs.arch }} + path: | + wsjtx-build/jt9 + wsjtx-build/wsprd + wsjtx-build/wsjtx + + - name: Report suppressed ccache save + if: inputs.save_ccache == 'true' && steps.image.outputs.recipe_match != 'true' + shell: bash + run: echo "::notice::Not saving ccache because this build used a stale Linux CI image recipe" + + - name: Save ccache + if: inputs.save_ccache == 'true' && steps.image.outputs.recipe_match == 'true' && steps.ccache.outputs.cache-hit != 'true' + uses: actions/cache/save@v5 + with: + path: .ccache + key: ${{ steps.ccache.outputs.cache-primary-key }} diff --git a/.github/actions/build-linux-sanitizers/action.yml b/.github/actions/build-linux-sanitizers/action.yml new file mode 100644 index 00000000..a9a6de6e --- /dev/null +++ b/.github/actions/build-linux-sanitizers/action.yml @@ -0,0 +1,277 @@ +name: "Build Linux sanitizers" +description: >- + Build and test WSJT-X with GCC sanitizers on Linux x86_64. + +inputs: + hamlib_branch: + description: "Hamlib branch to build" + required: true + sanitizer: + description: "Sanitizer mode: asan-ubsan or tsan" + required: false + default: "asan-ubsan" + recache: + description: "Force ccache to recompile and refresh cached objects" + required: false + default: "false" + save_ccache: + description: "Save compiled objects for trusted builds" + required: false + default: "false" + allow_stale_image: + description: "Allow a previously promoted image when a dependency refresh changed the recipe" + required: false + default: "false" + +runs: + using: "composite" + steps: + - name: Validate workflow inputs + shell: bash + env: + HAMLIB_BRANCH: ${{ inputs.hamlib_branch }} + run: .github/scripts/validate-ci-inputs.sh + + - name: Resolve sanitizer configuration + id: sanitizer + shell: bash + env: + SANITIZER: ${{ inputs.sanitizer }} + run: | + case "$SANITIZER" in + asan-ubsan) + echo "build_dir=wsjtx-sanitizer-build" >> "$GITHUB_OUTPUT" + echo "ccache_dir=.ccache-sanitizers" >> "$GITHUB_OUTPUT" + echo "cache_key=asan-ubsan-gcc" >> "$GITHUB_OUTPUT" + echo "cmake_option=WSJT_ENABLE_ASAN_UBSAN" >> "$GITHUB_OUTPUT" + echo "summary_name=Linux x86_64 ASan + UBSan" >> "$GITHUB_OUTPUT" + echo "artifact_name=ctest-results-linux-x86_64-asan-ubsan" >> "$GITHUB_OUTPUT" + echo "asan_options=detect_leaks=0:detect_stack_use_after_return=1:halt_on_error=1:abort_on_error=1" >> "$GITHUB_OUTPUT" + echo "ubsan_options=halt_on_error=1:print_stacktrace=1" >> "$GITHUB_OUTPUT" + echo "tsan_options=" >> "$GITHUB_OUTPUT" + ;; + tsan) + echo "build_dir=wsjtx-tsan-build" >> "$GITHUB_OUTPUT" + echo "ccache_dir=.ccache-tsan" >> "$GITHUB_OUTPUT" + echo "cache_key=tsan-gcc" >> "$GITHUB_OUTPUT" + echo "cmake_option=WSJT_ENABLE_TSAN" >> "$GITHUB_OUTPUT" + echo "summary_name=Linux x86_64 TSan" >> "$GITHUB_OUTPUT" + echo "artifact_name=ctest-results-linux-x86_64-tsan" >> "$GITHUB_OUTPUT" + echo "asan_options=" >> "$GITHUB_OUTPUT" + echo "ubsan_options=" >> "$GITHUB_OUTPUT" + tsan_suppressions="${GITHUB_WORKSPACE}/tests/sanitizers/tsan.supp" + if [ ! -f "$tsan_suppressions" ]; then + echo "::error::TSan suppressions file not found: $tsan_suppressions" + exit 1 + fi + echo "tsan_options=halt_on_error=0:second_deadlock_stack=1:suppressions=${tsan_suppressions}" >> "$GITHUB_OUTPUT" + ;; + *) + echo "::error::Unsupported sanitizer mode: $SANITIZER" + exit 1 + ;; + esac + + - name: Verify Linux CI image + id: image + shell: bash + env: + WSJTX_CI_IMAGE_ALLOW_RECIPE_MISMATCH: ${{ inputs.allow_stale_image }} + run: | + flavor=normal + if [ "${{ inputs.sanitizer }}" = tsan ]; then + flavor=tsan + fi + .github/scripts/verify-linux-ci-image.sh \ + "$flavor" x86_64 "${{ inputs.hamlib_branch }}" + + - name: Export TSan dependency environment + if: inputs.sanitizer == 'tsan' + shell: bash + run: | + { + echo "CC=gcc-13" + echo "CXX=g++-13" + echo "FC=gfortran-13" + echo "TSAN_QT_PREFIX=${{ steps.image.outputs.qt_prefix }}" + echo "TSAN_BOOST_PREFIX=${{ steps.image.outputs.boost_prefix }}" + echo "TSAN_HAMLIB_PREFIX=${{ steps.image.outputs.hamlib_prefix }}" + echo "TSAN_CMAKE_PREFIX_PATH=${{ steps.image.outputs.qt_prefix }};${{ steps.image.outputs.boost_prefix }};${{ steps.image.outputs.hamlib_prefix }}" + echo "LD_LIBRARY_PATH=${{ steps.image.outputs.qt_prefix }}/lib:${{ steps.image.outputs.boost_prefix }}/lib:${LD_LIBRARY_PATH:-}" + echo "PKG_CONFIG_PATH=${{ steps.image.outputs.qt_prefix }}/lib/pkgconfig:${{ steps.image.outputs.boost_prefix }}/lib/pkgconfig:${{ steps.image.outputs.hamlib_prefix }}/lib/pkgconfig:${PKG_CONFIG_PATH:-}" + echo "QT_PLUGIN_PATH=${{ steps.image.outputs.qt_prefix }}/plugins" + } >> "$GITHUB_ENV" + echo "${{ steps.image.outputs.qt_prefix }}/bin" >> "$GITHUB_PATH" + + - name: Select ccache key + id: ccache-key + shell: bash + env: + RECACHE: ${{ inputs.recache }} + run: .github/scripts/select-ccache-key-suffix.sh + + - name: Restore sanitizer objects + id: ccache + uses: actions/cache/restore@v5 + with: + path: ${{ steps.sanitizer.outputs.ccache_dir }} + key: ccache-linux-x86_64-${{ steps.sanitizer.outputs.cache_key }}-${{ steps.image.outputs.ccache_compatibility_id }}-${{ steps.image.outputs.generation }}-${{ github.sha }}${{ steps.ccache-key.outputs.suffix }} + restore-keys: | + ccache-linux-x86_64-${{ steps.sanitizer.outputs.cache_key }}-${{ steps.image.outputs.ccache_compatibility_id }}-${{ steps.image.outputs.generation }}- + ccache-linux-x86_64-${{ steps.sanitizer.outputs.cache_key }}-${{ steps.image.outputs.ccache_compatibility_id }}- + + - name: Configure ccache + shell: bash + run: | + export CCACHE_DIR="${GITHUB_WORKSPACE}/${{ steps.sanitizer.outputs.ccache_dir }}" + export CCACHE_COMPILERCHECK="${{ steps.image.outputs.ccache_compiler_check }}" + { + echo "CCACHE_DIR=$CCACHE_DIR" + echo "CCACHE_COMPILERCHECK=$CCACHE_COMPILERCHECK" + } >> "$GITHUB_ENV" + echo "ccache recache: ${{ inputs.recache }}" + if [ "${{ inputs.recache }}" = "true" ]; then + echo "CCACHE_RECACHE=1" >> "$GITHUB_ENV" + echo "Forcing ccache recache for this run" + fi + mkdir -p "$CCACHE_DIR" + ccache --version + ccache --show-config + ccache --zero-stats + + - name: Configure sanitizer build + shell: bash + run: | + prefix_path="${{ steps.image.outputs.hamlib_prefix }}" + compiler_args=() + boost_args=() + if [ "${{ inputs.sanitizer }}" = "tsan" ]; then + prefix_path="$TSAN_CMAKE_PREFIX_PATH" + compiler_args=( + -DCMAKE_C_COMPILER="$CC" + -DCMAKE_CXX_COMPILER="$CXX" + -DCMAKE_Fortran_COMPILER="$FC" + ) + boost_args=( + -DBOOST_ROOT="$TSAN_BOOST_PREFIX" + -DBoost_NO_SYSTEM_PATHS=ON + ) + fi + + cmake -S . -B "${{ steps.sanitizer.outputs.build_dir }}" \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DCMAKE_PREFIX_PATH="$prefix_path" \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ + -DWSJT_GENERATE_DOCS=OFF \ + -DWSJT_SKIP_MANPAGES=ON \ + -DWSJT_ENABLE_TESTS=ON \ + -DWSJT_ENABLE_GUI_SMOKE_TESTS=ON \ + -D${{ steps.sanitizer.outputs.cmake_option }}=ON \ + -DWSJT_BUILD_UTILS=OFF \ + -DWSJT_FORTRAN_LIBRARY_VARIANTS=OPENMP_ONLY \ + "${compiler_args[@]}" \ + "${boost_args[@]}" \ + -Wno-dev + + - name: Verify configured TSan dependency resolution + if: inputs.sanitizer == 'tsan' + shell: bash + run: >- + .github/scripts/verify-tsan-deps-linux.sh + "$TSAN_QT_PREFIX" + "$TSAN_BOOST_PREFIX" + "$TSAN_HAMLIB_PREFIX" + "${{ steps.sanitizer.outputs.build_dir }}/CMakeCache.txt" + + - name: Build sanitizer targets + shell: bash + run: cmake --build "${{ steps.sanitizer.outputs.build_dir }}" -j"$(nproc)" + + - name: Show ccache stats + if: always() + shell: bash + run: ccache --show-stats + + - name: Verify sanitizer instrumentation + shell: bash + run: >- + python3 .github/scripts/verify-sanitizer-instrumentation.py + "${{ steps.sanitizer.outputs.build_dir }}" + --sanitizer "${{ inputs.sanitizer }}" + + - name: Verify linked TSan dependency runtime + if: inputs.sanitizer == 'tsan' + shell: bash + run: >- + .github/scripts/verify-tsan-deps-linux.sh + "$TSAN_QT_PREFIX" + "$TSAN_BOOST_PREFIX" + "$TSAN_HAMLIB_PREFIX" + "${{ steps.sanitizer.outputs.build_dir }}/CMakeCache.txt" + "${{ steps.sanitizer.outputs.build_dir }}/wsjtx" + + - name: Prepare test scratch directory + shell: bash + run: mkdir -p "${GITHUB_WORKSPACE}/${{ steps.sanitizer.outputs.build_dir }}/tmp" + + - name: Run tests + id: ctest + continue-on-error: true + shell: bash + working-directory: ${{ steps.sanitizer.outputs.build_dir }} + env: + ASAN_OPTIONS: ${{ steps.sanitizer.outputs.asan_options }} + UBSAN_OPTIONS: ${{ steps.sanitizer.outputs.ubsan_options }} + TSAN_OPTIONS: ${{ steps.sanitizer.outputs.tsan_options }} + QT_QPA_PLATFORM: xcb + TMPDIR: ${{ github.workspace }}/${{ steps.sanitizer.outputs.build_dir }}/tmp + run: >- + xvfb-run -a -s "-screen 0 1280x1024x24" + ctest --parallel 1 --output-on-failure --output-junit ctest-results.xml + + - name: Publish test summary + if: always() && steps.ctest.outcome != 'skipped' + shell: bash + working-directory: ${{ steps.sanitizer.outputs.build_dir }} + run: >- + python3 ../.github/scripts/publish-ctest-summary.py + "${{ steps.sanitizer.outputs.summary_name }}" >> "$GITHUB_STEP_SUMMARY" + + - name: Upload test results + if: always() && steps.ctest.outcome != 'skipped' + uses: actions/upload-artifact@v7 + with: + name: ${{ steps.sanitizer.outputs.artifact_name }} + path: | + ${{ steps.sanitizer.outputs.build_dir }}/ctest-results.xml + ${{ steps.sanitizer.outputs.build_dir }}/Testing/Temporary/LastTest.log + ${{ steps.sanitizer.outputs.build_dir }}/Testing/Golden/test_jt9_mtd_ft8_210703_133430*/stderr.txt + if-no-files-found: ignore + + - name: Require sanitizer tests to pass + if: always() + shell: bash + run: | + failed=false + if [ "${{ steps.ctest.outcome }}" != "success" ]; then + echo "::error::CTest failed under ${{ steps.sanitizer.outputs.summary_name }}" + failed=true + fi + if [ "$failed" = "true" ]; then + exit 1 + fi + + - name: Report suppressed sanitizer ccache save + if: inputs.save_ccache == 'true' && steps.image.outputs.recipe_match != 'true' + shell: bash + run: echo "::notice::Not saving sanitizer ccache because this build used a stale Linux CI image recipe" + + - name: Save sanitizer objects + if: inputs.save_ccache == 'true' && steps.image.outputs.recipe_match == 'true' && steps.ccache.outputs.cache-hit != 'true' + uses: actions/cache/save@v5 + with: + path: ${{ steps.sanitizer.outputs.ccache_dir }} + key: ${{ steps.ccache.outputs.cache-primary-key }} diff --git a/.github/actions/build-windows-deps/action.yml b/.github/actions/build-windows-deps/action.yml new file mode 100644 index 00000000..9f1d2d07 --- /dev/null +++ b/.github/actions/build-windows-deps/action.yml @@ -0,0 +1,174 @@ +name: "Build Windows dependencies" +description: "Restore or populate Windows Boost, pFUnit, and Hamlib dependency caches." + +inputs: + boost_version: + description: "Boost version to build" + required: false + default: "1.91.0" + boost_source_sha256: + description: "Expected SHA-256 for the Boost source archive" + required: false + default: "de5e6b0e4913395c6bdfa90537febd9028ea4c0735d2cdb0cd9b45d5f51264f5" + windows_api_floor: + description: "Windows API floor used for Boost and WSJT-X builds" + required: false + default: "0x0601" + hamlib_branch: + description: "Hamlib branch to build" + required: true + save_caches: + description: "Whether to save dependency caches on misses" + required: false + default: "true" + +outputs: + boost_prefix: + description: "MSYS path to the Boost prefix" + value: ${{ steps.paths.outputs.boost_prefix }} + hamlib_prefix: + description: "MSYS path to the Hamlib prefix" + value: ${{ steps.paths.outputs.hamlib_prefix }} + pfunit_dir: + description: "Directory containing PFUNITConfig.cmake" + value: ${{ steps.pfunit.outputs.pfunit_dir }} + gftl_dir: + description: "Directory containing GFTLConfig.cmake" + value: ${{ steps.pfunit.outputs.gftl_dir }} + gftl_shared_dir: + description: "Directory containing GFTL_SHAREDConfig.cmake" + value: ${{ steps.pfunit.outputs.gftl_shared_dir }} + fargparse_dir: + description: "Directory containing FARGPARSEConfig.cmake" + value: ${{ steps.pfunit.outputs.fargparse_dir }} + +runs: + using: "composite" + steps: + - name: Validate workflow inputs + shell: bash + env: + HAMLIB_BRANCH: ${{ inputs.hamlib_branch }} + run: .github/scripts/validate-ci-inputs.sh + + - name: Resolve dependency prefixes + id: paths + shell: msys2 {0} + run: | + WORKSPACE=$(cygpath "${GITHUB_WORKSPACE}") + { + echo "boost_prefix=${WORKSPACE}/boost-prefix" + echo "hamlib_prefix=${WORKSPACE}/hamlib-prefix" + echo "pfunit_prefix=${WORKSPACE}/pfunit-prefix" + } >> "$GITHUB_OUTPUT" + + - name: Restore Boost cache + id: boost-cache + uses: actions/cache/restore@v6 + with: + path: boost-prefix + key: boost-windows-windows-latest-mingw64-${{ inputs.boost_version }}-${{ inputs.boost_source_sha256 }}-winapi${{ inputs.windows_api_floor }}-epoch1-${{ hashFiles('.github/scripts/build-boost-windows.sh') }} + + - name: Build Boost + if: steps.boost-cache.outputs.cache-hit != 'true' + shell: msys2 {0} + run: .github/scripts/build-boost-windows.sh "${{ inputs.boost_version }}" "${{ inputs.boost_source_sha256 }}" "${{ inputs.windows_api_floor }}" "${{ steps.paths.outputs.boost_prefix }}" + + - name: Save Boost cache + if: inputs.save_caches == 'true' && steps.boost-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v6 + with: + path: boost-prefix + key: ${{ steps.boost-cache.outputs.cache-primary-key }} + + - name: Verify Boost Windows API floor + shell: msys2 {0} + run: | + boost_dlls=("${{ steps.paths.outputs.boost_prefix }}"/lib/libboost_*.dll) + if [ ! -e "${boost_dlls[0]}" ]; then + echo "::error::Boost DLLs not found under ${{ steps.paths.outputs.boost_prefix }}/lib" + ls -la "${{ steps.paths.outputs.boost_prefix }}/lib" || true + exit 1 + fi + bad=0 + for boost_dll in "${boost_dlls[@]}"; do + echo "Inspecting ${boost_dll}" + objdump -p "$boost_dll" | awk '/DLL Name:/ {print " " $3}' | sort -u + if objdump -p "$boost_dll" | awk '/WaitOnAddress|WakeByAddressSingle|WakeByAddressAll|api-ms-win-core-synch-l1-2-0\.dll/ { found=1; print } END { exit found ? 0 : 1 }'; then + echo "::error::${boost_dll} imports Windows 8+ synchronization APIs" + bad=1 + fi + done + exit "$bad" + + - name: Locate gfortran + id: fc + shell: msys2 {0} + run: echo "version=$(gfortran -dumpfullversion -dumpversion)" >> "$GITHUB_OUTPUT" + + - name: Restore pFUnit cache + id: pfunit-cache + uses: actions/cache/restore@v6 + with: + path: pfunit-prefix + key: pfunit-windows-windows-latest-mingw64-v4.14.0-gfortran${{ steps.fc.outputs.version }}-epoch1-${{ hashFiles('.github/scripts/build-pfunit-windows.sh') }} + + - name: Build pFUnit + if: steps.pfunit-cache.outputs.cache-hit != 'true' + shell: msys2 {0} + run: .github/scripts/build-pfunit-windows.sh v4.14.0 "${{ steps.paths.outputs.pfunit_prefix }}" + + - name: Locate pFUnit config + id: pfunit + shell: msys2 {0} + run: | + for pkg in PFUNIT GFTL GFTL_SHARED FARGPARSE; do + CONFIG=$(find "${{ steps.paths.outputs.pfunit_prefix }}" -name ${pkg}Config.cmake | head -1) + if [ -z "$CONFIG" ]; then + echo "ERROR: ${pkg}Config.cmake not found under pfunit-prefix" + find "${{ steps.paths.outputs.pfunit_prefix }}" -maxdepth 3 -type d + exit 1 + fi + DIR="$(dirname "$CONFIG")" + echo "Found ${pkg}Config.cmake at: $CONFIG" + echo "$(echo $pkg | tr '[:upper:]' '[:lower:]')_dir=${DIR}" >> "$GITHUB_OUTPUT" + done + + - name: Save pFUnit cache + if: inputs.save_caches == 'true' && steps.pfunit-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v6 + with: + path: pfunit-prefix + key: ${{ steps.pfunit-cache.outputs.cache-primary-key }} + + - name: Restore Hamlib cache + id: hamlib-cache + uses: actions/cache/restore@v6 + with: + path: hamlib-prefix + key: hamlib-windows-windows-latest-mingw64-${{ inputs.hamlib_branch }}-epoch2-${{ hashFiles('.github/scripts/build-hamlib-windows.sh') }} + + - name: Build Hamlib + if: steps.hamlib-cache.outputs.cache-hit != 'true' + shell: msys2 {0} + env: + MSYS2_PATH_TYPE: inherit + HAMLIB_BRANCH: ${{ inputs.hamlib_branch }} + run: .github/scripts/build-hamlib-windows.sh "$HAMLIB_BRANCH" "${{ steps.paths.outputs.hamlib_prefix }}" + + - name: Verify Hamlib prefix + shell: msys2 {0} + run: | + test -f "${{ steps.paths.outputs.hamlib_prefix }}/bin/libhamlib-4.dll" + test -f "${{ steps.paths.outputs.hamlib_prefix }}/bin/rigctl.exe" + test -f "${{ steps.paths.outputs.hamlib_prefix }}/bin/rigctld.exe" + test -f "${{ steps.paths.outputs.hamlib_prefix }}/bin/rigctlcom.exe" + test -f "${{ steps.paths.outputs.hamlib_prefix }}/include/hamlib/rig.h" + test -f "${{ steps.paths.outputs.hamlib_prefix }}/lib/libhamlib.dll.a" + + - name: Save Hamlib cache + if: inputs.save_caches == 'true' && steps.hamlib-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v6 + with: + path: hamlib-prefix + key: ${{ steps.hamlib-cache.outputs.cache-primary-key }} diff --git a/.github/actions/warm-macos-deps/action.yml b/.github/actions/warm-macos-deps/action.yml new file mode 100644 index 00000000..74ef9423 --- /dev/null +++ b/.github/actions/warm-macos-deps/action.yml @@ -0,0 +1,330 @@ +name: "Warm macOS dependency caches" +description: "Restore or populate macOS Qt and pinned dependency caches without building WSJT-X." + +inputs: + arch: + description: "Target architecture: arm64 or x86_64" + required: true + runner: + description: "GitHub Actions runner label" + required: true + deployment_target: + description: "macOS deployment target version" + required: true + hamlib_branch: + description: "Hamlib branch to build" + required: true + +runs: + using: "composite" + steps: + - name: Validate workflow inputs + shell: bash + env: + HAMLIB_BRANCH: ${{ inputs.hamlib_branch }} + ARCH: ${{ inputs.arch }} + DEPLOYMENT_TARGET: ${{ inputs.deployment_target }} + RUNNER: ${{ inputs.runner }} + run: .github/scripts/validate-ci-inputs.sh + + - name: Verify macOS build tuple + shell: bash + run: | + case "${{ inputs.arch }}:${{ inputs.runner }}:${{ inputs.deployment_target }}" in + arm64:macos-15:11.0|x86_64:macos-15-intel:10.13) + echo "Using supported macOS dependency tuple: ${{ inputs.arch }} on ${{ inputs.runner }} targeting ${{ inputs.deployment_target }}" + ;; + *) + echo "::error::Unsupported macOS dependency tuple: arch=${{ inputs.arch }}, runner=${{ inputs.runner }}, deployment_target=${{ inputs.deployment_target }}" + exit 1 + ;; + esac + + - name: Set Homebrew prefix + shell: bash + run: echo "HOMEBREW_PREFIX=$(brew --prefix)" >> "$GITHUB_ENV" + + - name: Install dependencies + shell: bash + run: brew install cmake autoconf automake libtool pkg-config + + - name: Compute Qt cache key + id: qt-key + shell: bash + run: | + .github/scripts/macos-qt-cache-key.sh \ + --arch "${{ inputs.arch }}" \ + --runner "${{ inputs.runner }}" \ + --deployment-target "${{ inputs.deployment_target }}" \ + --github-output + + - name: Restore Qt cache + id: qt-cache + uses: actions/cache/restore@v5 + with: + path: qt-prefix + key: ${{ steps.qt-key.outputs.key }} + + - name: Build Qt + if: steps.qt-cache.outputs.cache-hit != 'true' + shell: bash + run: | + .github/scripts/build-qt-macos.sh \ + --arch "${{ inputs.arch }}" \ + --deployment-target "${{ inputs.deployment_target }}" \ + --prefix "${GITHUB_WORKSPACE}/qt-prefix" + + - name: Save Qt cache + if: steps.qt-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v5 + with: + path: qt-prefix + key: ${{ steps.qt-cache.outputs.cache-primary-key }} + + - name: Verify Qt prefix + shell: bash + run: | + .github/scripts/verify-macos-artifacts.sh \ + --target "${{ inputs.deployment_target }}" \ + --arch "${{ inputs.arch }}" \ + --allow-prefix "${GITHUB_WORKSPACE}/qt-prefix" \ + "${GITHUB_WORKSPACE}/qt-prefix" + + - name: Install controlled ARM gfortran + id: controlled-arm-fc + if: inputs.arch == 'arm64' + shell: bash + run: | + .github/scripts/install-r-macos-gfortran.sh \ + --target "${{ inputs.deployment_target }}" \ + --arch "${{ inputs.arch }}" \ + --work-dir "${RUNNER_TEMP}/r-macos-gfortran" \ + --prefix "${GITHUB_WORKSPACE}/gfortran-prefix" \ + --github-output + + - name: Install controlled Intel gfortran + id: controlled-intel-fc + if: inputs.arch == 'x86_64' + shell: bash + run: | + .github/scripts/install-xpack-gfortran-macos.sh \ + --target "${{ inputs.deployment_target }}" \ + --arch "${{ inputs.arch }}" \ + --work-dir "${RUNNER_TEMP}/xpack-gfortran" \ + --prefix "${GITHUB_WORKSPACE}/gfortran-prefix" \ + --github-output + + - name: Select gfortran + id: fc + shell: bash + run: | + if [ "${{ inputs.arch }}" = "x86_64" ]; then + echo "Using controlled gfortran: ${{ steps.controlled-intel-fc.outputs.path }}" + { + echo "path=${{ steps.controlled-intel-fc.outputs.path }}" + echo "runtime_lib_dir=${{ steps.controlled-intel-fc.outputs.runtime_lib_dir }}" + echo "runtime_archives=${{ steps.controlled-intel-fc.outputs.runtime_archives }}" + echo "cache_key=${{ steps.controlled-intel-fc.outputs.cache_key }}" + } >> "$GITHUB_OUTPUT" + exit 0 + fi + + echo "Using controlled gfortran: ${{ steps.controlled-arm-fc.outputs.path }}" + { + echo "path=${{ steps.controlled-arm-fc.outputs.path }}" + echo "runtime_lib_dir=${{ steps.controlled-arm-fc.outputs.runtime_lib_dir }}" + echo "runtime_archives=${{ steps.controlled-arm-fc.outputs.runtime_archives }}" + echo "cache_key=${{ steps.controlled-arm-fc.outputs.cache_key }}" + } >> "$GITHUB_OUTPUT" + + - name: Verify static Fortran runtime + shell: bash + run: | + .github/scripts/verify-macos-static-archives.sh \ + --target "${{ inputs.deployment_target }}" \ + --arch "${{ inputs.arch }}" \ + --mode error \ + ${{ steps.fc.outputs.runtime_archives }} + + - name: Restore libusb cache + id: libusb-cache + uses: actions/cache/restore@v5 + with: + path: libusb-prefix + key: libusb-macos-${{ inputs.arch }}-${{ inputs.runner }}-1.0.27-min${{ inputs.deployment_target }}-epoch1-${{ hashFiles('.github/scripts/build-libusb-macos.sh') }} + + - name: Build libusb + if: steps.libusb-cache.outputs.cache-hit != 'true' + shell: bash + run: | + .github/scripts/build-libusb-macos.sh \ + 1.0.27 \ + "${{ inputs.deployment_target }}" \ + "${GITHUB_WORKSPACE}/libusb-prefix" + + - name: Save libusb cache + if: steps.libusb-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v5 + with: + path: libusb-prefix + key: ${{ steps.libusb-cache.outputs.cache-primary-key }} + + - name: Restore PortAudio cache + id: portaudio-cache + uses: actions/cache/restore@v5 + with: + path: portaudio-prefix + key: portaudio-macos-${{ inputs.arch }}-${{ inputs.runner }}-19.7.0-min${{ inputs.deployment_target }}-epoch1-${{ hashFiles('.github/scripts/build-portaudio-macos.sh') }} + + - name: Build PortAudio + if: steps.portaudio-cache.outputs.cache-hit != 'true' + shell: bash + run: | + .github/scripts/build-portaudio-macos.sh \ + 19.7.0 \ + "${{ inputs.deployment_target }}" \ + "${GITHUB_WORKSPACE}/portaudio-prefix" + + - name: Save PortAudio cache + if: steps.portaudio-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v5 + with: + path: portaudio-prefix + key: ${{ steps.portaudio-cache.outputs.cache-primary-key }} + + - name: Restore FFTW cache + id: fftw-cache + uses: actions/cache/restore@v5 + with: + path: fftw-prefix + key: fftw-macos-${{ inputs.arch }}-${{ inputs.runner }}-3.3.10-min${{ inputs.deployment_target }}-epoch1-${{ hashFiles('.github/scripts/build-fftw-macos.sh') }} + + - name: Build FFTW + if: steps.fftw-cache.outputs.cache-hit != 'true' + shell: bash + run: | + .github/scripts/build-fftw-macos.sh \ + 3.3.10 \ + "${{ inputs.deployment_target }}" \ + "${GITHUB_WORKSPACE}/fftw-prefix" + + - name: Save FFTW cache + if: steps.fftw-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v5 + with: + path: fftw-prefix + key: ${{ steps.fftw-cache.outputs.cache-primary-key }} + + - name: Restore Boost cache + id: boost-cache + uses: actions/cache/restore@v5 + with: + path: boost-prefix + key: boost-macos-${{ inputs.arch }}-${{ inputs.runner }}-1.85.0-7009fe1faa1697476bdc7027703a2badb84e849b7b0baad5086b087b971f8617-min${{ inputs.deployment_target }}-epoch1-${{ hashFiles('.github/scripts/build-boost-macos.sh') }} + + - name: Build Boost + if: steps.boost-cache.outputs.cache-hit != 'true' + shell: bash + run: | + .github/scripts/build-boost-macos.sh \ + 1.85.0 \ + 7009fe1faa1697476bdc7027703a2badb84e849b7b0baad5086b087b971f8617 \ + "${{ inputs.arch }}" \ + "${{ inputs.deployment_target }}" \ + "${GITHUB_WORKSPACE}/boost-prefix" + + - name: Save Boost cache + if: steps.boost-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v5 + with: + path: boost-prefix + key: ${{ steps.boost-cache.outputs.cache-primary-key }} + + - name: Verify pinned runtime prefixes + shell: bash + run: | + .github/scripts/verify-macos-artifacts.sh \ + --target "${{ inputs.deployment_target }}" \ + --arch "${{ inputs.arch }}" \ + --allow-prefix "${GITHUB_WORKSPACE}/libusb-prefix" \ + --allow-prefix "${GITHUB_WORKSPACE}/portaudio-prefix" \ + --allow-prefix "${GITHUB_WORKSPACE}/fftw-prefix" \ + --allow-prefix "${GITHUB_WORKSPACE}/boost-prefix" \ + "${GITHUB_WORKSPACE}/libusb-prefix" \ + "${GITHUB_WORKSPACE}/portaudio-prefix" \ + "${GITHUB_WORKSPACE}/fftw-prefix" \ + "${GITHUB_WORKSPACE}/boost-prefix" + + - name: Restore Hamlib cache + id: hamlib-cache + uses: actions/cache/restore@v5 + with: + path: hamlib-prefix + key: hamlib-macos-${{ inputs.arch }}-${{ inputs.runner }}-${{ inputs.hamlib_branch }}-libusb1.0.27-min${{ inputs.deployment_target }}-epoch1-${{ hashFiles('.github/scripts/build-hamlib-macos.sh', '.github/scripts/build-libusb-macos.sh') }} + + - name: Build Hamlib + if: steps.hamlib-cache.outputs.cache-hit != 'true' + shell: bash + env: + HAMLIB_BRANCH: ${{ inputs.hamlib_branch }} + DEPLOYMENT_TARGET: ${{ inputs.deployment_target }} + run: | + .github/scripts/build-hamlib-macos.sh \ + "$HAMLIB_BRANCH" \ + "$DEPLOYMENT_TARGET" \ + "${GITHUB_WORKSPACE}/hamlib-prefix" \ + "${GITHUB_WORKSPACE}/libusb-prefix" + + - name: Verify Hamlib prefix + shell: bash + run: | + test -f "${GITHUB_WORKSPACE}/hamlib-prefix/lib/libhamlib.a" + .github/scripts/verify-macos-static-archives.sh \ + --target "${{ inputs.deployment_target }}" \ + --arch "${{ inputs.arch }}" \ + --mode error \ + "${GITHUB_WORKSPACE}/hamlib-prefix/lib/libhamlib.a" + + - name: Save Hamlib cache + if: steps.hamlib-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v5 + with: + path: hamlib-prefix + key: ${{ steps.hamlib-cache.outputs.cache-primary-key }} + + - name: Restore pFUnit cache + id: pfunit-cache + uses: actions/cache/restore@v5 + with: + path: pfunit-prefix + key: pfunit-macos-${{ inputs.arch }}-${{ inputs.runner }}-v4.14.0-${{ steps.fc.outputs.cache_key }}-min${{ inputs.deployment_target }}-epoch3-${{ hashFiles('.github/scripts/build-pfunit-macos.sh') }} + + - name: Build pFUnit + if: steps.pfunit-cache.outputs.cache-hit != 'true' + shell: bash + env: + DYLD_LIBRARY_PATH: ${{ steps.fc.outputs.runtime_lib_dir }} + run: | + .github/scripts/build-pfunit-macos.sh \ + v4.14.0 \ + "${{ steps.fc.outputs.path }}" \ + "${{ inputs.deployment_target }}" \ + "${GITHUB_WORKSPACE}/pfunit-prefix" + + - name: Locate pFUnit config + shell: bash + run: | + config=$(find "${GITHUB_WORKSPACE}/pfunit-prefix" -name PFUNITConfig.cmake -print -quit) + 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 + echo "Found PFUNITConfig.cmake at: $config" + + - name: Save pFUnit cache + if: steps.pfunit-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v5 + with: + path: pfunit-prefix + key: ${{ steps.pfunit-cache.outputs.cache-primary-key }} diff --git a/.github/cmake/armhf-toolchain.cmake b/.github/cmake/armhf-toolchain.cmake new file mode 100644 index 00000000..5a0e568e --- /dev/null +++ b/.github/cmake/armhf-toolchain.cmake @@ -0,0 +1,60 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR armv7l) + +set(WSJT_ARMHF_TOOLCHAIN_PREFIX "/opt/wsjtx/armhf-toolchain" + CACHE PATH "ARMHF cross-toolchain prefix") +set(WSJT_ARMHF_SYSROOT "/opt/wsjtx/armhf-sysroot" + CACHE PATH "Debian Bookworm ARMHF sysroot") +set(WSJT_QT_HOST_PATH "/usr/lib/qt5/bin" + CACHE PATH "Native Qt 5 tools used while cross-compiling") +set(WSJT_QT_TARGET_TRANSLATIONS_DIR + "${WSJT_ARMHF_SYSROOT}/usr/share/qt5/translations" + CACHE PATH "Qt 5 target translations directory") + +set(_wsjt_armhf_triplet arm-linux-gnueabihf) +set(_wsjt_armhf_bin "${WSJT_ARMHF_TOOLCHAIN_PREFIX}/bin") +set(CMAKE_C_COMPILER "${_wsjt_armhf_bin}/${_wsjt_armhf_triplet}-gcc") +set(CMAKE_CXX_COMPILER "${_wsjt_armhf_bin}/${_wsjt_armhf_triplet}-g++") +set(CMAKE_Fortran_COMPILER "${_wsjt_armhf_bin}/${_wsjt_armhf_triplet}-gfortran") +set(CMAKE_AR "${_wsjt_armhf_bin}/${_wsjt_armhf_triplet}-ar") +set(CMAKE_NM "${_wsjt_armhf_bin}/${_wsjt_armhf_triplet}-nm") +set(CMAKE_OBJCOPY "${_wsjt_armhf_bin}/${_wsjt_armhf_triplet}-objcopy") +set(CMAKE_OBJDUMP "${_wsjt_armhf_bin}/${_wsjt_armhf_triplet}-objdump") +set(CMAKE_RANLIB "${_wsjt_armhf_bin}/${_wsjt_armhf_triplet}-ranlib") +# GNU readelf is architecture-independent, and this stable path exists in +# both the builder and ARMv7 runtime containers for CTest commands. +set(CMAKE_READELF "/usr/bin/readelf") +set(CMAKE_STRIP "${_wsjt_armhf_bin}/${_wsjt_armhf_triplet}-strip") + +set(CMAKE_SYSROOT "${WSJT_ARMHF_SYSROOT}") +set(CMAKE_LIBRARY_ARCHITECTURE "${_wsjt_armhf_triplet}") +set(CMAKE_FIND_ROOT_PATH "${WSJT_ARMHF_SYSROOT}") +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +# crosstool-NG uses a conventional sysroot layout. Debian keeps ARMHF +# headers and start files in triplet-qualified directories instead. +set(_wsjt_armhf_include "${WSJT_ARMHF_SYSROOT}/usr/include/${_wsjt_armhf_triplet}") +set(_wsjt_armhf_lib "${WSJT_ARMHF_SYSROOT}/usr/lib/${_wsjt_armhf_triplet}") +set(_wsjt_armhf_base_lib "${WSJT_ARMHF_SYSROOT}/lib/${_wsjt_armhf_triplet}") +set(CMAKE_C_FLAGS_INIT "-isystem ${_wsjt_armhf_include}") +set(CMAKE_CXX_FLAGS_INIT "-isystem ${_wsjt_armhf_include}") +set(_wsjt_armhf_link_flags + "-B${_wsjt_armhf_lib}/ -L${_wsjt_armhf_lib} -Wl,-rpath-link,${_wsjt_armhf_lib} -Wl,-rpath-link,${_wsjt_armhf_base_lib}") +set(CMAKE_EXE_LINKER_FLAGS_INIT "${_wsjt_armhf_link_flags}") +set(CMAKE_SHARED_LINKER_FLAGS_INIT "${_wsjt_armhf_link_flags}") +set(CMAKE_MODULE_LINKER_FLAGS_INIT "${_wsjt_armhf_link_flags}") + +set(ENV{PKG_CONFIG_SYSROOT_DIR} "${WSJT_ARMHF_SYSROOT}") +set(ENV{PKG_CONFIG_PATH} "") +set(ENV{PKG_CONFIG_LIBDIR} + "${_wsjt_armhf_lib}/pkgconfig:${WSJT_ARMHF_SYSROOT}/usr/share/pkgconfig") + +# These are target programs installed from the cross-built Hamlib staging tree. +set(RIGCTL_EXE "${WSJT_ARMHF_SYSROOT}/usr/bin/rigctl" CACHE FILEPATH "" FORCE) +set(RIGCTLD_EXE "${WSJT_ARMHF_SYSROOT}/usr/bin/rigctld" CACHE FILEPATH "" FORCE) +set(RIGCTLCOM_EXE "${WSJT_ARMHF_SYSROOT}/usr/bin/rigctlcom" CACHE FILEPATH "" FORCE) +set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE armhf CACHE STRING "" FORCE) +set(CPACK_RPM_PACKAGE_ARCHITECTURE armv7l CACHE STRING "" FORCE) diff --git a/.github/images/linux-ci/Dockerfile.armhf-cross b/.github/images/linux-ci/Dockerfile.armhf-cross new file mode 100644 index 00000000..f37d1928 --- /dev/null +++ b/.github/images/linux-ci/Dockerfile.armhf-cross @@ -0,0 +1,121 @@ +FROM debian:bookworm + +ARG IMAGE_REFRESH_EPOCH + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +ENV DEBIAN_FRONTEND=noninteractive + +COPY .github/scripts/run-apt-get.sh /usr/local/bin/run-apt-get +RUN chmod +x /usr/local/bin/run-apt-get \ + && test -n "$IMAGE_REFRESH_EPOCH" \ + && run-apt-get update \ + && run-apt-get install -y --no-install-recommends \ + asciidoctor autoconf automake binutils bison build-essential \ + ca-certificates ccache cmake curl dpkg-dev file flex gawk git gperf \ + help2man libncurses-dev libtool libtool-bin mmdebstrap patch pkg-config \ + python3 python3-dev qt5-qmake-bin qtbase5-dev-tools qttools5-dev-tools \ + qemu-user-static rsync texinfo unzip wget xz-utils \ + && run-apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY .github/scripts/linux-ci-image-config.sh \ + .github/scripts/armhf-ci-image-config.sh \ + /usr/local/share/wsjtx-ci/ +COPY .github/images/linux-ci/armhf-cross-toolchain.config \ + /usr/local/share/wsjtx-ci/armhf-cross-toolchain.config + +RUN set -eux; \ + . /usr/local/share/wsjtx-ci/armhf-ci-image-config.sh; \ + curl --fail --show-error --silent --location --retry 5 \ + -o /tmp/crosstool-ng.tar.xz "$ARMHF_CROSSTOOL_NG_URL"; \ + echo "$ARMHF_CROSSTOOL_NG_SHA256 /tmp/crosstool-ng.tar.xz" | sha256sum -c -; \ + mkdir /tmp/crosstool-ng; \ + tar -xf /tmp/crosstool-ng.tar.xz -C /tmp/crosstool-ng --strip-components=1; \ + cd /tmp/crosstool-ng; \ + ./configure --prefix=/usr/local; \ + make -j"$(nproc)"; \ + make install; \ + cd /; \ + rm -rf /tmp/crosstool-ng /tmp/crosstool-ng.tar.xz; \ + useradd --create-home --shell /bin/bash wsjtx; \ + mkdir -p /tmp/wsjtx-ctng-build /var/cache/wsjtx-ctng /opt/wsjtx; \ + chown -R wsjtx:wsjtx /tmp/wsjtx-ctng-build /var/cache/wsjtx-ctng /opt/wsjtx + +ARG IMAGE_RECIPE_SHA256 +USER wsjtx +RUN --mount=type=cache,id=wsjtx-armhf-ctng-downloads,target=/var/cache/wsjtx-ctng,uid=1000,gid=1000 \ + --mount=type=cache,id=wsjtx-armhf-ctng-build-${IMAGE_RECIPE_SHA256},target=/tmp/wsjtx-ctng-build,uid=1000,gid=1000 \ + set -eux; \ + cd /tmp/wsjtx-ctng-build; \ + cp /usr/local/share/wsjtx-ci/armhf-cross-toolchain.config .config; \ + ct-ng olddefconfig; \ + # crosstool-NG prints only a summary on failure; expose the detailed compiler \ + # tail so hosted image failures can be diagnosed without reproducing locally. \ + if ! ct-ng build; then \ + tail -n 300 build.log >&2; \ + exit 1; \ + fi + +USER root +COPY .github/scripts/linux-ccache-compiler-signature.sh \ + .github/scripts/build-hamlib-armhf-cross.sh \ + .github/scripts/build-armhf-toolchain-smoke.sh \ + .github/scripts/normalize-armhf-sysroot-symlinks.sh \ + .github/scripts/write-armhf-ci-manifest.sh \ + .github/scripts/verify-armhf-ci-image.sh \ + /usr/local/share/wsjtx-ci/ +RUN set -eux; \ + chmod +x /usr/local/share/wsjtx-ci/*.sh; \ + . /usr/local/share/wsjtx-ci/armhf-ci-image-config.sh; \ + test "$("$ARMHF_TOOLCHAIN_PREFIX/bin/$ARMHF_TARGET_TRIPLET-gcc" -dumpfullversion -dumpversion)" = "$ARMHF_GCC_VERSION"; \ + test "$("$ARMHF_TOOLCHAIN_PREFIX/bin/$ARMHF_TARGET_TRIPLET-gcc" -dumpmachine)" = "$ARMHF_TARGET_TRIPLET"; \ + package_csv="$(IFS=,; echo "${ARMHF_SYSROOT_PACKAGES[*]}")"; \ + mmdebstrap --variant=extract --architectures=armhf \ + --include="$package_csv" --skip=cleanup/apt/cache \ + bookworm "$ARMHF_SYSROOT" http://deb.debian.org/debian; \ + /usr/local/share/wsjtx-ci/normalize-armhf-sysroot-symlinks.sh \ + "$ARMHF_SYSROOT"; \ + mkdir -p /opt/wsjtx-ci; \ + : > /opt/wsjtx-ci/armhf-sysroot-packages.unsorted; \ + while IFS= read -r -d '' package; do \ + dpkg-deb -f "$package" '${binary:Package}=${Version}\n' \ + >> /opt/wsjtx-ci/armhf-sysroot-packages.unsorted; \ + done < <(find "$ARMHF_SYSROOT/var/cache/apt/archives" -type f -name '*.deb' -print0); \ + LC_ALL=C sort -u /opt/wsjtx-ci/armhf-sysroot-packages.unsorted \ + > /opt/wsjtx-ci/armhf-sysroot-packages.txt; \ + rm /opt/wsjtx-ci/armhf-sysroot-packages.unsorted; \ + rm -rf "$ARMHF_SYSROOT/var/cache/apt/archives" \ + "$ARMHF_SYSROOT/var/lib/apt/lists"; \ + mkdir -p /tmp/wsjtx-hamlib-build; \ + cd /tmp/wsjtx-hamlib-build; \ + /usr/local/share/wsjtx-ci/build-hamlib-armhf-cross.sh \ + "$LINUX_HAMLIB_COMMIT" "$ARMHF_SYSROOT" "$ARMHF_TOOLCHAIN_PREFIX"; \ + mkdir -p "$ARMHF_RUNTIME_PREFIX"; \ + for library in "${ARMHF_GCC_RUNTIME_LIBRARIES[@]}"; do \ + source_path="$("$ARMHF_TOOLCHAIN_PREFIX/bin/$ARMHF_TARGET_TRIPLET-gcc" -print-file-name="$library")"; \ + test "$source_path" != "$library"; \ + cp -L "$source_path" "$ARMHF_RUNTIME_PREFIX/$library"; \ + done; \ + test "$("$ARMHF_TOOLCHAIN_PREFIX/bin/$ARMHF_TARGET_TRIPLET-gcc" -print-file-name=libquadmath.so.0)" = libquadmath.so.0; \ + /usr/local/share/wsjtx-ci/build-armhf-toolchain-smoke.sh \ + "$ARMHF_TOOLCHAIN_PREFIX" "$ARMHF_SYSROOT" /opt/wsjtx-ci/toolchain-smoke; \ + rm -rf /tmp/wsjtx-hamlib-build /home/wsjtx + +ARG IMAGE_CREATED +ARG IMAGE_GENERATION=local +ARG IMAGE_REVISION +LABEL org.opencontainers.image.created="${IMAGE_CREATED}" \ + org.opencontainers.image.revision="${IMAGE_REVISION}" \ + org.opencontainers.image.source="https://github.com/WSJTX/wsjtx-internal" \ + org.opencontainers.image.title="WSJT-X ARMHF cross-builder" \ + org.opencontainers.image.description="Native x86_64 GCC 13.4 cross-builder with a Debian Bookworm ARMHF sysroot" +RUN set -eux; \ + . /usr/local/share/wsjtx-ci/armhf-ci-image-config.sh; \ + /usr/local/share/wsjtx-ci/write-armhf-ci-manifest.sh \ + cross-builder armhf "$IMAGE_GENERATION" "$IMAGE_RECIPE_SHA256"; \ + IMAGE_RECIPE_SHA256="$IMAGE_RECIPE_SHA256" \ + /usr/local/share/wsjtx-ci/verify-armhf-ci-image.sh \ + cross-builder armhf "$LINUX_HAMLIB_REF" + +ENV PATH="/opt/wsjtx/armhf-toolchain/bin:${PATH}" +WORKDIR /work diff --git a/.github/images/linux-ci/Dockerfile.armhf-runtime b/.github/images/linux-ci/Dockerfile.armhf-runtime new file mode 100644 index 00000000..85404f0f --- /dev/null +++ b/.github/images/linux-ci/Dockerfile.armhf-runtime @@ -0,0 +1,48 @@ +ARG CROSS_BUILDER_IMAGE=wsjtx-armhf-cross:missing-build-arg +ARG CROSS_BUILDER_PLATFORM=linux/amd64 +FROM --platform=${CROSS_BUILDER_PLATFORM} ${CROSS_BUILDER_IMAGE} AS cross_builder + +FROM arm32v7/debian:bookworm + +ARG IMAGE_REFRESH_EPOCH + +ENV DEBIAN_FRONTEND=noninteractive + +COPY .github/scripts/run-apt-get.sh /usr/local/bin/run-apt-get +COPY .github/images/linux-ci/install-armhf-runtime-packages.sh \ + /usr/local/bin/install-armhf-runtime-packages +RUN chmod +x /usr/local/bin/run-apt-get /usr/local/bin/install-armhf-runtime-packages \ + && test -n "$IMAGE_REFRESH_EPOCH" \ + && /usr/local/bin/install-armhf-runtime-packages + +COPY .github/scripts/linux-ci-image-config.sh \ + .github/scripts/armhf-ci-image-config.sh \ + .github/scripts/write-armhf-ci-manifest.sh \ + .github/scripts/verify-armhf-ci-image.sh \ + /usr/local/share/wsjtx-ci/ +COPY --from=cross_builder /opt/wsjtx/armhf-runtime /opt/wsjtx/armhf-runtime +COPY --from=cross_builder /opt/wsjtx-ci/toolchain-smoke /opt/wsjtx-ci/toolchain-smoke +COPY --from=cross_builder /opt/wsjtx-ci/image.env \ + /usr/local/share/wsjtx-ci/cross-builder.env +COPY --from=cross_builder /usr/bin/qemu-arm-static /usr/local/bin/qemu-arm-static + +ARG IMAGE_CREATED +ARG IMAGE_GENERATION=local +ARG IMAGE_REVISION +ARG IMAGE_RECIPE_SHA256 +LABEL org.opencontainers.image.created="${IMAGE_CREATED}" \ + org.opencontainers.image.revision="${IMAGE_REVISION}" \ + org.opencontainers.image.source="https://github.com/WSJTX/wsjtx-internal" \ + org.opencontainers.image.title="WSJT-X ARMHF runtime validator" \ + org.opencontainers.image.description="Debian Bookworm ARMv7 packaging and runtime validation under QEMU" +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +RUN set -eux; \ + chmod +x /usr/local/share/wsjtx-ci/*.sh; \ + . /usr/local/share/wsjtx-ci/armhf-ci-image-config.sh; \ + /usr/local/share/wsjtx-ci/write-armhf-ci-manifest.sh \ + runtime armhf "$IMAGE_GENERATION" "$IMAGE_RECIPE_SHA256"; \ + IMAGE_RECIPE_SHA256="$IMAGE_RECIPE_SHA256" \ + /usr/local/share/wsjtx-ci/verify-armhf-ci-image.sh \ + runtime armhf "$LINUX_HAMLIB_REF" + +WORKDIR /work diff --git a/.github/images/linux-ci/Dockerfile.bookworm b/.github/images/linux-ci/Dockerfile.bookworm new file mode 100644 index 00000000..f919a032 --- /dev/null +++ b/.github/images/linux-ci/Dockerfile.bookworm @@ -0,0 +1,51 @@ +ARG BASE_IMAGE=gcc:13.4.0-bookworm +FROM ${BASE_IMAGE} + +ARG IMAGE_ARCH +ARG IMAGE_CREATED +ARG IMAGE_GENERATION=local +ARG IMAGE_REVISION +ARG IMAGE_RECIPE_SHA256 +ARG IMAGE_REFRESH_EPOCH + +LABEL org.opencontainers.image.created="${IMAGE_CREATED}" \ + org.opencontainers.image.revision="${IMAGE_REVISION}" \ + org.opencontainers.image.source="https://github.com/WSJTX/wsjtx-internal" \ + org.opencontainers.image.title="WSJT-X Bookworm Linux CI" \ + org.opencontainers.image.description="GCC 13.4 Debian Bookworm environment for WSJT-X ARM CI" + +ENV DEBIAN_FRONTEND=noninteractive + +COPY .github/scripts/run-apt-get.sh /usr/local/bin/run-apt-get +COPY .github/images/linux-ci/install-packages.sh /usr/local/bin/install-packages +RUN chmod +x /usr/local/bin/run-apt-get /usr/local/bin/install-packages \ + && test -n "$IMAGE_REFRESH_EPOCH" \ + && /usr/local/bin/install-packages normal + +COPY .github/scripts/linux-ci-image-config.sh \ + .github/scripts/build-pfunit-linux.sh \ + .github/scripts/build-hamlib-linux.sh \ + .github/scripts/linux-ccache-compiler-signature.sh \ + .github/scripts/verify-linux-ci-image.sh \ + /usr/local/share/wsjtx-ci/ +COPY .github/images/linux-ci/write-manifest.sh /usr/local/bin/write-wsjtx-ci-manifest + +RUN set -eux; \ + test -n "$IMAGE_ARCH"; \ + chmod +x /usr/local/bin/write-wsjtx-ci-manifest; \ + . /usr/local/share/wsjtx-ci/linux-ci-image-config.sh; \ + mkdir -p /tmp/wsjtx-pfunit-build; \ + cd /tmp/wsjtx-pfunit-build; \ + /usr/local/share/wsjtx-ci/build-pfunit-linux.sh \ + "$LINUX_PFUNIT_COMMIT" "$LINUX_PFUNIT_PREFIX"; \ + mkdir -p /tmp/wsjtx-hamlib-build; \ + cd /tmp/wsjtx-hamlib-build; \ + /usr/local/share/wsjtx-ci/build-hamlib-linux.sh \ + "$LINUX_HAMLIB_COMMIT" "$LINUX_HAMLIB_PREFIX"; \ + cd /; \ + rm -rf /tmp/wsjtx-pfunit-build /tmp/wsjtx-hamlib-build; \ + /usr/local/bin/write-wsjtx-ci-manifest \ + normal "$IMAGE_ARCH" "$IMAGE_GENERATION" "$IMAGE_RECIPE_SHA256"; \ + IMAGE_RECIPE_SHA256="$IMAGE_RECIPE_SHA256" \ + /usr/local/share/wsjtx-ci/verify-linux-ci-image.sh \ + normal "$IMAGE_ARCH" "$LINUX_HAMLIB_REF" diff --git a/.github/images/linux-ci/Dockerfile.noble b/.github/images/linux-ci/Dockerfile.noble new file mode 100644 index 00000000..b93abc37 --- /dev/null +++ b/.github/images/linux-ci/Dockerfile.noble @@ -0,0 +1,89 @@ +ARG BASE_IMAGE=ubuntu:24.04 +FROM ${BASE_IMAGE} AS common + +ARG IMAGE_CREATED +ARG IMAGE_GENERATION=local +ARG IMAGE_REVISION +ARG IMAGE_RECIPE_SHA256 + +LABEL org.opencontainers.image.created="${IMAGE_CREATED}" \ + org.opencontainers.image.revision="${IMAGE_REVISION}" \ + org.opencontainers.image.source="https://github.com/WSJTX/wsjtx-internal" + +ENV DEBIAN_FRONTEND=noninteractive + +COPY .github/scripts/run-apt-get.sh /usr/local/bin/run-apt-get +COPY .github/images/linux-ci/install-packages.sh /usr/local/bin/install-packages +RUN chmod +x /usr/local/bin/run-apt-get /usr/local/bin/install-packages + +FROM common AS normal + +ARG IMAGE_REFRESH_EPOCH + +LABEL org.opencontainers.image.title="WSJT-X Noble Linux CI" \ + org.opencontainers.image.description="Ubuntu 24.04 build environment for WSJT-X normal and ASan/UBSan CI" + +RUN test -n "$IMAGE_REFRESH_EPOCH" && /usr/local/bin/install-packages normal + +COPY .github/scripts/linux-ci-image-config.sh \ + .github/scripts/build-pfunit-linux.sh \ + .github/scripts/build-hamlib-linux.sh \ + .github/scripts/linux-ccache-compiler-signature.sh \ + .github/scripts/verify-linux-ci-image.sh \ + /usr/local/share/wsjtx-ci/ +COPY .github/images/linux-ci/write-manifest.sh /usr/local/bin/write-wsjtx-ci-manifest + +RUN set -eux; \ + chmod +x /usr/local/bin/write-wsjtx-ci-manifest; \ + . /usr/local/share/wsjtx-ci/linux-ci-image-config.sh; \ + mkdir -p /tmp/wsjtx-pfunit-build; \ + cd /tmp/wsjtx-pfunit-build; \ + /usr/local/share/wsjtx-ci/build-pfunit-linux.sh \ + "$LINUX_PFUNIT_COMMIT" "$LINUX_PFUNIT_PREFIX"; \ + mkdir -p /tmp/wsjtx-hamlib-build; \ + cd /tmp/wsjtx-hamlib-build; \ + /usr/local/share/wsjtx-ci/build-hamlib-linux.sh \ + "$LINUX_HAMLIB_COMMIT" "$LINUX_HAMLIB_PREFIX"; \ + cd /; \ + rm -rf /tmp/wsjtx-pfunit-build /tmp/wsjtx-hamlib-build; \ + /usr/local/bin/write-wsjtx-ci-manifest \ + normal x86_64 "$IMAGE_GENERATION" "$IMAGE_RECIPE_SHA256"; \ + IMAGE_RECIPE_SHA256="$IMAGE_RECIPE_SHA256" \ + /usr/local/share/wsjtx-ci/verify-linux-ci-image.sh \ + normal x86_64 "$LINUX_HAMLIB_REF" + +FROM common AS tsan + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +ARG IMAGE_GENERATION=local +ARG IMAGE_RECIPE_SHA256 +ARG IMAGE_REFRESH_EPOCH + +LABEL org.opencontainers.image.title="WSJT-X Noble TSan CI" \ + org.opencontainers.image.description="Ubuntu 24.04 environment with TSan-instrumented WSJT-X dependencies" + +RUN test -n "$IMAGE_REFRESH_EPOCH" && /usr/local/bin/install-packages tsan + +COPY .github/scripts/linux-ci-image-config.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/linux-ccache-compiler-signature.sh \ + .github/scripts/verify-tsan-deps-linux.sh \ + .github/scripts/verify-linux-ci-image.sh \ + /usr/local/share/wsjtx-ci/ +COPY .github/images/linux-ci/write-manifest.sh /usr/local/bin/write-wsjtx-ci-manifest + +RUN set -eux; \ + chmod +x /usr/local/bin/write-wsjtx-ci-manifest; \ + . /usr/local/share/wsjtx-ci/tsan-linux-deps-config.sh; \ + /usr/local/share/wsjtx-ci/build-qt-tsan-linux.sh /opt/wsjtx/tsan/qt; \ + /usr/local/share/wsjtx-ci/build-boost-tsan-linux.sh /opt/wsjtx/tsan/boost; \ + /usr/local/share/wsjtx-ci/build-hamlib-tsan-linux.sh /opt/wsjtx/tsan/hamlib; \ + /usr/local/bin/write-wsjtx-ci-manifest \ + tsan x86_64 "$IMAGE_GENERATION" "$IMAGE_RECIPE_SHA256"; \ + IMAGE_RECIPE_SHA256="$IMAGE_RECIPE_SHA256" \ + /usr/local/share/wsjtx-ci/verify-linux-ci-image.sh \ + tsan x86_64 "$TSAN_HAMLIB_REF" diff --git a/.github/images/linux-ci/README.md b/.github/images/linux-ci/README.md new file mode 100644 index 00000000..5c3cd01a --- /dev/null +++ b/.github/images/linux-ci/README.md @@ -0,0 +1,110 @@ +# Linux CI images + +WSJT-X publishes five private, single-platform build environments to GHCR: + +| Package | Platform | CI consumers | +| --- | --- | --- | +| `wsjtx-internal/linux-noble` | `linux/amd64` | Normal and ASan/UBSan | +| `wsjtx-internal/linux-tsan-noble` | `linux/amd64` | TSan | +| `wsjtx-internal/linux-arm64-bookworm` | `linux/arm64` | aarch64 | +| `wsjtx-internal/linux-armhf-cross-bookworm` | `linux/amd64` | Native armhf cross-build | +| `wsjtx-internal/linux-armv7-bookworm` | `linux/arm/v7` | armhf tests and packaging under QEMU | + +The normal images contain the compiler, development and packaging closure, and +the slow-moving pFUnit and Hamlib prefixes. The TSan image instead contains the +pinned, instrumented Qt, Boost, and Hamlib tuple. The armhf cross-builder pairs +a native x86-64 GCC 13.4 cross-toolchain with a Debian Bookworm armhf sysroot; +its runtime partner contains only the target execution and packaging closure. +WSJT-X objects and binaries are never baked into these images. + +The Ubuntu and GCC base tags intentionally follow their maintained upstream +security updates. Each published generation records the resolved package set, +compiler identity, dependency pins, and recipe fingerprint. Normal-image +promotion is gated by image construction, the image-level checks, and a full +WSJT-X build using the exact immutable candidate. That build also publishes the +candidate generation's ccache snapshot before `stable` moves. TSan publication +is an explicit image cohort and verifies its pinned closure during the image +build; the current code-level TSan suite is not part of image promotion. + +## Publication + +`publish-linux-ci-images.yml` pushes unique candidate and immutable `build-*` +tags for the selected image cohort. Each Docker build verifies the image +manifest, dependency metadata, and a representative compile/link smoke test. +Before a normal candidate is promoted, the standard x64 WSJT-X build and test +pipeline runs against its exact `build-*` tag and saves a generation-specific +ccache archive. This prevents a new image from becoming stable without a cache +that pull requests can restore. Successful generations also receive +`validated-build-*` tags. The secondary normal-image `stable` tags move first +and `linux-noble:stable` moves last within that cohort. Consumers resolve that +pointer to its immutable `build-*` tag and use the same generation for every +normal Linux leg. + +The armhf image pair is published explicitly with `include_armhf: true`. It is +excluded from routine weekly/monthly refreshes because toolchain construction +is expensive. The pair is built, promoted, and rolled back as one generation. +Opt-in full-ci, release, and standalone armhf builds resolve the last promoted +runtime generation once and require the matching cross-builder tag; a missing +member fails explicitly. Manual full-ci can instead name an immutable candidate +generation for pre-promotion acceptance testing. + +The TSan workflow resolves `linux-tsan-noble:stable` independently when its +optional label is used. A missing TSan generation fails explicitly instead of +silently using the normal image. A TSan-only publication builds, promotes, or +rolls back only that package; it does not rebuild or retag normal or ARM images. + +Ordinary non-TSan PR and `develop` jobs may overlap a dependency refresh. They +pin the image generation resolved at job start and allow a recipe-fingerprint +mismatch with a warning, so the last known-good stable generation remains a +usable fallback while the refresh completes. Image publication, release, and +TSan jobs keep strict fingerprint checks; if no promoted generation exists, the +resolver still fails explicitly. + +The dependency refresh workflow runs image publication monthly and when image +recipes change on `develop`. Changed paths are classified from the same profile +membership used to calculate the recipe fingerprints, so normal-only and +TSan-only inputs refresh only their affected cohort while shared inputs refresh +both. The monthly refresh includes TSan; weekly and `all` refreshes omit it. +The `linux-tsan` manual target selects only TSan, while `linux` and +`linux-images` select normal and ARM64 without armhf. Use the direct publisher +workflow when explicit armhf validation is needed. A monthly epoch invalidates the +package-install layer so repository security updates are not hidden by +BuildKit's cache. The direct publisher workflow also supports +retagging a retained `validated-build-*` generation as `stable` for rollback. +Promotion and rollback are restricted to `develop`; non-promoting candidate +builds may be run from another ref. + +## ccache compatibility + +The image recipe and ccache compatibility identities intentionally answer +different questions. The recipe and legacy `toolchain_id` describe the complete +image for verification and provenance. Actions-cache keys instead use the +architecture, sanitizer profile when applicable, a `gcc<major>-v2` +compatibility ID, and the immutable image generation. + +Within that archive, ccache uses a verified content signature covering the C +and C++ drivers, GCC frontends and LTO executable, assembler, their resolved +runtime-library closure, the target, and GCC specs. Compiler changes therefore +miss safely inside the compatible archive. +Source, flags, generated sources, and included header contents retain ccache's +normal per-object invalidation. Changes to unrelated image packages do not +discard otherwise compatible objects. + +A new generation first restores its own snapshot and then falls back to any +compatible older generation. The candidate build recompiles only genuine +misses and saves an augmented generation-specific snapshot before promotion. +Recipe-stale fallback builds may restore caches but are not allowed to save +them. + +## Retention + +The weekly retention job keeps `stable`, preserves unrecognized and untagged +versions, retains at least the newest three recognized package versions, and +deletes only recognized build, validated-build, and candidate versions older +than 60 days. Manual retention runs are dry-run only; scheduled runs apply the +printed plan. + +The Buildx jobs deliberately disable provenance and SBOM attachment. Even a +single-platform attestation is represented through an image index with +untagged child manifests, which cannot be safely classified from GitHub's +package-version REST response alone. diff --git a/.github/images/linux-ci/armhf-cross-toolchain.config b/.github/images/linux-ci/armhf-cross-toolchain.config new file mode 100644 index 00000000..e318e28a --- /dev/null +++ b/.github/images/linux-ci/armhf-cross-toolchain.config @@ -0,0 +1,30 @@ +CT_CONFIG_VERSION="4" +CT_LOCAL_TARBALLS_DIR="/var/cache/wsjtx-ctng" +CT_PREFIX_DIR="/opt/wsjtx/armhf-toolchain" +# CT_LOG_PROGRESS_BAR is not set +# CT_LOG_FILE_COMPRESS is not set +# Hosted x86_64 runners have 8 GiB; serializing the final GCC runtime-library +# build prevents libstdc++ and libgfortran from exhausting memory together. +CT_PARALLEL_JOBS=1 +# CI does not ship toolchain debug symbols, and omitting them further bounds the +# memory and image size of the slow, immutable toolchain-generation step. +CT_TARGET_CFLAGS="-g0" +CT_ARCH_ARM=y +CT_ARCH_ARM_MODE_THUMB=y +CT_OMIT_TARGET_VENDOR=y +CT_ARCH_ARCH="armv7-a+fp" +CT_ARCH_FLOAT_HW=y +CT_KERNEL_LINUX=y +CT_LINUX_V_6_1=y +CT_BINUTILS_V_2_40=y +CT_BINUTILS_LINKER_LD_GOLD=y +CT_BINUTILS_GOLD_THREADS=y +CT_BINUTILS_LD_WRAPPER=y +CT_BINUTILS_PLUGINS=y +CT_GLIBC_V_2_36=y +CT_GLIBC_KERNEL_VERSION_CHOSEN=y +CT_GLIBC_MIN_KERNEL_VERSION="3.2.0" +CT_GCC_V_13=y +CT_CC_GCC_LIBGOMP=y +CT_CC_LANG_CXX=y +CT_CC_LANG_FORTRAN=y diff --git a/.github/images/linux-ci/install-armhf-runtime-packages.sh b/.github/images/linux-ci/install-armhf-runtime-packages.sh new file mode 100755 index 00000000..a7a18e2e --- /dev/null +++ b/.github/images/linux-ci/install-armhf-runtime-packages.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +set -euo pipefail + +packages=( + ca-certificates curl file git python3 xz-utils + binutils cmake dpkg-dev rpm + libatomic1 libstdc++6 libgfortran5 libgomp1 + libfftw3-single3 + libboost-atomic1.74.0 libboost-chrono1.74.0 libboost-filesystem1.74.0 + libboost-log1.74.0 libboost-regex1.74.0 libboost-thread1.74.0 + libqt5widgets5 libqt5network5 libqt5multimedia5 libqt5printsupport5 libqt5test5 + libqt5multimedia5-plugins libqt5serialport5 libqt5sql5-sqlite + libqt5websockets5 qt5-qmake-bin qtbase5-dev-tools + libusb-1.0-0 libudev1 libportaudio2 + xauth xvfb +) + +/usr/local/bin/run-apt-get update +/usr/local/bin/run-apt-get install -y --no-install-recommends "${packages[@]}" +/usr/local/bin/run-apt-get clean +rm -rf /var/lib/apt/lists/* diff --git a/.github/images/linux-ci/install-packages.sh b/.github/images/linux-ci/install-packages.sh new file mode 100755 index 00000000..ed10940b --- /dev/null +++ b/.github/images/linux-ci/install-packages.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -ne 1 ]; then + echo "Usage: install-packages.sh normal|tsan" >&2 + exit 2 +fi + +normal_packages=( + ca-certificates curl git + build-essential cmake ccache + libfftw3-dev libboost-log-dev + qtbase5-dev qttools5-dev qtmultimedia5-dev libqt5serialport5-dev + libqt5sql5-sqlite libqt5websockets5-dev + libqt5multimedia5-plugins + libusb-1.0-0-dev libudev-dev + autoconf automake libtool pkg-config + texinfo + dpkg-dev + asciidoctor + rpm + python3 + file xz-utils xauth xvfb + portaudio19-dev +) + +tsan_packages=( + ca-certificates curl git xz-utils bzip2 perl python3 + build-essential binutils cmake ccache file make pkg-config xauth xvfb + gcc-13 g++-13 gfortran-13 + autoconf automake libtool texinfo + libfftw3-dev libreadline-dev libusb-1.0-0-dev portaudio19-dev + libasound2-dev libcups2-dev libdbus-1-dev libegl1-mesa-dev + libfontconfig1-dev libfreetype-dev libgl1-mesa-dev + libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev + libpulse-dev libssl-dev libudev-dev + libx11-dev libx11-xcb-dev libxcb1-dev libxcb-glx0-dev + libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev + libxcb-randr0-dev libxcb-render-util0-dev libxcb-shape0-dev + libxcb-shm0-dev libxcb-sync-dev libxcb-xfixes0-dev + libxcb-xinerama0-dev libxcb-xkb-dev + libxext-dev libxfixes-dev libxi-dev libxrender-dev + libxkbcommon-dev libxkbcommon-x11-dev +) + +case "$1" in + normal) + packages=("${normal_packages[@]}") + if ! command -v gfortran >/dev/null 2>&1; then + packages+=(gfortran) + fi + ;; + tsan) packages=("${tsan_packages[@]}") ;; + *) + echo "Unsupported Linux CI image package profile: $1" >&2 + exit 2 + ;; +esac + +/usr/local/bin/run-apt-get update +/usr/local/bin/run-apt-get install -y --no-install-recommends "${packages[@]}" +/usr/local/bin/run-apt-get clean +rm -rf /var/lib/apt/lists/* diff --git a/.github/images/linux-ci/write-manifest.sh b/.github/images/linux-ci/write-manifest.sh new file mode 100755 index 00000000..7a28887b --- /dev/null +++ b/.github/images/linux-ci/write-manifest.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -ne 4 ]; then + echo "Usage: write-manifest.sh FLAVOR ARCH GENERATION RECIPE_SHA256" >&2 + exit 2 +fi + +flavor=$1 +arch=$2 +generation=$3 +recipe_sha256=$4 + +# shellcheck source=.github/scripts/linux-ci-image-config.sh +. /usr/local/share/wsjtx-ci/linux-ci-image-config.sh +compiler_signature_helper=/usr/local/share/wsjtx-ci/linux-ccache-compiler-signature.sh + +case "$flavor" in + normal) + compiler=gcc + ;; + tsan) + # shellcheck source=.github/scripts/tsan-linux-deps-config.sh + . /usr/local/share/wsjtx-ci/tsan-linux-deps-config.sh + compiler=gcc-13 + ;; + *) + echo "Unsupported Linux CI image flavor: $flavor" >&2 + exit 2 + ;; +esac + +IFS=$'\t' read -r compiler_version compiler_target compiler_sha256 \ + ccache_compatibility_id compiler_signature_sha256 \ + < <("$compiler_signature_helper" "$compiler") +dpkg_arch="$(dpkg --print-architecture)" +case "$arch:$dpkg_arch" in + x86_64:amd64|aarch64:arm64|armhf:armhf) ;; + *) + echo "Image architecture mismatch: requested $arch, dpkg reports $dpkg_arch" >&2 + exit 1 + ;; +esac +package_sha256="$(dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort | sha256sum | awk '{print $1}')" +identity="$recipe_sha256:$compiler_target:$compiler_sha256:$package_sha256" +toolchain_sha256="$(printf '%s' "$identity" | sha256sum | awk '{print $1}')" +toolchain_id="gcc${compiler_version}-${arch}-${toolchain_sha256:0:20}" + +mkdir -p /opt/wsjtx-ci +{ + printf 'schema=%s\n' "$LINUX_CI_IMAGE_SCHEMA" + printf 'flavor=%s\n' "$flavor" + printf 'architecture=%s\n' "$arch" + printf 'generation=%s\n' "$generation" + printf 'compiler=%s\n' "$compiler" + printf 'compiler_version=%s\n' "$compiler_version" + printf 'compiler_sha256=%s\n' "$compiler_sha256" + printf 'compiler_target=%s\n' "$compiler_target" + printf 'dpkg_arch=%s\n' "$dpkg_arch" + printf 'package_sha256=%s\n' "$package_sha256" + printf 'recipe_sha256=%s\n' "$recipe_sha256" + printf 'toolchain_id=%s\n' "$toolchain_id" + printf 'ccache_compatibility_id=%s\n' "$ccache_compatibility_id" + printf 'compiler_signature_sha256=%s\n' "$compiler_signature_sha256" + if [ "$flavor" = normal ]; then + printf 'hamlib_ref=%s\n' "$LINUX_HAMLIB_REF" + printf 'hamlib_commit=%s\n' "$LINUX_HAMLIB_COMMIT" + printf 'pfunit_version=%s\n' "$LINUX_PFUNIT_VERSION" + printf 'pfunit_commit=%s\n' "$LINUX_PFUNIT_COMMIT" + else + printf 'hamlib_ref=%s\n' "$TSAN_HAMLIB_REF" + printf 'hamlib_commit=%s\n' "$TSAN_HAMLIB_COMMIT" + printf 'hamlib_patch_commit=%s\n' "$TSAN_HAMLIB_PATCH_COMMIT" + printf 'qt_version=%s\n' "$TSAN_QT_VERSION" + printf 'boost_version=%s\n' "$TSAN_BOOST_VERSION" + fi +} > /opt/wsjtx-ci/image.env diff --git a/.github/scripts/armhf-ci-image-config.sh b/.github/scripts/armhf-ci-image-config.sh new file mode 100755 index 00000000..6e97c2f0 --- /dev/null +++ b/.github/scripts/armhf-ci-image-config.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# Pinned inputs shared by the ARMHF cross-builder and runtime image pair. +# shellcheck disable=SC2034 + +_armhf_config_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +# shellcheck source=.github/scripts/linux-ci-image-config.sh +. "$_armhf_config_dir/linux-ci-image-config.sh" +unset _armhf_config_dir + +ARMHF_CI_IMAGE_SCHEMA=1 +ARMHF_CROSSTOOL_NG_VERSION=1.28.0 +ARMHF_CROSSTOOL_NG_SHA256=5750e29a2bda5cd8d67900592576b1670a1987a4dcd5e4f6beae09138a1f5699 +ARMHF_CROSSTOOL_NG_URL="https://github.com/crosstool-ng/crosstool-ng/releases/download/crosstool-ng-${ARMHF_CROSSTOOL_NG_VERSION}/crosstool-ng-${ARMHF_CROSSTOOL_NG_VERSION}.tar.xz" + +ARMHF_TARGET_TRIPLET=arm-linux-gnueabihf +ARMHF_TOOLCHAIN_PREFIX=/opt/wsjtx/armhf-toolchain +ARMHF_SYSROOT=/opt/wsjtx/armhf-sysroot +ARMHF_RUNTIME_PREFIX=/opt/wsjtx/armhf-runtime +ARMHF_QEMU_EXECUTABLE=/usr/local/bin/qemu-arm-static +ARMHF_GCC_VERSION=13.4.0 +ARMHF_GLIBC_VERSION=2.36 +ARMHF_BINUTILS_VERSION=2.40 +ARMHF_LINUX_HEADERS_VERSION=6.1.147 +ARMHF_MIN_KERNEL_VERSION=3.2.0 + +ARMHF_SYSROOT_PACKAGES=( + libc6-dev libstdc++6 libgfortran5 libgomp1 libatomic1 + libfftw3-dev libboost-log-dev + qtbase5-dev qttools5-dev qtmultimedia5-dev libqt5serialport5-dev + libqt5sql5-sqlite libqt5websockets5-dev libqt5multimedia5-plugins + libusb-1.0-0-dev libudev-dev portaudio19-dev +) + +ARMHF_GCC_RUNTIME_LIBRARIES=( + libatomic.so.1 + libgcc_s.so.1 + libgfortran.so.5 + libgomp.so.1 + libstdc++.so.6 +) diff --git a/.github/scripts/armhf-static-ldd.sh b/.github/scripts/armhf-static-ldd.sh new file mode 100755 index 00000000..bb85e6f3 --- /dev/null +++ b/.github/scripts/armhf-static-ldd.sh @@ -0,0 +1,98 @@ +#!/usr/bin/env bash +set -euo pipefail + +# linuxdeploy's ldd probe crashes when an ARM loader is nested under user-mode +# QEMU. Resolve DT_NEEDED entries from the clean ARMHF runtime without executing +# the target; packaged runtime behavior is still proved by the QEMU smoke test. + +if [ "$#" -ne 1 ]; then + echo "Usage: armhf-static-ldd.sh ELF" >&2 + exit 2 +fi + +target=$1 +runtime_prefix=${WSJT_ARMHF_RUNTIME_PREFIX:-/opt/wsjtx/armhf-runtime} +search_path=${ARMHF_STATIC_LDD_LIBRARY_PATH:-} + +base_search_directories=("$runtime_prefix") +if [ -n "$search_path" ]; then + IFS=: read -r -a configured_directories <<< "$search_path" + base_search_directories+=("${configured_directories[@]}") +fi + +status=0 +declare -A resolved_libraries=() + +resolve_dependencies() { + local elf=$1 dynamic origin line directory library resolved metadata + local -a needed=() encoded_directories=() search_directories=() + + dynamic="$(readelf -dW -- "$elf")" || exit + origin="$(dirname -- "$elf")" + while IFS= read -r line; do + if [[ "$line" =~ \(NEEDED\).*Shared[[:space:]]library:[[:space:]]\[([^]]+)\] ]]; then + needed+=("${BASH_REMATCH[1]}") + elif [[ "$line" =~ \((RUNPATH|RPATH)\).*Library[[:space:]](runpath|rpath):[[:space:]]\[([^]]+)\] ]]; then + IFS=: read -r -a encoded <<< "${BASH_REMATCH[3]}" + for directory in "${encoded[@]}"; do + # shellcheck disable=SC2016 # expand the loader's literal ORIGIN token + directory=${directory//'${ORIGIN}'/$origin} + # shellcheck disable=SC2016 # expand the loader's literal ORIGIN token + directory=${directory//'$ORIGIN'/$origin} + encoded_directories+=("$directory") + done + fi + done <<< "$dynamic" + search_directories=( + "${base_search_directories[@]}" + "${encoded_directories[@]}" + /lib/arm-linux-gnueabihf + /usr/lib/arm-linux-gnueabihf + /lib + /usr/lib + ) + + for library in "${needed[@]}"; do + if [[ "$library" == libquadmath.so* ]]; then + echo "$elf unexpectedly depends on unavailable ARMHF runtime $library" >&2 + exit 1 + fi + if [ -n "${resolved_libraries[$library]:-}" ]; then + continue + fi + + resolved= + if [[ "$library" == */* ]] && [ -f "$library" ]; then + resolved=$library + else + for directory in "${search_directories[@]}"; do + if [ -f "$directory/$library" ]; then + resolved=$directory/$library + break + fi + done + fi + + if [ -z "$resolved" ]; then + printf '%s => not found (0x00000000)\n' "$library" + status=1 + continue + fi + + metadata="$(file -L -- "$resolved")" || exit + case "$metadata" in + *"ELF 32-bit"*"ARM, EABI5"*) ;; + *) + echo "$elf resolves $library to a non-ARMHF ELF: $metadata" >&2 + exit 1 + ;; + esac + resolved_libraries[$library]=$resolved + printf '%s => %s (0x00000000)\n' "$library" "$resolved" + resolve_dependencies "$resolved" + done +} + +resolve_dependencies "$target" + +exit "$status" diff --git a/.github/scripts/audit-armhf-cross-build.sh b/.github/scripts/audit-armhf-cross-build.sh new file mode 100755 index 00000000..d8088612 --- /dev/null +++ b/.github/scripts/audit-armhf-cross-build.sh @@ -0,0 +1,104 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -ne 1 ]; then + echo "Usage: audit-armhf-cross-build.sh BUILD_DIR" >&2 + exit 2 +fi + +build_dir=$1 +toolchain_prefix=${WSJT_ARMHF_TOOLCHAIN_PREFIX:-/opt/wsjtx/armhf-toolchain} +sysroot=${WSJT_ARMHF_SYSROOT:-/opt/wsjtx/armhf-sysroot} +runtime_prefix=${WSJT_ARMHF_RUNTIME_PREFIX:-/opt/wsjtx/armhf-runtime} +triplet=arm-linux-gnueabihf +readelf="$toolchain_prefix/bin/$triplet-readelf" +object_count=0 + +while IFS= read -r -d '' object; do + headers="$("$readelf" -hW "$object")" + case "$headers" in + *"Class:"*"ELF32"*"Machine:"*"ARM"*"Version5 EABI"*) ;; + *) + echo "Target build contains a non-ARMHF object: $object" >&2 + exit 1 + ;; + esac + object_count=$((object_count + 1)) +done < <(find "$build_dir" -type f -name '*.o' -print0) +if [ "$object_count" -eq 0 ]; then + echo "No target objects found below $build_dir" >&2 + exit 1 +fi + +for tool in qmake moc uic rcc lrelease lconvert; do + metadata="$(file -L "/usr/lib/qt5/bin/$tool")" + case "$metadata" in + *"ELF 64-bit"*"x86-64"*) ;; + *) echo "Qt host tool is not x86-64: $metadata" >&2; exit 1 ;; + esac +done +for target in \ + "$sysroot/usr/lib/$triplet/libQt5Core.so.5" \ + "$sysroot/usr/lib/$triplet/libQt5Widgets.so.5" \ + "$sysroot/usr/lib/$triplet/qt5/plugins/platforms/libqxcb.so" \ + "$sysroot/usr/bin/rigctl" \ + "$sysroot/usr/bin/rigctld" \ + "$sysroot/usr/bin/rigctlcom"; do + metadata="$(file -L "$target")" + case "$metadata" in + *"ELF 32-bit"*"ARM, EABI5"*) ;; + *) echo "Target dependency has the wrong architecture: $metadata" >&2; exit 1 ;; + esac +done + +binary_count=0 +while IFS= read -r -d '' target_file; do + metadata="$(file -L "$target_file")" + case "$metadata" in + *"ELF 32-bit"*"ARM, EABI5"*) ;; + *"ELF"*) + echo "Target build contains a non-ARMHF binary: $metadata" >&2 + exit 1 + ;; + *) continue ;; + esac + dynamic="$($readelf -dW "$target_file" 2>/dev/null || true)" + if [[ "$dynamic" == *"Shared library: [libquadmath.so"* ]]; then + echo "$target_file unexpectedly depends on libquadmath" >&2 + exit 1 + fi + versions="$($readelf --version-info -W "$target_file" 2>/dev/null || true)" + if [[ "$versions" == *"GLIBC_PRIVATE"* ]]; then + echo "$target_file unexpectedly depends on a private glibc symbol" >&2 + exit 1 + fi + binary_count=$((binary_count + 1)) +done < <(find "$build_dir" -type f \( -perm /111 -o -name '*.so*' \) -print0) +if [ "$binary_count" -eq 0 ]; then + echo "No target executables or shared libraries found below $build_dir" >&2 + exit 1 +fi + +for executable in wsjtx jt9 qmap/qmap map65/map65 ft8code wsprd; do + versions="$("$readelf" --version-info -W "$build_dir/$executable")" + remaining=$versions + maximum=0 + while [[ "$remaining" =~ GLIBC_([0-9]+\.[0-9]+) ]]; do + version=${BASH_REMATCH[1]} + if dpkg --compare-versions "$version" gt "$maximum"; then + maximum=$version + fi + remaining=${remaining#*"${BASH_REMATCH[0]}"} + done + if dpkg --compare-versions "$maximum" gt 2.36; then + echo "$build_dir/$executable requires GLIBC_$maximum, newer than Bookworm" >&2 + exit 1 + fi + for runtime in libstdc++.so.6 libgcc_s.so.1 libgfortran.so.5 libgomp.so.1; do + if [[ "$versions" == *"${runtime%%.so*}"* ]]; then + test -f "$runtime_prefix/$runtime" + fi + done + echo "$executable: maximum GLIBC_$maximum" +done +echo "Audited $object_count ARMHF objects and $binary_count target binaries; Qt host tools are x86-64" diff --git a/.github/scripts/audit-staged-dll-imports-windows.sh b/.github/scripts/audit-staged-dll-imports-windows.sh index b16adaca..ca8b75f2 100644 --- a/.github/scripts/audit-staged-dll-imports-windows.sh +++ b/.github/scripts/audit-staged-dll-imports-windows.sh @@ -50,6 +50,23 @@ for exe in "$@"; do echo "(none)" fi + win7_blocked_imports=$( + objdump -p "$exe" | + awk ' + /DLL Name:/ { dll=tolower($3) } + /api-ms-win-core-synch-l1-2-0\.dll/ { print "api-ms-win-core-synch-l1-2-0.dll" } + /WaitOnAddress/ { print dll "::WaitOnAddress" } + /WakeByAddressSingle/ { print dll "::WakeByAddressSingle" } + ' | + sort -u + ) + + if [ -n "$win7_blocked_imports" ]; then + echo "::error::$exe imports Windows 8+ synchronization APIs that block Windows 7 compatibility:" + echo "$win7_blocked_imports" + fail=1 + fi + high_risk=$( echo "$imports" | awk '{ lower=tolower($0); if (lower ~ /^(libgomp|libgfortran|libgcc_s|libquadmath|libportaudio|libhamlib|libfftw|qt5.*\.dll)/) print lower }' | diff --git a/.github/scripts/build-armhf-toolchain-smoke.sh b/.github/scripts/build-armhf-toolchain-smoke.sh new file mode 100755 index 00000000..3cfaa4d2 --- /dev/null +++ b/.github/scripts/build-armhf-toolchain-smoke.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -ne 3 ]; then + echo "Usage: build-armhf-toolchain-smoke.sh TOOLCHAIN_PREFIX SYSROOT OUTPUT_DIR" >&2 + exit 2 +fi + +toolchain_prefix=$1 +sysroot=$2 +output_dir=$3 +triplet=arm-linux-gnueabihf +compiler_prefix="$toolchain_prefix/bin/$triplet" +target_include="$sysroot/usr/include/$triplet" +target_lib="$sysroot/usr/lib/$triplet" +target_base_lib="$sysroot/lib/$triplet" +common_flags=( + "--sysroot=$sysroot" + -isystem "$target_include" + "-B$target_lib/" + "-L$target_lib" + "-Wl,-rpath-link,$target_lib" + "-Wl,-rpath-link,$target_base_lib" +) + +mkdir -p "$output_dir" +source_dir="$(mktemp -d)" +trap 'rm -rf "$source_dir"' EXIT + +cat > "$source_dir/c.c" <<'EOF' +#include <stdatomic.h> +#include <stdio.h> +int main(void) { + _Atomic long long value = 41; + printf("c atomic: %lld\n", atomic_fetch_add(&value, 1) + 1); + return 0; +} +EOF +cat > "$source_dir/cxx.cpp" <<'EOF' +#include <iostream> +#include <numeric> +#include <vector> +int main() { + std::vector<int> values{1, 2, 3, 4}; + std::cout << "c++ standard library: " + << std::accumulate(values.begin(), values.end(), 0) << '\n'; + return 0; +} +EOF +cat > "$source_dir/fortran.f90" <<'EOF' +program fortran_smoke + use omp_lib + implicit none + integer :: i, total + total = 0 + !$omp parallel do reduction(+:total) + do i = 1, 4 + total = total + i + end do + !$omp end parallel do + print '(A,I0)', 'fortran openmp: ', total +end program fortran_smoke +EOF + +"${compiler_prefix}-gcc" "${common_flags[@]}" "$source_dir/c.c" -latomic \ + -o "$output_dir/c-smoke" +"${compiler_prefix}-g++" "${common_flags[@]}" "$source_dir/cxx.cpp" \ + -o "$output_dir/cxx-smoke" +"${compiler_prefix}-gfortran" "${common_flags[@]}" -fopenmp \ + "$source_dir/fortran.f90" -o "$output_dir/fortran-smoke" + +for executable in "$output_dir"/*-smoke; do + metadata="$(file "$executable")" + headers="$("${compiler_prefix}-readelf" -hW "$executable")" + programs="$("${compiler_prefix}-readelf" -lW "$executable")" + case "$metadata:$headers:$programs" in + *"ELF 32-bit"*"ARM, EABI5"*"hard-float ABI"*"/lib/ld-linux-armhf.so.3"*) ;; + *) + echo "ARMHF toolchain smoke output has invalid ABI metadata: $executable" >&2 + exit 1 + ;; + esac +done diff --git a/.github/scripts/build-boost-macos.sh b/.github/scripts/build-boost-macos.sh index 06e9de1a..c3b876f0 100755 --- a/.github/scripts/build-boost-macos.sh +++ b/.github/scripts/build-boost-macos.sh @@ -1,15 +1,16 @@ #!/usr/bin/env bash set -euo pipefail -if [ "$#" -ne 4 ]; then - echo "Usage: build-boost-macos.sh VERSION ARCH DEPLOYMENT_TARGET PREFIX" >&2 +if [ "$#" -ne 5 ]; then + echo "Usage: build-boost-macos.sh VERSION SOURCE_SHA256 ARCH DEPLOYMENT_TARGET PREFIX" >&2 exit 2 fi version="$1" -arch="$2" -deployment_target="$3" -prefix="$4" +source_sha256="$2" +arch="$3" +deployment_target="$4" +prefix="$5" version_underscores=${version//./_} boost_arch=x86 @@ -17,7 +18,25 @@ if [ "$arch" = "arm64" ]; then boost_arch=arm fi +sha256_file() { + if command -v shasum >/dev/null 2>&1; then + shasum -a 256 "$1" | awk '{print $1}' + elif command -v sha256sum >/dev/null 2>&1; then + sha256sum "$1" | awk '{print $1}' + else + echo "No SHA-256 tool found; expected shasum or sha256sum" >&2 + return 1 + fi +} + curl -L --fail --retry 5 --retry-delay 10 -o boost.tar.bz2 "https://archives.boost.io/release/${version}/source/boost_${version_underscores}.tar.bz2" +actual_sha256="$(sha256_file boost.tar.bz2)" +if [ "$actual_sha256" != "$source_sha256" ]; then + echo "::error::Boost source SHA-256 mismatch" >&2 + echo "Expected: ${source_sha256}" >&2 + echo "Actual: ${actual_sha256}" >&2 + exit 1 +fi tar -xjf boost.tar.bz2 cd "boost_${version_underscores}" diff --git a/.github/scripts/build-boost-tsan-linux.sh b/.github/scripts/build-boost-tsan-linux.sh new file mode 100755 index 00000000..3139b370 --- /dev/null +++ b/.github/scripts/build-boost-tsan-linux.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -ne 1 ]; then + echo "Usage: build-boost-tsan-linux.sh PREFIX" >&2 + exit 2 +fi + +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +# shellcheck source=.github/scripts/tsan-linux-deps-config.sh +. "${script_dir}/tsan-linux-deps-config.sh" + +prefix=$1 +tsan_require_toolchain + +if [ -e "$prefix" ] && [ -n "$(ls -A "$prefix")" ]; then + echo "Boost TSan prefix already exists and is not empty: $prefix" >&2 + exit 1 +fi + +build_root="$(mktemp -d "${RUNNER_TEMP:-/tmp}/wsjtx-boost-tsan.XXXXXX")" +archive="${build_root}/boost.tar.bz2" +version_underscores=${TSAN_BOOST_VERSION//./_} + +mkdir -p "$prefix" +curl -L --fail --retry 5 --retry-delay 10 \ + -o "$archive" "$TSAN_BOOST_SOURCE_URL" + +actual_sha256="$(sha256sum "$archive" | awk '{print $1}')" +if [ "$actual_sha256" != "$TSAN_BOOST_SOURCE_SHA256" ]; then + echo "Boost source SHA-256 mismatch" >&2 + echo "Expected: $TSAN_BOOST_SOURCE_SHA256" >&2 + echo "Actual: $actual_sha256" >&2 + exit 1 +fi + +tar -xjf "$archive" -C "$build_root" +cd "${build_root}/boost_${version_underscores}" + +printf 'using gcc : %s : %s ;\n' "$TSAN_GCC_SUFFIX" "$TSAN_CXX" > user-config.jam +./bootstrap.sh --prefix="$prefix" --with-libraries=log +./b2 -j"$(nproc)" \ + --user-config="${PWD}/user-config.jam" \ + toolset="gcc-${TSAN_GCC_SUFFIX}" \ + variant=release \ + link=shared \ + runtime-link=shared \ + threading=multi \ + cxxstd=11 \ + cxxflags="$TSAN_SANITIZER_FLAGS" \ + linkflags="$TSAN_LINK_FLAGS" \ + --layout=system \ + install + +tsan_write_dependency_manifest boost "$prefix" diff --git a/.github/scripts/build-boost-windows.sh b/.github/scripts/build-boost-windows.sh new file mode 100755 index 00000000..0e56b920 --- /dev/null +++ b/.github/scripts/build-boost-windows.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -ne 4 ]; then + echo "Usage: build-boost-windows.sh VERSION SOURCE_SHA256 WIN32_WINNT PREFIX" >&2 + exit 2 +fi + +version="$1" +source_sha256="$2" +win32_winnt="$3" +prefix="$4" +version_underscores=${version//./_} +api_floor_flags="-D_WIN32_WINNT=${win32_winnt} -DWINVER=${win32_winnt} -DBOOST_USE_WINAPI_VERSION=${win32_winnt}" +install_prefix=$(cygpath -m "$prefix") + +sha256_file() { + if command -v sha256sum >/dev/null 2>&1; then + sha256sum "$1" | awk '{print $1}' + elif command -v shasum >/dev/null 2>&1; then + shasum -a 256 "$1" | awk '{print $1}' + else + echo "No SHA-256 tool found; expected sha256sum or shasum" >&2 + return 1 + fi +} + +curl -L --fail --retry 5 --retry-delay 10 -o boost.tar.bz2 "https://archives.boost.io/release/${version}/source/boost_${version_underscores}.tar.bz2" +actual_sha256="$(sha256_file boost.tar.bz2)" +if [ "$actual_sha256" != "$source_sha256" ]; then + echo "::error::Boost source SHA-256 mismatch" >&2 + echo "Expected: ${source_sha256}" >&2 + echo "Actual: ${actual_sha256}" >&2 + exit 1 +fi +tar -xjf boost.tar.bz2 +cd "boost_${version_underscores}" + +python3 - <<'PY' +from pathlib import Path + +platform = Path("boost/atomic/detail/platform.hpp") +text = platform.read_text() +old = """#if defined(BOOST_WINDOWS) + +#define BOOST_ATOMIC_DETAIL_WAIT_BACKEND windows + +#else // defined(BOOST_WINDOWS) +""" +new = """#if defined(BOOST_WINDOWS) + +#include <boost/winapi/config.hpp> +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN8 +#define BOOST_ATOMIC_DETAIL_WAIT_BACKEND windows +#endif + +#else // defined(BOOST_WINDOWS) +""" +if old not in text: + raise SystemExit("Boost.Atomic Windows wait backend block not found") +platform.write_text(text.replace(old, new, 1)) + +jamfile = Path("libs/atomic/build/Jamfile.v2") +text = jamfile.read_text() +for line in ( + " <target-os>windows:<library>synchronization\n", + " <toolset>gcc,<target-os>windows:<define>_WIN32_WINNT=0x0A00\n", +): + if line not in text: + raise SystemExit(f"Boost.Atomic Jamfile line not found: {line.rstrip()}") + text = text.replace(line, "", 2) +jamfile.write_text(text) +PY + +./bootstrap.sh --prefix="$install_prefix" --with-libraries=log +./b2 --with-log -j"$(nproc)" \ + toolset=gcc \ + variant=release \ + link=shared \ + runtime-link=shared \ + threading=multi \ + cxxstd=11 \ + address-model=64 \ + --layout=tagged \ + cflags="${api_floor_flags}" \ + cxxflags="${api_floor_flags}" \ + install diff --git a/.github/scripts/build-hamlib-armhf-cross.sh b/.github/scripts/build-hamlib-armhf-cross.sh new file mode 100755 index 00000000..00e80453 --- /dev/null +++ b/.github/scripts/build-hamlib-armhf-cross.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -ne 3 ]; then + echo "Usage: build-hamlib-armhf-cross.sh COMMIT SYSROOT TOOLCHAIN_PREFIX" >&2 + exit 2 +fi + +commit=$1 +sysroot=$2 +toolchain_prefix=$3 +triplet=arm-linux-gnueabihf +target_include="$sysroot/usr/include/$triplet" +target_lib="$sysroot/usr/lib/$triplet" +target_base_lib="$sysroot/lib/$triplet" + +export PATH="$toolchain_prefix/bin:$PATH" +export PKG_CONFIG_SYSROOT_DIR="$sysroot" +export PKG_CONFIG_PATH= +export PKG_CONFIG_LIBDIR="$target_lib/pkgconfig:$sysroot/usr/share/pkgconfig" + +git init hamlib-src +git -C hamlib-src remote add origin https://github.com/Hamlib/Hamlib.git +git -C hamlib-src fetch --depth 1 origin "$commit" +git -C hamlib-src checkout --detach FETCH_HEAD +actual_commit="$(git -C hamlib-src rev-parse HEAD)" +if [ "$actual_commit" != "$commit" ]; then + echo "Hamlib source mismatch: expected $commit, got $actual_commit" >&2 + exit 1 +fi + +cd hamlib-src +./bootstrap +./configure \ + --build=x86_64-pc-linux-gnu \ + --host="$triplet" \ + --prefix=/usr \ + --disable-shared --enable-static \ + --without-cxx-binding \ + --without-readline \ + --without-indi \ + CC="${triplet}-gcc" \ + CXX="${triplet}-g++" \ + AR="${triplet}-ar" \ + NM="${triplet}-nm" \ + OBJDUMP="${triplet}-objdump" \ + RANLIB="${triplet}-ranlib" \ + STRIP="${triplet}-strip" \ + CFLAGS="--sysroot=$sysroot -isystem $target_include -g -O2 -fPIC -fdata-sections -ffunction-sections" \ + CXXFLAGS="--sysroot=$sysroot -isystem $target_include -g -O2 -fPIC -fdata-sections -ffunction-sections" \ + LDFLAGS="--sysroot=$sysroot -B$target_lib/ -L$target_lib -Wl,-rpath-link,$target_lib -Wl,-rpath-link,$target_base_lib -Wl,--gc-sections" +make -j"$(nproc)" +make DESTDIR="$sysroot" install + +for utility in rigctl rigctld rigctlcom; do + metadata="$(file "$sysroot/usr/bin/$utility")" + case "$metadata" in + *"ELF 32-bit"*"ARM, EABI5"*) ;; + *) + echo "Cross-built Hamlib utility has the wrong architecture: $metadata" >&2 + exit 1 + ;; + esac +done +test -f "$sysroot/usr/lib/libhamlib.a" diff --git a/.github/scripts/build-hamlib-linux.sh b/.github/scripts/build-hamlib-linux.sh new file mode 100755 index 00000000..11676c56 --- /dev/null +++ b/.github/scripts/build-hamlib-linux.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -ne 2 ]; then + echo "Usage: build-hamlib-linux.sh REF PREFIX" >&2 + exit 2 +fi + +ref="$1" +prefix="$2" + +git init hamlib-src +git -C hamlib-src remote add origin https://github.com/Hamlib/Hamlib.git +git -C hamlib-src fetch --depth 1 origin "$ref" +git -C hamlib-src checkout --detach FETCH_HEAD +actual_commit="$(git -C hamlib-src rev-parse HEAD)" +if [[ "$ref" =~ ^[0-9a-f]{40}$ ]] && [ "$actual_commit" != "$ref" ]; then + echo "Hamlib source mismatch: expected $ref, got $actual_commit" >&2 + exit 1 +fi +cd hamlib-src +./bootstrap +./configure \ + --prefix="$prefix" \ + --disable-shared --enable-static \ + --without-cxx-binding \ + --without-readline \ + --without-indi \ + CFLAGS="-g -O2 -fPIC -fdata-sections -ffunction-sections" \ + LDFLAGS="-Wl,--gc-sections" +make -j"$(nproc)" +make install diff --git a/.github/scripts/build-hamlib-macos.sh b/.github/scripts/build-hamlib-macos.sh index 637492e4..525f3ebf 100755 --- a/.github/scripts/build-hamlib-macos.sh +++ b/.github/scripts/build-hamlib-macos.sh @@ -1,14 +1,15 @@ #!/usr/bin/env bash set -euo pipefail -if [ "$#" -ne 3 ]; then - echo "Usage: build-hamlib-macos.sh BRANCH DEPLOYMENT_TARGET PREFIX" >&2 +if [ "$#" -ne 4 ]; then + echo "Usage: build-hamlib-macos.sh BRANCH DEPLOYMENT_TARGET PREFIX LIBUSB_PREFIX" >&2 exit 2 fi branch="$1" deployment_target="$2" prefix="$3" +libusb_prefix="$4" git clone --depth 1 --branch "$branch" \ https://github.com/Hamlib/Hamlib.git hamlib-src @@ -18,7 +19,9 @@ cd hamlib-src --prefix="$prefix" \ --disable-shared --enable-static \ --without-cxx-binding \ + PKG_CONFIG_PATH="${libusb_prefix}/lib/pkgconfig" \ + CPPFLAGS="-I${libusb_prefix}/include" \ CFLAGS="-mmacosx-version-min=${deployment_target}" \ - LDFLAGS="-mmacosx-version-min=${deployment_target}" + LDFLAGS="-L${libusb_prefix}/lib -mmacosx-version-min=${deployment_target} -Wl,-headerpad_max_install_names" make -j"$(sysctl -n hw.ncpu)" make install diff --git a/.github/scripts/build-hamlib-tsan-linux.sh b/.github/scripts/build-hamlib-tsan-linux.sh new file mode 100755 index 00000000..d3b37d57 --- /dev/null +++ b/.github/scripts/build-hamlib-tsan-linux.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -ne 1 ]; then + echo "Usage: build-hamlib-tsan-linux.sh PREFIX" >&2 + exit 2 +fi + +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +# shellcheck source=.github/scripts/tsan-linux-deps-config.sh +. "${script_dir}/tsan-linux-deps-config.sh" + +prefix=$1 +tsan_require_toolchain + +if [ -e "$prefix" ] && [ -n "$(ls -A "$prefix")" ]; then + echo "Hamlib TSan prefix already exists and is not empty: $prefix" >&2 + exit 1 +fi + +build_root="$(mktemp -d "${RUNNER_TEMP:-/tmp}/wsjtx-hamlib-tsan.XXXXXX")" +source_dir="${build_root}/hamlib-src" +mkdir -p "$prefix" "$source_dir" + +git -C "$source_dir" init +git -C "$source_dir" remote add origin https://github.com/Hamlib/Hamlib.git +git -C "$source_dir" fetch --depth 1 origin "$TSAN_HAMLIB_COMMIT" +git -C "$source_dir" checkout --detach FETCH_HEAD + +actual_commit="$(git -C "$source_dir" rev-parse HEAD)" +if [ "$actual_commit" != "$TSAN_HAMLIB_COMMIT" ]; then + echo "Hamlib source commit mismatch: expected $TSAN_HAMLIB_COMMIT, got $actual_commit" >&2 + exit 1 +fi + +git -C "$source_dir" fetch --depth 2 origin "$TSAN_HAMLIB_PATCH_COMMIT" +git -C "$source_dir" cherry-pick --no-commit "$TSAN_HAMLIB_PATCH_COMMIT" + +cd "$source_dir" +./bootstrap +./configure \ + --prefix="$prefix" \ + --disable-shared --enable-static \ + --without-indi \ + --without-cxx-binding \ + CC="$TSAN_CC" \ + CFLAGS="${TSAN_SANITIZER_FLAGS} -fPIC -fdata-sections -ffunction-sections" \ + LDFLAGS="${TSAN_LINK_FLAGS} -Wl,--gc-sections" +make -j"$(nproc)" +make install + +tsan_write_dependency_manifest hamlib "$prefix" diff --git a/.github/scripts/build-hamlib-windows.sh b/.github/scripts/build-hamlib-windows.sh new file mode 100755 index 00000000..a4240998 --- /dev/null +++ b/.github/scripts/build-hamlib-windows.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -ne 2 ]; then + echo "Usage: build-hamlib-windows.sh BRANCH PREFIX" >&2 + exit 2 +fi + +branch="$1" +prefix="$2" + +git clone --depth 1 --branch "$branch" \ + https://github.com/Hamlib/Hamlib.git hamlib-src +cd hamlib-src +./bootstrap +./configure \ + --prefix="$prefix" \ + --enable-shared --disable-static \ + --without-cxx-binding \ + --without-readline \ + CFLAGS="-DNDEBUG -g -O2 -fdata-sections -ffunction-sections" \ + LDFLAGS="-Wl,--gc-sections" +make -j"$(nproc)" +make install-strip diff --git a/.github/scripts/build-linux-armhf-cross.sh b/.github/scripts/build-linux-armhf-cross.sh new file mode 100755 index 00000000..cfbb2f03 --- /dev/null +++ b/.github/scripts/build-linux-armhf-cross.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +set -euo pipefail + +VERSION="${VERSION:?missing}" +ARCH="${ARCH:?missing}" +HAMLIB_BRANCH="${HAMLIB_BRANCH:?missing}" +WSJT_RELEASE_CHANNEL="${WSJT_RELEASE_CHANNEL:-DEVEL}" +WSJT_RC_NUMBER="${WSJT_RC_NUMBER:-}" +if [ "$ARCH" != armhf ]; then + echo "build-linux-armhf-cross.sh supports only arch=armhf" >&2 + exit 2 +fi + +unset GITHUB_TOKEN +cd /work +# shellcheck source=.github/scripts/armhf-ci-image-config.sh +source .github/scripts/armhf-ci-image-config.sh +# shellcheck source=.github/scripts/linux-artifact-validation.sh +source .github/scripts/linux-artifact-validation.sh +.github/scripts/verify-armhf-ci-image.sh cross-builder "$ARCH" "$HAMLIB_BRANCH" + +export CC="$ARMHF_TOOLCHAIN_PREFIX/bin/$ARMHF_TARGET_TRIPLET-gcc" +export CXX="$ARMHF_TOOLCHAIN_PREFIX/bin/$ARMHF_TARGET_TRIPLET-g++" +export FC="$ARMHF_TOOLCHAIN_PREFIX/bin/$ARMHF_TARGET_TRIPLET-gfortran" +for compiler in "$CC" "$CXX" "$FC"; do + version="$("$compiler" -dumpfullversion -dumpversion)" + if [ "$version" != "$ARMHF_GCC_VERSION" ]; then + echo "Expected GCC $ARMHF_GCC_VERSION, found $version at $compiler" >&2 + exit 1 + fi +done + +export CCACHE_DIR="${CCACHE_DIR:-/work/.ccache-armhf}" +mkdir -p "$CCACHE_DIR" +ccache --zero-stats +started="$(date +%s)" +cmake -S . -B wsjtx-build \ + -DCMAKE_TOOLCHAIN_FILE=/work/.github/cmake/armhf-toolchain.cmake \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DWSJT_SKIP_MANPAGES=ON \ + -DWSJT_ENABLE_TESTS=ON \ + -DWSJT_FORTRAN_LIBRARY_VARIANTS=OPENMP_ONLY \ + -DWSJT_RELEASE_CHANNEL="$WSJT_RELEASE_CHANNEL" \ + -DWSJT_RC_NUMBER="$WSJT_RC_NUMBER" \ + -Wno-dev +cmake --build wsjtx-build --parallel "$(nproc)" +ended="$(date +%s)" +{ + printf 'started_epoch=%s\n' "$started" + printf 'ended_epoch=%s\n' "$ended" + printf 'duration_seconds=%s\n' "$((ended - started))" +} > wsjtx-build/armhf-cross-build-timing.env +ccache --show-stats + +validate_linux_build_executables wsjtx-build "$ARCH" +.github/scripts/audit-armhf-cross-build.sh wsjtx-build +echo "::group::Prepare ARMHF AppDir" +cmake --install wsjtx-build --prefix /work/AppDir/usr +validate_linux_application_tree AppDir appdir "$ARCH" +echo "::endgroup::" +echo "ARMHF cross-build complete for version=$VERSION" diff --git a/.github/scripts/build-pfunit-linux.sh b/.github/scripts/build-pfunit-linux.sh new file mode 100755 index 00000000..4020fca8 --- /dev/null +++ b/.github/scripts/build-pfunit-linux.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -ne 2 ]; then + echo "Usage: build-pfunit-linux.sh REF PREFIX" >&2 + exit 2 +fi + +ref="$1" +prefix="$2" + +git init pfunit-src +git -C pfunit-src remote add origin \ + https://github.com/Goddard-Fortran-Ecosystem/pFUnit.git +git -C pfunit-src fetch --depth 1 origin "$ref" +git -C pfunit-src checkout --detach FETCH_HEAD +actual_commit="$(git -C pfunit-src rev-parse HEAD)" +if [[ "$ref" =~ ^[0-9a-f]{40}$ ]] && [ "$actual_commit" != "$ref" ]; then + echo "pFUnit source mismatch: expected $ref, got $actual_commit" >&2 + exit 1 +fi +git -C pfunit-src submodule update --init --recursive --depth 1 +cmake -S pfunit-src -B pfunit-build \ + -DSKIP_MPI=YES \ + -DSKIP_OPENMP=YES \ + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ + -DCMAKE_INSTALL_PREFIX="$prefix" +cmake --build pfunit-build -j"$(nproc)" +cmake --install pfunit-build diff --git a/.github/scripts/build-pfunit-macos.sh b/.github/scripts/build-pfunit-macos.sh new file mode 100755 index 00000000..0b53fdf8 --- /dev/null +++ b/.github/scripts/build-pfunit-macos.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -lt 4 ] || [ "$#" -gt 6 ]; then + echo "Usage: build-pfunit-macos.sh TAG FORTRAN_COMPILER DEPLOYMENT_TARGET PREFIX [FORTRAN_FLAGS] [LINKER_FLAGS]" >&2 + exit 2 +fi + +tag="$1" +fortran_compiler="$2" +deployment_target="$3" +prefix="$4" +fortran_flags="${5:-}" +linker_flags="${6:-}" + +git clone --depth 1 --branch "$tag" --recursive \ + https://github.com/Goddard-Fortran-Ecosystem/pFUnit.git pfunit-src + +gftl_shared_v1_cmake="pfunit-src/extern/fArgParse/extern/gFTL-shared/src/v1/CMakeLists.txt" +if [ -f "$gftl_shared_v1_cmake" ]; then + gftl_shared_v1_cmake_tmp="${gftl_shared_v1_cmake}.tmp" + awk ' + $0 == "add_executable (demo.x demo.F90)" { + print "add_executable (demo.x EXCLUDE_FROM_ALL demo.F90)" + replaced = 1 + next + } + { print } + END { if (!replaced) exit 42 } + ' "$gftl_shared_v1_cmake" > "$gftl_shared_v1_cmake_tmp" || { + echo "::error::Could not exclude gFTL-shared demo.x from the pFUnit dependency build" + exit 1 + } + mv "$gftl_shared_v1_cmake_tmp" "$gftl_shared_v1_cmake" +fi + +cmake -S pfunit-src -B pfunit-build \ + -DSKIP_MPI=YES \ + -DSKIP_OPENMP=YES \ + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ + -DCMAKE_C_COMPILER=/usr/bin/cc \ + -DCMAKE_Fortran_COMPILER="$fortran_compiler" \ + -DCMAKE_Fortran_FLAGS="$fortran_flags" \ + -DCMAKE_EXE_LINKER_FLAGS="$linker_flags" \ + -DCMAKE_OSX_DEPLOYMENT_TARGET="$deployment_target" \ + -DCMAKE_INSTALL_PREFIX="$prefix" +cmake --build pfunit-build -j"$(sysctl -n hw.ncpu)" +cmake --install pfunit-build diff --git a/.github/scripts/build-pfunit-windows.sh b/.github/scripts/build-pfunit-windows.sh new file mode 100755 index 00000000..90504e01 --- /dev/null +++ b/.github/scripts/build-pfunit-windows.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -ne 2 ]; then + echo "Usage: build-pfunit-windows.sh TAG PREFIX" >&2 + exit 2 +fi + +tag="$1" +prefix="$2" + +git config --global core.longpaths true +git clone --depth 1 --branch "$tag" --recursive \ + https://github.com/Goddard-Fortran-Ecosystem/pFUnit.git pfunit-src +cmake -S pfunit-src -B pfunit-build -G "MSYS Makefiles" \ + -DSKIP_MPI=YES \ + -DSKIP_OPENMP=YES \ + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ + -DCMAKE_INSTALL_PREFIX="$prefix" +cmake --build pfunit-build -j"$(nproc)" +cmake --install pfunit-build diff --git a/.github/scripts/build-qt-macos.sh b/.github/scripts/build-qt-macos.sh index 3bc0434b..f60f821e 100755 --- a/.github/scripts/build-qt-macos.sh +++ b/.github/scripts/build-qt-macos.sh @@ -161,9 +161,8 @@ jobs="$(sysctl -n hw.ncpu)" make -j"$jobs" make install -"${prefix}/bin/qmake" -query -"${prefix}/bin/qmake" -query QT_VERSION | awk -v expected="$QT_VERSION" ' +"${prefix}/bin/qtpaths" --qt-version | awk -v expected="$QT_VERSION" ' $0 != expected { - printf "Expected qmake QT_VERSION %s, got %s\n", expected, $0 > "/dev/stderr" + printf "Expected Qt version %s, got %s\n", expected, $0 > "/dev/stderr" exit 1 }' diff --git a/.github/scripts/build-qt-tsan-linux.sh b/.github/scripts/build-qt-tsan-linux.sh new file mode 100755 index 00000000..d2c3d756 --- /dev/null +++ b/.github/scripts/build-qt-tsan-linux.sh @@ -0,0 +1,135 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -ne 1 ]; then + echo "Usage: build-qt-tsan-linux.sh PREFIX" >&2 + exit 2 +fi + +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +# shellcheck source=.github/scripts/tsan-linux-deps-config.sh +. "${script_dir}/tsan-linux-deps-config.sh" + +prefix=$1 +tsan_require_toolchain + +if [ -e "$prefix" ] && [ -n "$(ls -A "$prefix")" ]; then + echo "Qt TSan prefix already exists and is not empty: $prefix" >&2 + exit 1 +fi + +build_root="$(mktemp -d "${RUNNER_TEMP:-/tmp}/wsjtx-qt-tsan.XXXXXX")" +archive="${build_root}/qt-everywhere-opensource-src-${TSAN_QT_VERSION}.tar.xz" + +cleanup_build_root() { + local expected_root=${RUNNER_TEMP:-/tmp} + if [[ $build_root != "$expected_root"/wsjtx-qt-tsan.* ]]; then + echo "Refusing to remove unexpected Qt build directory: $build_root" >&2 + return 1 + fi + rm -rf -- "$build_root" +} + +trap cleanup_build_root EXIT +mkdir -p "$prefix" + +curl -L --fail --retry 5 --retry-delay 10 \ + -o "$archive" "$TSAN_QT_SOURCE_URL" + +actual_sha256="$(sha256sum "$archive" | awk '{print $1}')" +if [ "$actual_sha256" != "$TSAN_QT_SOURCE_SHA256" ]; then + echo "Qt source SHA-256 mismatch" >&2 + echo "Expected: $TSAN_QT_SOURCE_SHA256" >&2 + echo "Actual: $actual_sha256" >&2 + exit 1 +fi + +tar -xf "$archive" -C "$build_root" +rm -f "$archive" +source_dir="${build_root}/qt-everywhere-src-${TSAN_QT_VERSION}" +if [ ! -d "$source_dir" ]; then + source_dir="${build_root}/qt-everywhere-opensource-src-${TSAN_QT_VERSION}" +fi +if [ ! -d "$source_dir" ]; then + echo "Could not locate extracted Qt source under $build_root" >&2 + exit 1 +fi + +cd "$source_dir" +export CC="$TSAN_CC" +export CXX="$TSAN_CXX" +export CFLAGS="$TSAN_SANITIZER_FLAGS" +export CXXFLAGS="$TSAN_SANITIZER_FLAGS" +export LDFLAGS="$TSAN_LINK_FLAGS" + +configure_args=( + -opensource + -confirm-license + -release + -shared + -prefix "$prefix" + -sanitize thread + -force-debug-info + -no-strip + "QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO=-O1 -g1" + "QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO=-O1 -g1" + -nomake examples + -nomake tests + -qt-zlib + -qt-libpng + -qt-libjpeg + -qt-pcre + -qt-harfbuzz + -qt-sqlite + -no-sql-mysql + -no-sql-psql + -openssl-runtime + -skip qt3d + -skip qtactiveqt + -skip qtandroidextras + -skip qtcharts + -skip qtconnectivity + -skip qtdatavis3d + -skip qtdeclarative + -skip qtdoc + -skip qtgamepad + -skip qtgraphicaleffects + -skip qtimageformats + -skip qtlocation + -skip qtlottie + -skip qtmacextras + -skip qtnetworkauth + -skip qtpurchasing + -skip qtquick3d + -skip qtquickcontrols + -skip qtquickcontrols2 + -skip qtquicktimeline + -skip qtremoteobjects + -skip qtscript + -skip qtscxml + -skip qtsensors + -skip qtserialbus + -skip qtspeech + -skip qtvirtualkeyboard + -skip qtwayland + -skip qtwebchannel + -skip qtwebengine + -skip qtwebglplugin + -skip qtwebview + -skip qtx11extras + -skip qtxmlpatterns +) + +./configure "${configure_args[@]}" +make -j"$(nproc)" +make install + +actual_version="$("${prefix}/bin/qtpaths" --qt-version)" +if [ "$actual_version" != "$TSAN_QT_VERSION" ]; then + echo "Qt version mismatch: expected $TSAN_QT_VERSION, got $actual_version" >&2 + exit 1 +fi + +tsan_write_dependency_manifest qt "$prefix" +cleanup_build_root +trap - EXIT diff --git a/.github/scripts/check-candidate-tag.sh b/.github/scripts/check-candidate-tag.sh new file mode 100755 index 00000000..860f91f2 --- /dev/null +++ b/.github/scripts/check-candidate-tag.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +set -euo pipefail + +if [ "$#" -ne 2 ]; then + echo "Usage: check-candidate-tag.sh TAG EXPECTED_SHA" >&2 + exit 2 +fi + +tag=$1 +expected_sha=$2 +ref="refs/tags/$tag" + +if git show-ref --verify --quiet "$ref"; then + if ! current=$(git rev-parse --verify --quiet "$ref^{commit}"); then + echo "::error::$tag does not identify a commit" >&2 + exit 1 + fi + if [ "$current" != "$expected_sha" ]; then + echo "::error::$tag already exists at $current; release tags are never moved" >&2 + exit 1 + fi + printf 'exists=true\n' + printf '%s already identifies %s; creation is idempotently satisfied.\n' "$tag" "$expected_sha" >&2 +else + status=$? + if [ "$status" -ne 1 ]; then + echo "::error::Could not inspect $ref (git show-ref exited $status)" >&2 + exit "$status" + fi + printf 'exists=false\n' +fi diff --git a/.github/scripts/deploy-macos-app.sh b/.github/scripts/deploy-macos-app.sh new file mode 100755 index 00000000..f4eaaae7 --- /dev/null +++ b/.github/scripts/deploy-macos-app.sh @@ -0,0 +1,243 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +usage() { + cat <<'USAGE' +Usage: deploy-macos-app.sh --app PATH --workspace-prefix PATH --qt-prefix PATH --boost-prefix PATH --fftw-prefix PATH --libusb-prefix PATH --portaudio-prefix PATH --fortran-prefix PATH --gcc-lib PATH [--fortran-original-prefix PATH] [--homebrew-prefix PATH] +USAGE +} + +APP="" +WORKSPACE_PREFIX="${GITHUB_WORKSPACE:-}" +QT_PREFIX="" +BOOST_PREFIX="" +FFTW_PREFIX="" +LIBUSB_PREFIX="" +PORTAUDIO_PREFIX="" +FORTRAN_PREFIX="" +FORTRAN_ORIGINAL_PREFIX="" +GCC_LIB="" +HOMEBREW_PREFIX="${HOMEBREW_PREFIX:-}" + +while [ "$#" -gt 0 ]; do + case "$1" in + --app) APP="$2"; shift 2 ;; + --workspace-prefix) WORKSPACE_PREFIX="$2"; shift 2 ;; + --qt-prefix) QT_PREFIX="$2"; shift 2 ;; + --boost-prefix) BOOST_PREFIX="$2"; shift 2 ;; + --fftw-prefix) FFTW_PREFIX="$2"; shift 2 ;; + --libusb-prefix) LIBUSB_PREFIX="$2"; shift 2 ;; + --portaudio-prefix) PORTAUDIO_PREFIX="$2"; shift 2 ;; + --fortran-prefix) FORTRAN_PREFIX="$2"; shift 2 ;; + --fortran-original-prefix) FORTRAN_ORIGINAL_PREFIX="$2"; shift 2 ;; + --gcc-lib) GCC_LIB="$2"; shift 2 ;; + --homebrew-prefix) HOMEBREW_PREFIX="$2"; shift 2 ;; + --help|-h) usage; exit 0 ;; + *) echo "Unknown argument: $1" >&2; usage >&2; exit 2 ;; + esac +done + +for value_name in APP WORKSPACE_PREFIX QT_PREFIX BOOST_PREFIX FFTW_PREFIX LIBUSB_PREFIX PORTAUDIO_PREFIX FORTRAN_PREFIX GCC_LIB HOMEBREW_PREFIX; do + if [ -z "${!value_name}" ]; then + echo "Missing required argument or environment: ${value_name}" >&2 + usage >&2 + exit 2 + fi +done + +FRAMEWORKS="${APP}/Contents/Frameworks" +mkdir -p "${FRAMEWORKS}" + +dump_bundle_context() { + local status="$1" + local line="$2" + local command="$3" + echo "::error::deploy-macos-app failed at line ${line} with status ${status}: ${command}" + echo "APP=${APP}" + echo "FRAMEWORKS=${FRAMEWORKS}" + echo "FORTRAN_PREFIX=${FORTRAN_PREFIX}" + echo "FORTRAN_ORIGINAL_PREFIX=${FORTRAN_ORIGINAL_PREFIX}" + echo "GCC_LIB=${GCC_LIB}" + echo "HOMEBREW_PREFIX=${HOMEBREW_PREFIX}" + echo "App executable contents:" + ls -la "${APP}/Contents/MacOS" || true + echo "Framework contents:" + ls -la "${FRAMEWORKS}" || true + echo "External references in app executables:" + find "${APP}/Contents/MacOS" -type f -perm +111 -print -exec otool -L {} \; 2>/dev/null || true + if [ -f macdeployqt.log ]; then + echo "macdeployqt.log:" + cat macdeployqt.log + fi +} +trap 'status=$?; dump_bundle_context "$status" "$LINENO" "$BASH_COMMAND"; exit "$status"' ERR + +run_logged() { + echo "+ $*" + "$@" +} + +echo "Running macdeployqt..." +set +e +"${QT_PREFIX}/bin/macdeployqt" "${APP}" -verbose=2 > macdeployqt.log 2>&1 +status=$? +set -e +if [ "$status" -ne 0 ]; then + echo "::error::macdeployqt failed with status ${status}" + dump_bundle_context "$status" "$LINENO" "macdeployqt" + exit "$status" +fi +cat macdeployqt.log + +resolve_lib() { + local lib="$1" + if [ -n "$FORTRAN_ORIGINAL_PREFIX" ] && [[ "$lib" == "$FORTRAN_ORIGINAL_PREFIX"/* ]]; then + local original_prefix="${FORTRAN_ORIGINAL_PREFIX}/" + local relocated="${FORTRAN_PREFIX}/${lib:${#original_prefix}}" + [ -f "$relocated" ] && echo "$relocated" && return 0 + fi + if [[ "$lib" == $HOMEBREW_PREFIX/* ]]; then + echo "$lib" + return 0 + elif [[ "$lib" == "$WORKSPACE_PREFIX"/* ]]; then + echo "$lib" + return 0 + elif [[ "$lib" == @rpath/* ]]; then + local name="${lib#@rpath/}" + for dir in \ + "$FRAMEWORKS" \ + "${BOOST_PREFIX}/lib" \ + "${FFTW_PREFIX}/lib" \ + "${LIBUSB_PREFIX}/lib" \ + "${PORTAUDIO_PREFIX}/lib" \ + "${FORTRAN_PREFIX}/lib" \ + "$GCC_LIB" \ + "${HOMEBREW_PREFIX}/lib" + do + [ -f "$dir/$name" ] && echo "$dir/$name" && return + done + fi + return 0 +} + +should_bundle_ref() { + local ref="$1" + if [ -n "$FORTRAN_ORIGINAL_PREFIX" ] && [[ "$ref" == "$FORTRAN_ORIGINAL_PREFIX"/* ]]; then + return 0 + fi + case "$ref" in + *Qt*.framework/*) + return 1 + ;; + "$HOMEBREW_PREFIX"/*|"$WORKSPACE_PREFIX"/*|@rpath/*) + return 0 + ;; + *) + return 1 + ;; + esac +} + +bundle_dylib() { + local binary="$1" + local lib + while IFS= read -r lib; do + should_bundle_ref "$lib" || continue + local resolved + resolved=$(resolve_lib "$lib") + if [ -z "$resolved" ]; then + echo "::error::Could not resolve ${lib} required by ${binary}" + exit 1 + fi + local libname + libname=$(basename "$resolved") + case "$libname" in + libgomp*.dylib) + echo "::error::Refusing to bundle ${resolved}; libgomp must be linked statically for deployable macOS artifacts." + exit 1 + ;; + esac + if [ ! -f "${FRAMEWORKS}/${libname}" ]; then + echo " Bundling: $resolved -> ${FRAMEWORKS}/${libname}" + run_logged cp "$resolved" "${FRAMEWORKS}/${libname}" + run_logged chmod 644 "${FRAMEWORKS}/${libname}" + run_logged install_name_tool -id "@rpath/${libname}" "${FRAMEWORKS}/${libname}" + bundle_dylib "${FRAMEWORKS}/${libname}" + fi + if [ "$lib" != "@rpath/${libname}" ]; then + run_logged install_name_tool -change "$lib" "@rpath/${libname}" "$binary" + fi + done < <(otool -L "$binary" | awk 'NR > 1 {print $1}' || true) +} + +ensure_app_rpath() { + local binary="$1" + local rpath + + while IFS= read -r rpath; do + [ -n "$rpath" ] || continue + case "$rpath" in + "$WORKSPACE_PREFIX"/*|"$HOMEBREW_PREFIX"/*) + run_logged install_name_tool -delete_rpath "$rpath" "$binary" + ;; + esac + done < <(otool -l "$binary" | awk '/LC_RPATH/{getline; getline; print $2}' || true) + + local rpaths + rpaths=$(otool -l "$binary" | awk '/LC_RPATH/{getline; getline; print $2}' || true) + case $'\n'"$rpaths"$'\n' in + *$'\n''@executable_path/../Frameworks'$'\n'*) ;; + *) + run_logged install_name_tool -add_rpath "@executable_path/../Frameworks" "$binary" + ;; + esac +} + +for exe in "${APP}/Contents/MacOS/"*; do + [ -f "$exe" ] && [ -x "$exe" ] && { + ensure_app_rpath "$exe" + bundle_dylib "$exe" + for fw in $(otool -L "$exe" | awk '{print $1}' | grep '\.framework/' || true); do + fwname=$(basename "$fw") + bundled=$(find "${FRAMEWORKS}" -name "${fwname}" -path "*.framework/*" -print -quit 2>/dev/null) + if [ -n "$bundled" ]; then + app_contents="${APP}/Contents/" + fwrel="${bundled:${#app_contents}}" + if [ "$fw" != "@executable_path/../${fwrel}" ]; then + run_logged install_name_tool -change "$fw" "@executable_path/../${fwrel}" "$exe" + fi + fi + done + } +done + +for fw in "${FRAMEWORKS}"/*.dylib; do + [ -f "$fw" ] && bundle_dylib "$fw" +done + +for exe in "${APP}/Contents/MacOS/"*; do + [ -f "$exe" ] && [ -x "$exe" ] && bundle_dylib "$exe" +done + +echo "Checking for remaining external references..." +remaining_refs="${RUNNER_TEMP:-/tmp}/wsjtx-app-remaining-refs.txt" +: > "$remaining_refs" +while IFS= read -r binary; do + while IFS= read -r ref; do + case "$ref" in + "$HOMEBREW_PREFIX"/*|"$WORKSPACE_PREFIX"/*) + echo "${binary}: ${ref}" >> "$remaining_refs" + ;; + esac + if [ -n "$FORTRAN_ORIGINAL_PREFIX" ] && [[ "$ref" == "$FORTRAN_ORIGINAL_PREFIX"/* ]]; then + echo "${binary}: ${ref}" >> "$remaining_refs" + fi + done < <(otool -L "$binary" | awk 'NR > 1 {print $1}' || true) +done < <(find "${APP}/Contents/MacOS" -type f -perm +111 -print 2>/dev/null) +if [ -s "$remaining_refs" ]; then + echo "::error::External build-time paths still present:" + cat "$remaining_refs" + exit 1 +fi + +echo "All dylibs bundled successfully" diff --git a/.github/scripts/deploy-macos-cli-tools.sh b/.github/scripts/deploy-macos-cli-tools.sh new file mode 100755 index 00000000..d8603599 --- /dev/null +++ b/.github/scripts/deploy-macos-cli-tools.sh @@ -0,0 +1,259 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +usage() { + cat <<'USAGE' +Usage: deploy-macos-cli-tools.sh --assets PATH --stage PATH --workspace-prefix PATH --boost-prefix PATH --fftw-prefix PATH --libusb-prefix PATH --portaudio-prefix PATH --fortran-prefix PATH --gcc-lib PATH [--fortran-original-prefix PATH] [--homebrew-prefix PATH] +USAGE +} + +ASSETS="" +STAGE="" +WORKSPACE_PREFIX="${GITHUB_WORKSPACE:-}" +BOOST_PREFIX="" +FFTW_PREFIX="" +LIBUSB_PREFIX="" +PORTAUDIO_PREFIX="" +FORTRAN_PREFIX="" +FORTRAN_ORIGINAL_PREFIX="" +GCC_LIB="" +HOMEBREW_PREFIX="${HOMEBREW_PREFIX:-}" + +while [ "$#" -gt 0 ]; do + case "$1" in + --assets) ASSETS="$2"; shift 2 ;; + --stage) STAGE="$2"; shift 2 ;; + --workspace-prefix) WORKSPACE_PREFIX="$2"; shift 2 ;; + --boost-prefix) BOOST_PREFIX="$2"; shift 2 ;; + --fftw-prefix) FFTW_PREFIX="$2"; shift 2 ;; + --libusb-prefix) LIBUSB_PREFIX="$2"; shift 2 ;; + --portaudio-prefix) PORTAUDIO_PREFIX="$2"; shift 2 ;; + --fortran-prefix) FORTRAN_PREFIX="$2"; shift 2 ;; + --fortran-original-prefix) FORTRAN_ORIGINAL_PREFIX="$2"; shift 2 ;; + --gcc-lib) GCC_LIB="$2"; shift 2 ;; + --homebrew-prefix) HOMEBREW_PREFIX="$2"; shift 2 ;; + --help|-h) usage; exit 0 ;; + *) echo "Unknown argument: $1" >&2; usage >&2; exit 2 ;; + esac +done + +for value_name in ASSETS STAGE WORKSPACE_PREFIX BOOST_PREFIX FFTW_PREFIX LIBUSB_PREFIX PORTAUDIO_PREFIX FORTRAN_PREFIX GCC_LIB HOMEBREW_PREFIX; do + if [ -z "${!value_name}" ]; then + echo "Missing required argument or environment: ${value_name}" >&2 + usage >&2 + exit 2 + fi +done + +LIBDIR="${ASSETS}/lib" +mkdir -p "${LIBDIR}" + +dump_cli_context() { + local status="$1" + local line="$2" + local command="$3" + echo "::error::deploy-macos-cli-tools failed at line ${line} with status ${status}: ${command}" + echo "ASSETS=${ASSETS}" + echo "LIBDIR=${LIBDIR}" + echo "FORTRAN_PREFIX=${FORTRAN_PREFIX}" + echo "FORTRAN_ORIGINAL_PREFIX=${FORTRAN_ORIGINAL_PREFIX}" + echo "GCC_LIB=${GCC_LIB}" + echo "HOMEBREW_PREFIX=${HOMEBREW_PREFIX}" + echo "Asset contents:" + ls -la "${ASSETS}" || true + echo "Library contents:" + ls -la "${LIBDIR}" || true + echo "External references in CLI assets:" + for bin in "${ASSETS}"/*; do + [ -f "$bin" ] && [ -x "$bin" ] && [ "$(basename "$bin")" != "lib" ] || continue + echo "== $bin ==" + otool -L "$bin" || true + done +} +trap 'status=$?; dump_cli_context "$status" "$LINENO" "$BASH_COMMAND"; exit "$status"' ERR + +run_logged() { + echo "+ $*" + "$@" +} + +resolve_cli_ref() { + local ref="$1" + local name="" suffix="" + + if [ -n "$FORTRAN_ORIGINAL_PREFIX" ] && [[ "$ref" == "$FORTRAN_ORIGINAL_PREFIX"/* ]]; then + local original_prefix="${FORTRAN_ORIGINAL_PREFIX}/" + local relocated="${FORTRAN_PREFIX}/${ref:${#original_prefix}}" + [ -f "$relocated" ] && echo "$relocated" + return 0 + fi + + case "$ref" in + /usr/lib/*|/System/Library/*) + return 0 + ;; + @loader_path/lib/*) + name="${ref#@loader_path/lib/}" + [ -f "${LIBDIR}/${name}" ] && echo "${LIBDIR}/${name}" + return 0 + ;; + @loader_path/*) + name="${ref#@loader_path/}" + [ -f "${LIBDIR}/${name}" ] && echo "${LIBDIR}/${name}" + return 0 + ;; + "$WORKSPACE_PREFIX"/*|"$HOMEBREW_PREFIX"/*) + echo "$ref" + return 0 + ;; + esac + + if [[ "$ref" == @rpath/* ]]; then + suffix="${ref#@rpath/}" + if [[ "$suffix" == *.framework/* ]]; then + for dir in \ + "${STAGE}/wsjtx.app/Contents/Frameworks" \ + "${WORKSPACE_PREFIX}/qt-prefix/lib" + do + [ -f "${dir}/${suffix}" ] && echo "${dir}/${suffix}" && return 0 + done + else + name="${suffix}" + for dir in \ + "${LIBDIR}" \ + "${STAGE}/wsjtx.app/Contents/Frameworks" \ + "${BOOST_PREFIX}/lib" \ + "${FFTW_PREFIX}/lib" \ + "${LIBUSB_PREFIX}/lib" \ + "${PORTAUDIO_PREFIX}/lib" \ + "${FORTRAN_PREFIX}/lib" \ + "${GCC_LIB}" \ + "${HOMEBREW_PREFIX}/lib" + do + [ -f "${dir}/${name}" ] && echo "${dir}/${name}" && return 0 + done + fi + fi + + return 0 +} + +bundle_cli_deps() { + local binary="$1" + local change_prefix="$2" + local ref resolved out name target + + while IFS= read -r ref; do + resolved=$(resolve_cli_ref "$ref") + if [ -z "$resolved" ]; then + case "$ref" in + @rpath/*|@loader_path/*|"$WORKSPACE_PREFIX"/*|"$HOMEBREW_PREFIX"/*) + echo "::error::Could not resolve ${ref} required by ${binary}" + exit 1 + ;; + *) + continue + ;; + esac + fi + + name="$(basename "$resolved")" + case "$name" in + libgomp*.dylib) + echo "::error::Refusing to bundle ${resolved}; libgomp must be linked statically for deployable macOS artifacts." + exit 1 + ;; + esac + + out="${LIBDIR}/${name}" + if [ ! -f "$out" ]; then + echo " Bundling: ${resolved} -> ${out}" + run_logged cp "$resolved" "$out" + run_logged chmod 644 "$out" + run_logged install_name_tool -id "@rpath/${name}" "$out" + bundle_cli_deps "$out" "@rpath" + fi + + target="${change_prefix}/${name}" + if [ "$ref" != "$target" ]; then + run_logged install_name_tool -change "$ref" "$target" "$binary" + fi + done < <(otool -L "$binary" | awk 'NR > 1 {print $1}' | grep -E "($WORKSPACE_PREFIX|$HOMEBREW_PREFIX|@rpath|@loader_path)" || true) +} + +ensure_cli_rpath() { + local binary="$1" + local rpath + local bad_rpaths=() + local unique_bad_rpaths=() + + while IFS= read -r rpath; do + [ -n "$rpath" ] || continue + case "$rpath" in + "$WORKSPACE_PREFIX"/*|"$HOMEBREW_PREFIX"/*) + bad_rpaths+=("$rpath") + ;; + esac + done < <(otool -l "$binary" | awk '/LC_RPATH/{getline; getline; print $2}' || true) + + if [ "${#bad_rpaths[@]}" -gt 0 ]; then + for rpath in "${bad_rpaths[@]}"; do + local found=0 + local u + if [ "${#unique_bad_rpaths[@]}" -gt 0 ]; then + for u in "${unique_bad_rpaths[@]}"; do + [ "$u" = "$rpath" ] && found=1 && break + done + fi + [ "$found" -eq 0 ] && unique_bad_rpaths+=("$rpath") + done + fi + + if [ "${#unique_bad_rpaths[@]}" -gt 0 ]; then + for rpath in "${unique_bad_rpaths[@]}"; do + run_logged install_name_tool -delete_rpath "$rpath" "$binary" + done + fi + + local rpaths + rpaths=$(otool -l "$binary" | awk '/LC_RPATH/{getline; getline; print $2}' || true) + case $'\n'"$rpaths"$'\n' in + *$'\n''@loader_path/lib'$'\n'*) ;; + *) + run_logged install_name_tool -add_rpath "@loader_path/lib" "$binary" + ;; + esac +} + +for bin in "${ASSETS}"/*; do + [ -f "$bin" ] && [ -x "$bin" ] && [ "$(basename "$bin")" != "lib" ] || continue + ensure_cli_rpath "$bin" + bundle_cli_deps "$bin" "@rpath" + run_logged codesign --force --sign - "$bin" +done + +for lib in "${LIBDIR}"/*; do + [ -f "$lib" ] || continue + bundle_cli_deps "$lib" "@rpath" + run_logged codesign --force --sign - "$lib" +done + +echo "Verifying CLI tools..." +for bin in "${ASSETS}"/*; do + [ -f "$bin" ] && [ -x "$bin" ] && [ "$(basename "$bin")" != "lib" ] && { + BAD=$(otool -L "$bin" | grep "$HOMEBREW_PREFIX" || true) + if [ -n "$BAD" ]; then + echo "ERROR: $(basename "$bin") still has Homebrew refs:" + echo "$BAD" + exit 1 + fi + } +done +echo "All CLI tools are self-contained" + +cp -R "${LIBDIR}" "${STAGE}/lib" +for bin in "${ASSETS}"/*; do + [ -f "$bin" ] && [ -x "$bin" ] && [ "$(basename "$bin")" != "lib" ] && { + cp "$bin" "${STAGE}/$(basename "$bin")" + } +done diff --git a/.github/scripts/generate-quick-downloads.py b/.github/scripts/generate-quick-downloads.py new file mode 100755 index 00000000..6706292d --- /dev/null +++ b/.github/scripts/generate-quick-downloads.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python3 +"""Generate the "Quick Downloads" markdown block for a WSJT-X GitHub Release. + +The release workflow attaches every build artifact to the Release, which makes +the assets list long and hard for an end user to navigate (installers sit among +standalone command-line utilities, raw binaries, and source). This emits a +short, curated per-platform installer picker to prepend to the auto-generated +release notes. + +It is *asset-driven*: platforms and architectures are derived from the asset +filenames passed in, not hard-coded. New build variants (for example an added +Linux architecture such as armhf) therefore appear in Quick Downloads +automatically, with no edit to this script. + +The block is emitted on stdout, ending at the last platform line (no trailing +separator); the caller joins it to the auto-generated notes. + +Usage: + generate-quick-downloads.py <owner/repo> <tag> <asset-path-or-name>... + +Only installer-grade assets are listed (.pkg / win64.exe / .deb / .rpm / +.AppImage) plus the source tarball. Per-mode utility tarballs and raw +command-line binaries are intentionally omitted; they remain in the full +assets list below the notes. +""" +import os +import re +import sys + +# Architectures listed first, in this order; any others are appended sorted. +ARCH_ORDER = ["x86_64", "aarch64", "armhf", "armv7l", "arm64", "i686"] + + +def main(argv): + if len(argv) < 4: + sys.stderr.write( + "usage: generate-quick-downloads.py <owner/repo> <tag> <asset>...\n" + ) + return 2 + + repo, tag = argv[1], argv[2] + names = sorted({os.path.basename(p) for p in argv[3:] if p.strip()}) + + def url(name): + return f"https://github.com/{repo}/releases/download/{tag}/{name}" + + macos = {} # label -> filename + windows = {} # label -> filename + deb = {} # arch -> filename + rpm = {} # arch -> filename + appimage = {} # arch -> filename + source = None + + for n in names: + if n.endswith("-arm64-macOS.pkg"): + macos["Apple Silicon"] = n + elif n.endswith("-x86_64-macOS.pkg"): + macos["Intel"] = n + elif re.search(r"-win\d+\.exe$", n): # installer, not raw jt9.exe + windows["64-bit"] = n + elif n.endswith("-src.tar.gz"): + source = n + elif (m := re.search(r"-linux-([A-Za-z0-9_]+)\.deb$", n)): + deb[m.group(1)] = n + elif (m := re.search(r"-linux-([A-Za-z0-9_]+)\.AppImage$", n)): + appimage[m.group(1)] = n + elif (m := re.search(r"\.([A-Za-z0-9_]+)\.rpm$", n)): + rpm[m.group(1)] = n + # Anything else (utility tarballs, raw binaries) is intentionally + # excluded; it stays in the full assets list. + + def arches(d): + known = [a for a in ARCH_ORDER if a in d] + extra = sorted(a for a in d if a not in ARCH_ORDER) + return known + extra + + def arch_line(label, d): + return f"- {label}: " + " · ".join( + f"[{a}]({url(d[a])})" for a in arches(d) + ) + + out = [ + "## Quick Downloads", + "", + "Choose the installer for your platform. The full assets list below also", + "includes standalone command-line utilities and source code for developers.", + ] + + if macos: + out += ["", "### macOS"] + if "Apple Silicon" in macos: + out.append(f"- Apple Silicon: [{macos['Apple Silicon']}]({url(macos['Apple Silicon'])})") + if "Intel" in macos: + out.append(f"- Intel: [{macos['Intel']}]({url(macos['Intel'])})") + + if windows: + out += ["", "### Windows"] + out.append(f"- 64-bit: [{windows['64-bit']}]({url(windows['64-bit'])})") + + if deb or rpm or appimage: + out += ["", "### Linux"] + if deb: + out.append(arch_line("Debian / Ubuntu (.deb)", deb)) + if rpm: + out.append(arch_line("Fedora / RHEL (.rpm)", rpm)) + if appimage: + out.append(arch_line("AppImage (universal)", appimage)) + + if source: + out += ["", "### Source", f"- [{source}]({url(source)})"] + + # If nothing matched (no installer-grade assets), emit nothing so the + # caller leaves the auto-generated notes untouched. + if len(out) == 4: + return 0 + + sys.stdout.write("\n".join(out) + "\n") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main(sys.argv)) diff --git a/.github/scripts/ghcr_retention.py b/.github/scripts/ghcr_retention.py new file mode 100755 index 00000000..ac0881f6 --- /dev/null +++ b/.github/scripts/ghcr_retention.py @@ -0,0 +1,234 @@ +#!/usr/bin/env python3 +"""Plan and apply conservative retention for WSJT-X GHCR build images.""" + +from __future__ import annotations + +import argparse +import json +import os +import re +import sys +import urllib.error +import urllib.parse +import urllib.request +from dataclasses import dataclass +from datetime import datetime, timedelta, timezone +from typing import Iterable + + +API_VERSION = "2022-11-28" +BUILD_TAG = re.compile( + r"^(?:build-\d{8}-\d+-\d+|validated-build-\d{8}-\d+-\d+|candidate-\d+-\d+)$" +) + + +@dataclass(frozen=True) +class Version: + id: int + digest: str + created_at: datetime + tags: tuple[str, ...] + + +@dataclass(frozen=True) +class Decision: + version: Version + delete: bool + reason: str + + +def parse_timestamp(value: object) -> datetime: + if not isinstance(value, str): + raise ValueError("created_at must be a string") + parsed = datetime.fromisoformat(value.replace("Z", "+00:00")) + if parsed.tzinfo is None: + raise ValueError("created_at must include a timezone") + return parsed.astimezone(timezone.utc) + + +def parse_version(raw: object) -> Version: + if not isinstance(raw, dict): + raise ValueError("package version must be an object") + version_id = raw.get("id") + digest = raw.get("name") + metadata = raw.get("metadata") + if not isinstance(version_id, int) or not isinstance(digest, str): + raise ValueError("package version requires integer id and string name") + if not isinstance(metadata, dict) or metadata.get("package_type") != "container": + raise ValueError(f"package version {version_id} is not a container") + container = metadata.get("container") + tags = container.get("tags") if isinstance(container, dict) else None + if not isinstance(tags, list) or not all(isinstance(tag, str) for tag in tags): + raise ValueError(f"package version {version_id} has invalid tags") + return Version( + id=version_id, + digest=digest, + created_at=parse_timestamp(raw.get("created_at")), + tags=tuple(sorted(tags)), + ) + + +def is_retirable(version: Version) -> bool: + return bool(version.tags) and all( + tag == "stable" or BUILD_TAG.fullmatch(tag) for tag in version.tags + ) + + +def plan_retention( + versions: Iterable[Version], now: datetime, max_age_days: int, keep: int +) -> list[Decision]: + ordered = sorted(versions, key=lambda item: (item.created_at, item.id), reverse=True) + retirable = [version for version in ordered if is_retirable(version)] + kept_ids = {version.id for version in retirable[:keep]} + cutoff = now.astimezone(timezone.utc) - timedelta(days=max_age_days) + decisions: list[Decision] = [] + for version in ordered: + if "stable" in version.tags: + decisions.append(Decision(version, False, "stable")) + elif not is_retirable(version): + decisions.append(Decision(version, False, "unknown-or-untagged")) + elif version.id in kept_ids: + decisions.append(Decision(version, False, "newest-generation")) + elif version.created_at >= cutoff: + decisions.append(Decision(version, False, "within-retention-window")) + else: + decisions.append(Decision(version, True, "expired")) + return decisions + + +class GitHubPackagesClient: + def __init__(self, token: str, api_url: str = "https://api.github.com") -> None: + self.api_url = api_url.rstrip("/") + self.headers = { + "Accept": "application/vnd.github+json", + "Authorization": f"Bearer {token}", + "X-GitHub-Api-Version": API_VERSION, + "User-Agent": "wsjtx-ghcr-retention", + } + + def request(self, method: str, path: str) -> object | None: + request = urllib.request.Request( + f"{self.api_url}{path}", headers=self.headers, method=method + ) + try: + with urllib.request.urlopen(request, timeout=30) as response: + if method == "DELETE": + if response.status != 204: + raise RuntimeError(f"DELETE {path} returned HTTP {response.status}") + return None + return json.load(response) + except urllib.error.HTTPError as error: + request_id = error.headers.get("x-github-request-id", "unknown") + raise RuntimeError( + f"{method} {path} failed with HTTP {error.code} " + f"(GitHub request {request_id})" + ) from error + + @staticmethod + def package_path(owner: str, package: str) -> str: + encoded = urllib.parse.quote(package, safe="") + return f"/orgs/{owner}/packages/container/{encoded}" + + def list_versions(self, owner: str, package: str) -> list[Version]: + base = self.package_path(owner, package) + versions: list[Version] = [] + page = 1 + while True: + raw = self.request( + "GET", f"{base}/versions?state=active&per_page=100&page={page}" + ) + if not isinstance(raw, list): + raise RuntimeError(f"GitHub returned a non-list for package {package}") + versions.extend(parse_version(item) for item in raw) + if len(raw) < 100: + return versions + page += 1 + + def get_version(self, owner: str, package: str, version_id: int) -> Version: + raw = self.request( + "GET", f"{self.package_path(owner, package)}/versions/{version_id}" + ) + return parse_version(raw) + + def delete_version(self, owner: str, package: str, version_id: int) -> None: + self.request( + "DELETE", f"{self.package_path(owner, package)}/versions/{version_id}" + ) + + +def process_package( + client: GitHubPackagesClient, + owner: str, + package: str, + now: datetime, + max_age_days: int, + keep: int, + apply: bool, +) -> int: + decisions = plan_retention(client.list_versions(owner, package), now, max_age_days, keep) + deleted = 0 + for decision in decisions: + version = decision.version + action = "delete" if decision.delete else "keep" + print( + f"{package} id={version.id} digest={version.digest} " + f"created={version.created_at.isoformat()} tags={','.join(version.tags) or '-'} " + f"action={action} reason={decision.reason}" + ) + if not apply or not decision.delete: + continue + refreshed = client.get_version(owner, package, version.id) + refreshed_decision = next( + item + for item in plan_retention([refreshed], now, max_age_days, 0) + if item.version.id == version.id + ) + if not refreshed_decision.delete: + print( + f"{package} id={version.id} action=keep " + f"reason=changed-before-delete-{refreshed_decision.reason}" + ) + continue + client.delete_version(owner, package, version.id) + deleted += 1 + return deleted + + +def parse_args() -> argparse.Namespace: + parser = argparse.ArgumentParser() + parser.add_argument("--owner", required=True) + parser.add_argument("--package", action="append", required=True) + parser.add_argument("--max-age-days", type=int, default=60) + parser.add_argument("--keep", type=int, default=3) + parser.add_argument("--apply", action="store_true") + return parser.parse_args() + + +def main() -> int: + args = parse_args() + if args.max_age_days < 1 or args.keep < 1: + print("max-age-days and keep must be positive", file=sys.stderr) + return 2 + token = os.environ.get("GITHUB_TOKEN") + if not token: + print("GITHUB_TOKEN is required", file=sys.stderr) + return 2 + client = GitHubPackagesClient(token) + now = datetime.now(timezone.utc) + deleted = 0 + for package in args.package: + deleted += process_package( + client, + args.owner, + package, + now, + args.max_age_days, + args.keep, + args.apply, + ) + print(f"total_deleted={deleted} apply={str(args.apply).lower()}") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/.github/scripts/is-linux-ci-image-input.sh b/.github/scripts/is-linux-ci-image-input.sh new file mode 100755 index 00000000..23a76e1b --- /dev/null +++ b/.github/scripts/is-linux-ci-image-input.sh @@ -0,0 +1,127 @@ +#!/usr/bin/env bash + +set -euo pipefail + +. .github/scripts/linux-ci-image-inputs.sh + +is_linux_ci_image_input() { + local profile=$1 + local path=$2 + local input inputs + + if ! inputs="$(linux_ci_image_inputs "$profile")"; then + return 2 + fi + + while IFS= read -r input; do + if [ "$path" = "$input" ]; then + return 0 + fi + done <<< "$inputs" + return 1 +} + +linux_ci_image_set_for_inputs() { + local normal=false tsan=false path + + for path in "$@"; do + if is_linux_ci_image_input normal-noble "$path" || + is_linux_ci_image_input normal-bookworm "$path" || + is_linux_ci_image_input armhf-cross-bookworm "$path" || + is_linux_ci_image_input armhf-runtime-bookworm "$path"; then + normal=true + fi + if is_linux_ci_image_input tsan-noble "$path"; then + tsan=true + fi + done + + if [ "$normal" = true ] && [ "$tsan" = true ]; then + echo normal-and-tsan + elif [ "$normal" = true ]; then + echo normal + elif [ "$tsan" = true ]; then + echo tsan + else + echo none + fi +} + +expect_input() { + if ! is_linux_ci_image_input "$1" "$2"; then + echo "self-test failed: expected $1 image input: $2" >&2 + exit 1 + fi +} + +expect_non_input() { + if is_linux_ci_image_input "$1" "$2"; then + echo "self-test failed: unexpected $1 image input: $2" >&2 + exit 1 + fi +} + +expect_image_set() { + local expected=$1 + shift + local actual + actual="$(linux_ci_image_set_for_inputs "$@")" + if [ "$actual" != "$expected" ]; then + echo "self-test failed: expected image set $expected, got $actual" >&2 + exit 1 + fi +} + +if [ "${1:-}" = "--self-test" ]; then + expect_input normal-noble ".github/images/linux-ci/Dockerfile.noble" + expect_input tsan-noble ".github/images/linux-ci/Dockerfile.noble" + expect_input normal-bookworm ".github/images/linux-ci/Dockerfile.bookworm" + expect_input armhf-cross-bookworm ".github/images/linux-ci/Dockerfile.armhf-cross" + expect_input armhf-runtime-bookworm ".github/images/linux-ci/Dockerfile.armhf-runtime" + expect_input armhf-runtime-bookworm ".github/images/linux-ci/install-armhf-runtime-packages.sh" + expect_non_input normal-noble ".github/images/linux-ci/install-armhf-runtime-packages.sh" + expect_input armhf-cross-bookworm ".github/images/linux-ci/armhf-cross-toolchain.config" + expect_non_input armhf-runtime-bookworm ".github/images/linux-ci/armhf-cross-toolchain.config" + expect_input normal-noble ".github/scripts/build-hamlib-linux.sh" + expect_non_input tsan-noble ".github/scripts/build-hamlib-linux.sh" + expect_input tsan-noble ".github/scripts/build-qt-tsan-linux.sh" + expect_non_input normal-noble ".github/scripts/build-qt-tsan-linux.sh" + expect_input normal-noble ".github/scripts/verify-linux-ci-image.sh" + expect_input tsan-noble ".github/scripts/verify-linux-ci-image.sh" + + expect_non_input normal-noble ".github/workflows/build-linux.yml" + expect_non_input tsan-noble "CMake/Sources.cmake" + expect_non_input normal-bookworm ".github/scripts/build-boost-macos.sh" + expect_image_set normal ".github/scripts/build-hamlib-linux.sh" + expect_image_set tsan ".github/scripts/build-qt-tsan-linux.sh" + expect_image_set normal-and-tsan ".github/scripts/verify-linux-ci-image.sh" + expect_image_set normal-and-tsan \ + ".github/scripts/build-hamlib-linux.sh" \ + ".github/scripts/build-qt-tsan-linux.sh" + expect_image_set none "CMake/Sources.cmake" + if is_linux_ci_image_input unsupported ".github/images/linux-ci/Dockerfile.noble" 2>/dev/null; then + echo "self-test failed: unsupported image profile was accepted" >&2 + exit 1 + elif [ "$?" -ne 2 ]; then + echo "self-test failed: unsupported image profile did not return status 2" >&2 + exit 1 + fi + exit 0 +fi + +if [ "${1:-}" = "--classify" ]; then + shift + if [ "$#" -eq 0 ]; then + echo "Usage: is-linux-ci-image-input.sh --classify PATH [PATH ...]" >&2 + exit 2 + fi + linux_ci_image_set_for_inputs "$@" + exit 0 +fi + +if [ "$#" -ne 2 ]; then + echo "Usage: is-linux-ci-image-input.sh PROFILE PATH | --classify PATH [PATH ...]" >&2 + exit 2 +fi + +is_linux_ci_image_input "$1" "$2" diff --git a/.github/scripts/linux-artifact-validation.sh b/.github/scripts/linux-artifact-validation.sh new file mode 100644 index 00000000..01a607f6 --- /dev/null +++ b/.github/scripts/linux-artifact-validation.sh @@ -0,0 +1,290 @@ +#!/bin/bash +# Shared acceptance checks for Linux build products. + +linux_validation_error() { + echo "::error::$*" >&2 + return 1 +} + +validate_elf_metadata() { + local arch="$1" + local path="$2" + local file_output="$3" + local header_output="$4" + local program_output="$5" + + case "$arch" in + armhf) + [[ "$file_output" == *"ELF 32-bit"* ]] || { + linux_validation_error "$path is not ELF32" + return 1 + } + [[ "$file_output" == *"ARM, EABI5"* ]] || { + linux_validation_error "$path is not ARM EABI5" + return 1 + } + [[ "$header_output" == *"Class:"*"ELF32"* ]] || { + linux_validation_error "$path has the wrong ELF class for armhf" + return 1 + } + [[ "$header_output" == *"Machine:"*"ARM"* ]] || { + linux_validation_error "$path has the wrong ELF machine for armhf" + return 1 + } + [[ "$header_output" == *"Version5 EABI"* ]] || { + linux_validation_error "$path does not use EABI5" + return 1 + } + [[ "$header_output" == *"hard-float ABI"* ]] || { + linux_validation_error "$path does not use the ARM hard-float ABI" + return 1 + } + if [[ "$file_output" == *"dynamically linked"* ]] && + [[ "$program_output" != *"/lib/ld-linux-armhf.so.3"* ]]; then + linux_validation_error "$path does not request /lib/ld-linux-armhf.so.3" + return 1 + fi + ;; + x86_64) + [[ "$file_output" == *"ELF 64-bit"* && "$file_output" == *"x86-64"* ]] || { + linux_validation_error "$path is not a 64-bit x86-64 ELF" + return 1 + } + ;; + aarch64) + [[ "$file_output" == *"ELF 64-bit"* && "$file_output" == *"ARM aarch64"* ]] || { + linux_validation_error "$path is not a 64-bit AArch64 ELF" + return 1 + } + ;; + *) + linux_validation_error "Unsupported Linux architecture: $arch" + return 2 + ;; + esac +} + +validate_elf_executable() { + local arch="$1" + local path="$2" + local file_output + local header_output + local program_output + + if [ ! -x "$path" ]; then + linux_validation_error "Required executable is missing: $path" + return 1 + fi + + file_output=$(file -- "$path") || return + header_output=$(readelf -hW -- "$path") || return + program_output=$(readelf -lW -- "$path") || return + echo "$file_output" + validate_elf_metadata "$arch" "$path" "$file_output" "$header_output" "$program_output" +} + +validate_linux_build_executables() { + local build_dir="$1" + local arch="$2" + local executable + + for executable in wsjtx jt9 qmap/qmap map65/map65 ft8code wsprd; do + validate_elf_executable "$arch" "$build_dir/$executable" || return + done +} + +linux_manifest_has_path() { + local manifest="$1" + local path="$2" + case $'\n'"$manifest"$'\n' in + *"$path"$'\n'*) return 0 ;; + *) return 1 ;; + esac +} + +validate_linux_package_manifest() { + local manifest="$1" + local label="$2" + local path + + for path in \ + /usr/bin/wsjtx \ + /usr/bin/jt9 \ + /usr/bin/qmap \ + /usr/bin/map65 \ + /usr/share/wsjtx/ALLCALL7.TXT \ + /usr/share/wsjtx/CALL3.TXT \ + /usr/share/wsjtx/sounds/Message.wav \ + /usr/share/wsjtx/sounds/Testing123.wav; do + if ! linux_manifest_has_path "$manifest" "$path"; then + linux_validation_error "$label is missing expected package path: $path" + return 1 + fi + done + + case $'\n'"$manifest"$'\n' in + *"/usr/bin/sounds"$'\n'* | *"/usr/bin/sounds/"*) + linux_validation_error "$label contains unexpected package path: /usr/bin/sounds" + return 1 + ;; + esac +} + +validate_deb_package() { + local package="$1" + local manifest + + manifest=$(dpkg-deb --fsys-tarfile "$package" | tar -tf -) || return + validate_linux_package_manifest "$manifest" "DEB $package" +} + +validate_rpm_package() { + local package="$1" + local manifest + + manifest=$(rpm -qpl "$package") || return + printf '%s\n' "$manifest" | sed -n '1,40p' + validate_linux_package_manifest "$manifest" "RPM $package" +} + +linux_require_executable() { + local path="$1" + if [ ! -x "$path" ]; then + linux_validation_error "Required executable is missing: $path" + return 1 + fi +} + +linux_require_file() { + local path="$1" + if [ ! -f "$path" ]; then + linux_validation_error "Required file is missing: $path" + return 1 + fi +} + +validate_linux_application_layout() { + local root="$1" + local kind="$2" + local path + + for path in wsjtx jt9 qmap map65 ft8code; do + linux_require_executable "$root/usr/bin/$path" || return + done + if [ "$kind" = appimage ]; then + linux_require_executable "$root/usr/bin/wsprd" || return + elif [ "$kind" != appdir ]; then + linux_validation_error "Unknown application tree kind: $kind" + return 2 + fi + + for path in \ + usr/share/wsjtx/ALLCALL7.TXT \ + usr/share/wsjtx/CALL3.TXT \ + usr/share/wsjtx/sounds/Message.wav \ + usr/share/wsjtx/sounds/Testing123.wav; do + linux_require_file "$root/$path" || return + done + if [ -e "$root/usr/bin/sounds" ] || [ -L "$root/usr/bin/sounds" ]; then + linux_validation_error "Unexpected executable-adjacent sounds path is present: $root/usr/bin/sounds" + return 1 + fi + + if [ "$kind" = appdir ]; then + linux_require_file "$root/usr/share/applications/wsjtx.desktop" || return + linux_require_file "$root/usr/share/pixmaps/wsjtx_icon.png" || return + return 0 + fi + + for path in \ + usr/bin/qt.conf \ + usr/plugins/platforms/libqxcb.so \ + usr/plugins/sqldrivers/libqsqlite.so; do + linux_require_file "$root/$path" || return + done + if ! grep -Eq '^[[:space:]]*Plugins[[:space:]]*=[[:space:]]*plugins[[:space:]]*$' \ + "$root/usr/bin/qt.conf"; then + linux_validation_error "AppImage qt.conf must set Plugins = plugins" + echo "AppImage qt.conf contents:" + cat "$root/usr/bin/qt.conf" + return 1 + fi + + for path in libQt5Core.so libQt5Widgets.so libQt5Multimedia.so; do + if [ -z "$(find "$root/usr/lib" -maxdepth 1 -name "$path*" -print -quit 2>/dev/null)" ]; then + linux_validation_error "Required AppImage Qt library is missing: $path" + return 1 + fi + done + + if [ -z "$(find "$root" -path '*/plugins/audio/*.so' -print -quit 2>/dev/null)" ]; then + linux_validation_error "No Qt audio backend plugin is bundled in the AppImage" + echo "AppImage plugin tree:" + find "$root" -path '*/plugins/*' -name '*.so' -print 2>/dev/null | sed -n '1,20p' + return 1 + fi +} + +validate_linux_application_tree() { + local root="$1" + local kind="$2" + local arch="$3" + local executable + + validate_linux_application_layout "$root" "$kind" || return + for executable in wsjtx jt9 qmap map65 ft8code; do + validate_elf_executable "$arch" "$root/usr/bin/$executable" || return + done + if [ "$kind" = appimage ]; then + validate_elf_executable "$arch" "$root/usr/bin/wsprd" || return + echo "Qt audio plugins bundled:" + find "$root" -path '*/plugins/audio/*.so' -print 2>/dev/null + fi +} + +run_packaged_appimage_startup_smoke() { + local appimage="$1" + local log="$2" + local status + local runner=() + if [ -n "${LINUX_APPIMAGE_RUNNER:-}" ]; then + runner=("$LINUX_APPIMAGE_RUNNER") + fi + + mkdir -p "$(dirname "$log")" + if env \ + -u LD_LIBRARY_PATH \ + -u LD_PRELOAD \ + -u LD_AUDIT \ + -u QT_PLUGIN_PATH \ + -u QT_QPA_PLATFORM_PLUGIN_PATH \ + -u QML_IMPORT_PATH \ + -u QML2_IMPORT_PATH \ + APPIMAGE_EXTRACT_AND_RUN=1 \ + QT_QPA_PLATFORM=xcb \ + timeout --kill-after=5s 45s \ + xvfb-run -a -s "-screen 0 1280x1024x24" \ + "${runner[@]}" \ + "$appimage" \ + --startup-smoke-test \ + --rig-name CI-APPIMAGE-STARTUP \ + >"$log" 2>&1; then + status=0 + else + status=$? + fi + + cat "$log" + if [ "$status" -eq 124 ]; then + linux_validation_error "AppImage startup smoke test timed out after 45 seconds" + return 1 + fi + if [ "$status" -ne 0 ]; then + linux_validation_error "AppImage startup smoke test exited with status $status" + return 1 + fi + if ! grep -Fq "WSJT-X startup smoke test passed" "$log"; then + linux_validation_error "AppImage exited successfully without the startup-smoke success marker" + return 1 + fi +} diff --git a/.github/scripts/linux-ccache-compiler-signature.sh b/.github/scripts/linux-ccache-compiler-signature.sh new file mode 100755 index 00000000..02d3270b --- /dev/null +++ b/.github/scripts/linux-ccache-compiler-signature.sh @@ -0,0 +1,157 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -ne 1 ]; then + echo "Usage: linux-ccache-compiler-signature.sh C_COMPILER" >&2 + exit 2 +fi + +c_compiler=$1 +case "$(basename "$c_compiler")" in + gcc) + cxx_compiler=g++ + ;; + gcc-*) + cxx_compiler="g++-${c_compiler##*-}" + ;; + *-gcc) + cxx_compiler="${c_compiler%-gcc}-g++" + ;; + *) + echo "Unsupported C compiler for Linux ccache identity: $c_compiler" >&2 + exit 2 + ;; +esac + +resolve_executable() { + local executable=$1 resolved + if [[ "$executable" == */* ]]; then + resolved=$executable + else + resolved="$(command -v "$executable" || true)" + fi + if [ -z "$resolved" ] || [ ! -f "$resolved" ]; then + echo "Compiler component not found: $executable" >&2 + exit 1 + fi + readlink -f "$resolved" +} + +hash_file() { + sha256sum "$1" | awk '{print $1}' +} + +c_path="$(resolve_executable "$(command -v "$c_compiler")")" +cxx_path="$(resolve_executable "$(command -v "$cxx_compiler")")" +compiler_version="$($c_compiler -dumpfullversion -dumpversion)" +cxx_version="$($cxx_compiler -dumpfullversion -dumpversion)" +compiler_target="$($c_compiler -dumpmachine)" +cxx_target="$($cxx_compiler -dumpmachine)" + +if [ "$cxx_version" != "$compiler_version" ]; then + echo "C and C++ compiler version mismatch: $compiler_version != $cxx_version" >&2 + exit 1 +fi +if [ "$cxx_target" != "$compiler_target" ]; then + echo "C and C++ compiler target mismatch: $compiler_target != $cxx_target" >&2 + exit 1 +fi +if [[ ! "$compiler_version" =~ ^[0-9]+([.][0-9]+)*$ ]]; then + echo "Invalid GCC version: $compiler_version" >&2 + exit 1 +fi +if [[ ! "$compiler_target" =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ ]]; then + echo "Invalid GCC target: $compiler_target" >&2 + exit 1 +fi + +cc1_path="$(resolve_executable "$($c_compiler -print-prog-name=cc1)")" +cc1plus_path="$(resolve_executable "$($cxx_compiler -print-prog-name=cc1plus)")" +lto1_path="$(resolve_executable "$($c_compiler -print-prog-name=lto1)")" +assembler_path="$(resolve_executable "$($c_compiler -print-prog-name=as)")" +dumpspecs_sha256="$($c_compiler -dumpspecs | sha256sum | awk '{print $1}')" + +if ! command -v ldd >/dev/null 2>&1; then + echo "ldd is required to identify compiler runtime dependencies" >&2 + exit 1 +fi + +runtime_dependency_records() { + local role=$1 executable=$2 output dependencies name dependency + + if ! output="$(LC_ALL=C ldd "$executable" 2>&1)"; then + case "$output" in + *"not a dynamic executable"*|*"statically linked"*) return 0 ;; + *) + echo "Could not inspect runtime dependencies for $executable: $output" >&2 + return 1 + ;; + esac + fi + if [[ "$output" == *"=> not found"* ]]; then + echo "Unresolved runtime dependency for $executable: $output" >&2 + return 1 + fi + + dependencies="$(printf '%s\n' "$output" | awk ' + /=> \/[^ ]+/ { print $1 "\t" $(NF - 1) } + $1 ~ /^\// { + name = $1 + sub(/^.*\//, "", name) + print name "\t" $1 + } + ')" + if [ -z "$dependencies" ]; then + case "$output" in + *"statically linked"*|*"not a dynamic executable"*) return 0 ;; + *) + echo "No runtime dependencies could be parsed for $executable: $output" >&2 + return 1 + ;; + esac + fi + + while IFS=$'\t' read -r name dependency; do + dependency="$(readlink -f "$dependency")" + if [ ! -f "$dependency" ]; then + echo "Runtime dependency not found for $executable: $dependency" >&2 + return 1 + fi + printf '%s:%s:%s\n' "$role" "$name" "$(hash_file "$dependency")" + done <<< "$dependencies" +} + +runtime_dependencies="$({ + runtime_dependency_records c_driver "$c_path" + runtime_dependency_records cxx_driver "$cxx_path" + runtime_dependency_records cc1 "$cc1_path" + runtime_dependency_records cc1plus "$cc1plus_path" + runtime_dependency_records lto1 "$lto1_path" + runtime_dependency_records assembler "$assembler_path" +} | LC_ALL=C sort)" + +signature_record="$({ + printf 'format=wsjtx-linux-ccache-compiler-signature-v2\n' + printf 'c_driver_sha256=%s\n' "$(hash_file "$c_path")" + printf 'cxx_driver_sha256=%s\n' "$(hash_file "$cxx_path")" + printf 'cc1_sha256=%s\n' "$(hash_file "$cc1_path")" + printf 'cc1plus_sha256=%s\n' "$(hash_file "$cc1plus_path")" + printf 'lto1_sha256=%s\n' "$(hash_file "$lto1_path")" + printf 'assembler_sha256=%s\n' "$(hash_file "$assembler_path")" + printf 'target=%s\n' "$compiler_target" + printf 'dumpspecs_sha256=%s\n' "$dumpspecs_sha256" + while IFS= read -r dependency_record; do + if [ -n "$dependency_record" ]; then + printf 'runtime_dependency=%s\n' "$dependency_record" + fi + done <<< "$runtime_dependencies" +})" +compiler_signature_sha256="$(printf '%s\n' "$signature_record" | sha256sum | awk '{print $1}')" +compiler_major=${compiler_version%%.*} + +printf '%s\t%s\t%s\t%s\t%s\n' \ + "$compiler_version" \ + "$compiler_target" \ + "$(hash_file "$c_path")" \ + "gcc${compiler_major}-v2" \ + "$compiler_signature_sha256" diff --git a/.github/scripts/linux-ci-image-config.sh b/.github/scripts/linux-ci-image-config.sh new file mode 100755 index 00000000..d9742d96 --- /dev/null +++ b/.github/scripts/linux-ci-image-config.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# Shared dependency tuple embedded in the normal and ARM Linux CI images. +# shellcheck disable=SC2034 + +LINUX_CI_IMAGE_SCHEMA=1 + +LINUX_PFUNIT_VERSION=4.14.0 +LINUX_PFUNIT_REF=v${LINUX_PFUNIT_VERSION} +LINUX_PFUNIT_COMMIT=29ddfad16e10958bbe4a685d1fde17678296c19a + +LINUX_HAMLIB_REF=4.7.2 +LINUX_HAMLIB_COMMIT=40f63488fe0bd751b147f48d62fd217bf53713a0 + +LINUX_CI_PREFIX=/opt/wsjtx +LINUX_PFUNIT_PREFIX=${LINUX_CI_PREFIX}/pfunit +LINUX_HAMLIB_PREFIX=${LINUX_CI_PREFIX}/hamlib diff --git a/.github/scripts/linux-ci-image-fingerprint.sh b/.github/scripts/linux-ci-image-fingerprint.sh new file mode 100755 index 00000000..02920299 --- /dev/null +++ b/.github/scripts/linux-ci-image-fingerprint.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -ne 1 ]; then + echo "Usage: linux-ci-image-fingerprint.sh normal-noble|normal-bookworm|tsan-noble|armhf-cross-bookworm|armhf-runtime-bookworm" >&2 + exit 2 +fi + +profile=$1 +. .github/scripts/linux-ci-image-inputs.sh +files=() +inputs="$(linux_ci_image_inputs "$profile")" +while IFS= read -r file; do + files+=("$file") +done <<< "$inputs" + +sha256sum "${files[@]}" | sha256sum | awk '{print $1}' diff --git a/.github/scripts/linux-ci-image-inputs.sh b/.github/scripts/linux-ci-image-inputs.sh new file mode 100644 index 00000000..bc3e43af --- /dev/null +++ b/.github/scripts/linux-ci-image-inputs.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash + +# Prints the files whose contents define a Linux CI image profile. +linux_ci_image_inputs() { + local profile=$1 + local common=( + .github/images/linux-ci/install-packages.sh + .github/images/linux-ci/write-manifest.sh + .github/scripts/linux-ci-image-fingerprint.sh + .github/scripts/linux-ci-image-inputs.sh + .github/scripts/linux-ci-image-config.sh + .github/scripts/linux-ccache-compiler-signature.sh + .github/scripts/run-apt-get.sh + .github/scripts/verify-linux-ci-image.sh + ) + + case "$profile" in + normal-noble) + printf '%s\n' \ + "${common[@]}" \ + .github/images/linux-ci/Dockerfile.noble \ + .github/scripts/build-pfunit-linux.sh \ + .github/scripts/build-hamlib-linux.sh + ;; + normal-bookworm) + printf '%s\n' \ + "${common[@]}" \ + .github/images/linux-ci/Dockerfile.bookworm \ + .github/scripts/build-pfunit-linux.sh \ + .github/scripts/build-hamlib-linux.sh + ;; + armhf-cross-bookworm) + printf '%s\n' \ + .github/images/linux-ci/Dockerfile.armhf-cross \ + .github/images/linux-ci/armhf-cross-toolchain.config \ + .github/scripts/armhf-ci-image-config.sh \ + .github/scripts/build-armhf-toolchain-smoke.sh \ + .github/scripts/build-hamlib-armhf-cross.sh \ + .github/scripts/linux-ccache-compiler-signature.sh \ + .github/scripts/linux-ci-image-config.sh \ + .github/scripts/linux-ci-image-fingerprint.sh \ + .github/scripts/linux-ci-image-inputs.sh \ + .github/scripts/normalize-armhf-sysroot-symlinks.sh \ + .github/scripts/run-apt-get.sh \ + .github/scripts/verify-armhf-ci-image.sh \ + .github/scripts/write-armhf-ci-manifest.sh + ;; + armhf-runtime-bookworm) + printf '%s\n' \ + .github/images/linux-ci/Dockerfile.armhf-runtime \ + .github/images/linux-ci/install-armhf-runtime-packages.sh \ + .github/scripts/armhf-ci-image-config.sh \ + .github/scripts/linux-ci-image-config.sh \ + .github/scripts/linux-ci-image-fingerprint.sh \ + .github/scripts/linux-ci-image-inputs.sh \ + .github/scripts/run-apt-get.sh \ + .github/scripts/verify-armhf-ci-image.sh \ + .github/scripts/write-armhf-ci-manifest.sh + ;; + tsan-noble) + printf '%s\n' \ + "${common[@]}" \ + .github/images/linux-ci/Dockerfile.noble \ + .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-tsan-deps-linux.sh + ;; + *) + echo "Unsupported Linux CI image profile: $profile" >&2 + return 2 + ;; + esac +} diff --git a/.github/scripts/list-release-assets.sh b/.github/scripts/list-release-assets.sh new file mode 100755 index 00000000..28c62c95 --- /dev/null +++ b/.github/scripts/list-release-assets.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -ne 2 ]; then + echo "Usage: $0 ARTIFACTS_DIRECTORY VERSION" >&2 + exit 2 +fi + +artifacts_directory="$1" +version="$2" + +find "$artifacts_directory" -maxdepth 2 -type f \ + \( -path "$artifacts_directory/wsjtx-${version}-arm64-macOS.pkg/*.pkg" \ + -o -path "$artifacts_directory/wsjtx-${version}-x86_64-macOS.pkg/*.pkg" \ + -o -path "$artifacts_directory/wsjtx-${version}-linux-*-AppImage/*.AppImage" \ + -o -path "$artifacts_directory/wsjtx-${version}-linux-*-deb/*.deb" \ + -o -path "$artifacts_directory/wsjtx-${version}-linux-*-rpm/*.rpm" \ + -o -path "$artifacts_directory/wsjtx-${version}-windows-x86_64-installer/*.exe" \ + -o -path "$artifacts_directory/wsjtx-${version}-src.tar.gz" \ + \) -print | sort diff --git a/.github/scripts/normalize-armhf-sysroot-symlinks.sh b/.github/scripts/normalize-armhf-sysroot-symlinks.sh new file mode 100755 index 00000000..09a0403b --- /dev/null +++ b/.github/scripts/normalize-armhf-sysroot-symlinks.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -ne 1 ]; then + echo "Usage: normalize-armhf-sysroot-symlinks.sh SYSROOT" >&2 + exit 2 +fi + +sysroot=${1%/} +if [ ! -d "$sysroot" ]; then + echo "ARMHF sysroot does not exist: $sysroot" >&2 + exit 1 +fi + +# Debian packages may contain absolute library links. Make them relative so an +# x86 linker cannot follow them into the builder host instead of the sysroot. +count=0 +while IFS= read -r -d '' link; do + target="$(readlink -- "$link")" + case "$target" in + /*) + relative="$(realpath --canonicalize-missing \ + --relative-to="$(dirname -- "$link")" "$sysroot$target")" + ln -sfn -- "$relative" "$link" + count=$((count + 1)) + ;; + esac +done < <(find "$sysroot" -type l -print0) + +echo "Normalized $count absolute ARMHF sysroot symlinks" diff --git a/.github/scripts/package-linux-armhf.sh b/.github/scripts/package-linux-armhf.sh new file mode 100755 index 00000000..abef3284 --- /dev/null +++ b/.github/scripts/package-linux-armhf.sh @@ -0,0 +1,137 @@ +#!/usr/bin/env bash +set -euo pipefail + +VERSION="${VERSION:?missing}" +ARCH="${ARCH:?missing}" +if [ "$ARCH" != armhf ]; then + echo "package-linux-armhf.sh supports only arch=armhf" >&2 + exit 2 +fi + +github_api_token="${GITHUB_TOKEN:-}" +unset GITHUB_TOKEN +cd /work +# shellcheck source=.github/scripts/armhf-ci-image-config.sh +source .github/scripts/armhf-ci-image-config.sh +# shellcheck source=.github/scripts/linux-artifact-validation.sh +source .github/scripts/linux-artifact-validation.sh +export LD_LIBRARY_PATH="$ARMHF_RUNTIME_PREFIX" +export ARMHF_QEMU_EXECUTABLE +export LINUX_APPIMAGE_RUNNER="$ARMHF_QEMU_EXECUTABLE" + +echo "::group::Package .deb" +( + cd wsjtx-build + cpack -G DEB \ + -D "CPACK_DEBIAN_FILE_NAME=wsjtx-${VERSION}-linux-${ARCH}.deb" \ + -D "CPACK_INSTALL_CMAKE_PROJECTS=" \ + -D "CPACK_INSTALLED_DIRECTORIES=/work/AppDir;/" +) +DEB="wsjtx-build/wsjtx-${VERSION}-linux-${ARCH}.deb" +if [ ! -f "$DEB" ]; then + echo "::error::cpack -G DEB produced no package at $DEB" + exit 1 +fi +dpkg-deb --info "$DEB" | sed -n '1,20p' +deb_arch="$(dpkg-deb -f "$DEB" Architecture)" +if [ "$deb_arch" != armhf ]; then + echo "::error::DEB architecture is $deb_arch, expected armhf" + exit 1 +fi +validate_deb_package "$DEB" +echo "::endgroup::" + +echo "::group::Package RPM" +( + cd wsjtx-build + cpack -G RPM \ + -D "CPACK_INSTALL_CMAKE_PROJECTS=" \ + -D "CPACK_INSTALLED_DIRECTORIES=/work/AppDir;/" +) +rpms=(wsjtx-build/*.rpm) +if [ ! -f "${rpms[0]}" ]; then + echo "::error::cpack -G RPM produced no package" + exit 1 +fi +RPM=${rpms[0]} +rpm_arch="$(rpm -qp --qf '%{ARCH}' "$RPM")" +case "$rpm_arch" in + armv7hl|armv7l) ;; + *) echo "::error::RPM architecture is $rpm_arch, expected armv7"; exit 1 ;; +esac +rpm -qpi "$RPM" +rpm -qpR "$RPM" +validate_rpm_package "$RPM" +echo "::endgroup::" + +echo "::group::Validate AppDir" +validate_linux_application_tree AppDir appdir "$ARCH" +echo "::endgroup::" + +echo "::group::Package AppImage" +LINUXDEPLOY_TAG=1-alpha-20251107-1 +LINUXDEPLOY_SHA256=e359161979fa4bee50b92ce7102fb510299caebf34f711d983fba7a8f4bb1c2e +QT_PLUGIN_ASSET_NAME=linuxdeploy-plugin-qt-armhf.AppImage +curl_flags=(--fail --show-error --silent --location --retry 5 --retry-delay 5) +github_api_curl() { + local api_headers=(-H "User-Agent: wsjtx-ci") + if [ -n "$github_api_token" ]; then + api_headers+=(-H "Authorization: Bearer ${github_api_token}") + env GITHUB_TOKEN="$github_api_token" curl "${curl_flags[@]}" "${api_headers[@]}" "$@" + else + curl "${curl_flags[@]}" "${api_headers[@]}" "$@" + fi +} +QT_PLUGIN_ASSET_ID="$( + github_api_curl -H "Accept: application/vnd.github+json" \ + "https://api.github.com/repos/linuxdeploy/linuxdeploy-plugin-qt/releases/tags/continuous" | + python3 -c 'import json, sys; name = sys.argv[1]; matches = [asset for asset in json.load(sys.stdin)["assets"] if asset["name"] == name]; print(matches[0]["id"]) if matches else sys.exit("asset not found: " + name)' "$QT_PLUGIN_ASSET_NAME" +)" +curl "${curl_flags[@]}" -o linuxdeploy.AppImage \ + "https://github.com/linuxdeploy/linuxdeploy/releases/download/${LINUXDEPLOY_TAG}/linuxdeploy-armhf.AppImage" +mkdir -p wsjtx-build/appimage-tools +github_api_curl -H "Accept: application/octet-stream" \ + -o wsjtx-build/appimage-tools/qt-plugin.AppImage \ + "https://api.github.com/repos/linuxdeploy/linuxdeploy-plugin-qt/releases/assets/${QT_PLUGIN_ASSET_ID}" +echo "$LINUXDEPLOY_SHA256 linuxdeploy.AppImage" | sha256sum -c - +chmod +x linuxdeploy.AppImage wsjtx-build/appimage-tools/qt-plugin.AppImage +# shellcheck disable=SC2016 # variables expand when the generated wrapper runs +printf '%s\n' \ + '#!/bin/sh' \ + 'exec "${ARMHF_QEMU_EXECUTABLE:?}" /work/wsjtx-build/appimage-tools/qt-plugin.AppImage "$@"' \ + > linuxdeploy-plugin-qt.AppImage +chmod +x linuxdeploy-plugin-qt.AppImage +# Supply linuxdeploy with the non-executing ARMHF resolver; native ldd cannot +# safely enter the target loader from this already-emulated container. +ln -sfn /work/.github/scripts/armhf-static-ldd.sh wsjtx-build/appimage-tools/ldd + +for target in AppDir/usr/bin/wsjtx AppDir/usr/bin/jt9 AppDir/usr/bin/qmap \ + AppDir/usr/bin/map65; do + wsjtx-build/appimage-tools/ldd "$target" +done + +export APPIMAGE_EXTRACT_AND_RUN=1 +export OUTPUT="wsjtx-${VERSION}-linux-${ARCH}.AppImage" +env -u GITHUB_TOKEN PATH="/work/wsjtx-build/appimage-tools:$PATH" \ + "$ARMHF_QEMU_EXECUTABLE" \ + ./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 +file "$OUTPUT" +echo "::endgroup::" + +echo "::group::Validate AppImage payload" +"$ARMHF_QEMU_EXECUTABLE" ./"$OUTPUT" --appimage-extract >/dev/null +validate_linux_application_tree squashfs-root appimage "$ARCH" +rm -rf /work/squashfs-root +echo "::endgroup::" + +echo "::group::AppImage startup smoke" +run_packaged_appimage_startup_smoke \ + "./$OUTPUT" wsjtx-build/appimage-startup-smoke.log +echo "::endgroup::" + +echo "ARMHF package phase complete for version=$VERSION" diff --git a/.github/scripts/release-policy.py b/.github/scripts/release-policy.py new file mode 100644 index 00000000..ec7abe09 --- /dev/null +++ b/.github/scripts/release-policy.py @@ -0,0 +1,406 @@ +#!/usr/bin/env python3 +"""Validate release identity and installer artifact policy.""" + +from __future__ import annotations + +import argparse +import hashlib +import json +import re +import sys +import tarfile +import zipfile +from pathlib import Path + + +VERSION_RE = re.compile(r"^(?P<numeric>\d+\.\d+\.\d+)(?:-rc(?P<rc>[1-9]\d*))?$") +MACOS_MODES = ("validation", "distribution") +WINDOWS_MODES = ("signpath", "unsigned") + + +def classify(version: str) -> dict[str, str]: + match = VERSION_RE.fullmatch(version) + if not match: + raise ValueError("version must be X.Y.Z or X.Y.Z-rcN") + rc = match.group("rc") or "" + numeric = match.group("numeric") + major, minor, _ = numeric.split(".") + return { + "version": version, + "numeric": numeric, + "channel": "RC" if rc else "GA", + "rc_number": rc, + "release_branch": f"release/{major}.{minor}", + } + + +def parse_state(contents: str, *, expected_revision: str | None = None) -> dict[str, str]: + state = {} + for line in contents.splitlines(): + key, separator, value = line.partition("=") + if not separator or key in state: + raise ValueError("release-state.txt must contain unique key=value lines") + state[key] = value + required_keys = {"version", "channel", "rc", "revision"} + if not required_keys <= set(state) or set(state) - required_keys - {"windows_signing"}: + raise ValueError("release-state.txt must define version, channel, rc, revision, and optionally windows_signing") + state.setdefault("windows_signing", "signpath") + if state["windows_signing"] not in WINDOWS_MODES: + raise ValueError("release-state.txt windows_signing must be signpath or unsigned") + if state["channel"] not in {"DEVEL", "RC", "GA"}: + raise ValueError("release-state.txt channel must be DEVEL, RC, or GA") + if not re.fullmatch(r"\d+\.\d+\.\d+", state["version"]): + raise ValueError("release-state.txt version must be X.Y.Z") + if state["channel"] == "RC": + if not re.fullmatch(r"[1-9]\d*", state["rc"]): + raise ValueError("RC release state requires a positive RC number") + elif state["rc"]: + raise ValueError("DEVEL and GA release states require an empty RC number") + required_revision = expected_revision or "$Format:%H$" + if state["revision"].lower() != required_revision.lower(): + raise ValueError(f"release-state.txt revision must be {required_revision}") + return state + + +def read_state(root: Path, *, expected_revision: str | None = None) -> dict[str, str]: + return parse_state( + (root / "release-state.txt").read_text(encoding="utf-8"), + expected_revision=expected_revision, + ) + + +def validate_source(root: Path, version: str) -> dict[str, str]: + identity = classify(version) + state = read_state(root) + errors = [] + if state["version"] != identity["numeric"]: + errors.append(f"release-state version {state['version']} does not match {identity['numeric']}") + if state["channel"] != identity["channel"]: + errors.append(f"release channel {state['channel']} does not match {identity['channel']}") + if state["rc"] != identity["rc_number"]: + errors.append(f"RC number {state['rc'] or '<empty>'} does not match {identity['rc_number'] or '<empty>'}") + if errors: + raise ValueError("; ".join(errors)) + identity["windows_signing"] = state["windows_signing"] + return identity + + +def validate_archive(path: Path, version: str, commit: str) -> None: + if not re.fullmatch(r"[0-9a-f]{40}|[0-9a-f]{64}", commit): + raise ValueError("archive commit must be a full lowercase Git object ID") + names: list[str] + release_state_contents: str + if zipfile.is_zipfile(path): + with zipfile.ZipFile(path) as archive: + names = archive.namelist() + matches = [name for name in names if name.count("/") == 1 and name.endswith("/release-state.txt")] + if len(matches) != 1: + raise ValueError("source archive must contain one top-level release-state.txt") + release_state_contents = archive.read(matches[0]).decode("utf-8") + else: + with tarfile.open(path, "r:*") as archive: + names = archive.getnames() + matches = [name for name in names if name.count("/") == 1 and name.endswith("/release-state.txt")] + if len(matches) != 1: + raise ValueError("source archive must contain one top-level release-state.txt") + member = archive.extractfile(matches[0]) + if member is None: + raise ValueError("source archive release-state.txt is not a regular file") + release_state_contents = member.read().decode("utf-8") + if any(part == ".git" for name in names for part in Path(name).parts): + raise ValueError("source archive must not contain .git metadata") + identity = classify(version) + state = parse_state(release_state_contents, expected_revision=commit) + if state["version"] != identity["numeric"] or state["channel"] != identity["channel"] or state["rc"] != identity["rc_number"]: + raise ValueError("source archive release identity does not match its tag") + + +def expected_assets(version: str, distribution: bool) -> list[str]: + mac_suffix = "macOS.pkg" if distribution else "macOS-unsigned.pkg" + return [ + f"wsjtx-{version}-arm64-{mac_suffix}", + f"wsjtx-{version}-x86_64-{mac_suffix}", + f"wsjtx-{version}-linux-x86_64-AppImage", + f"wsjtx-{version}-linux-aarch64-AppImage", + f"wsjtx-{version}-linux-armhf-AppImage", + f"wsjtx-{version}-windows-x86_64-installer-signed" if distribution else f"wsjtx-{version}-windows-x86_64-installer", + ] + + +def public_expected_assets(version: str, macos_mode: str, windows_mode: str = "signpath") -> list[str]: + if macos_mode not in MACOS_MODES: + raise ValueError(f"unsupported macOS release mode: {macos_mode}") + if windows_mode not in WINDOWS_MODES: + raise ValueError(f"unsupported Windows release mode: {windows_mode}") + mac_suffix = "macOS.pkg" if macos_mode == "distribution" else "macOS-unsigned.pkg" + return [ + f"wsjtx-{version}-arm64-{mac_suffix}", + f"wsjtx-{version}-x86_64-{mac_suffix}", + f"wsjtx-{version}-linux-x86_64-AppImage", + f"wsjtx-{version}-linux-aarch64-AppImage", + f"wsjtx-{version}-linux-armhf-AppImage", + f"wsjtx-{version}-windows-x86_64-installer{'-signed' if windows_mode == 'signpath' else ''}", + ] + + +def collect_asset_files(root: Path, expected: list[str]) -> list[Path]: + files: list[Path] = [] + for artifact in expected: + directory = root / artifact + if not directory.is_dir(): + raise ValueError(f"missing artifact directory: {artifact}") + suffix = ".pkg" if "macOS" in artifact else ".AppImage" if "linux" in artifact else ".exe" + matches = sorted(path for path in directory.rglob(f"*{suffix}") if path.is_file()) + if len(matches) != 1: + raise ValueError(f"{artifact} must contain exactly one {suffix} file; found {len(matches)}") + if matches[0].stat().st_size == 0: + raise ValueError(f"artifact is empty: {matches[0]}") + files.append(matches[0]) + return files + + +def find_asset_files(root: Path, version: str, distribution: bool) -> list[Path]: + files = collect_asset_files(root, expected_assets(version, distribution)) + if distribution: + unsigned = sorted(root.rglob("*-unsigned.pkg")) + if unsigned: + raise ValueError(f"unsigned macOS packages cannot be published: {unsigned[0]}") + return files + + +def find_public_asset_files( + root: Path, version: str, macos_mode: str, windows_mode: str = "signpath" +) -> list[Path]: + files = collect_asset_files(root, public_expected_assets(version, macos_mode, windows_mode)) + if macos_mode == "distribution": + unsigned = sorted(root.rglob("*-unsigned.pkg")) + if unsigned: + raise ValueError(f"unsigned macOS packages cannot be published: {unsigned[0]}") + if windows_mode == "unsigned": + installer = files[-1] + if installer.name != f"wsjtx-{version}-win64.exe": + raise ValueError(f"unexpected unsigned Windows installer: {installer.name}") + if (root / f"wsjtx-{version}-windows-x86_64-installer-signed").exists(): + raise ValueError("signed Windows installer cannot accompany unsigned release") + return files + + +def release_files( + root: Path, version: str, macos_mode: str = "distribution", windows_mode: str = "signpath" +) -> list[Path]: + files = find_public_asset_files(root, version, macos_mode, windows_mode) + for arch in ("x86_64", "aarch64", "armhf"): + for package_type, suffix in (("deb", ".deb"), ("rpm", ".rpm")): + directory = root / f"wsjtx-{version}-linux-{arch}-{package_type}" + if not directory.is_dir(): + raise ValueError(f"missing artifact directory: {directory.name}") + matches = sorted(path for path in directory.rglob(f"*{suffix}") if path.is_file()) + if len(matches) != 1 or matches[0].stat().st_size == 0: + raise ValueError(f"{directory.name} must contain exactly one non-empty {suffix} file") + files.append(matches[0]) + source = root / f"wsjtx-{version}-src.tar.gz" + if not source.is_file() or source.stat().st_size == 0: + raise ValueError(f"missing source archive: {source.name}") + files.append(source) + names = [path.name for path in files] + if len(names) != len(set(names)): + raise ValueError("release assets must have unique filenames") + return sorted(files, key=lambda item: item.name) + + +def hash_file(path: Path) -> str: + digest = hashlib.sha256() + with path.open("rb") as stream: + for chunk in iter(lambda: stream.read(1024 * 1024), b""): + digest.update(chunk) + return digest.hexdigest() + + +def read_single_json(directory: Path) -> dict: + matches = sorted(directory.glob("*.json")) + if len(matches) != 1: + raise ValueError(f"{directory.name} must contain exactly one JSON report") + return json.loads(matches[0].read_text(encoding="utf-8")) + + +def verify_signing_reports( + root: Path, version: str, commit: str, tag: str, macos_mode: str = "distribution", + windows_mode: str = "signpath", +) -> None: + if macos_mode not in MACOS_MODES: + raise ValueError(f"unsupported macOS release mode: {macos_mode}") + if windows_mode not in WINDOWS_MODES: + raise ValueError(f"unsupported Windows release mode: {windows_mode}") + for arch in ("arm64", "x86_64"): + report = read_single_json(root / f"macos-signing-report-{version}-{arch}") + if report.get("mode") != macos_mode or report.get("git_sha") != commit: + raise ValueError(f"macOS {arch} report does not bind {macos_mode} packaging to {commit}") + if macos_mode == "distribution": + if report.get("notarization", {}).get("status") != "Accepted": + raise ValueError(f"macOS {arch} notarization was not accepted") + if report.get("stapled") is not True or report.get("gatekeeper_accepted") is not True: + raise ValueError(f"macOS {arch} trust verification is incomplete") + if not re.fullmatch(r"[A-Z0-9]{10}", report.get("team_id", "")): + raise ValueError(f"macOS {arch} report has no verified Apple Team ID") + for field in ("application_certificate_sha1", "installer_certificate_sha1"): + if not re.fullmatch(r"[0-9A-F]{40}", report.get(field, "")): + raise ValueError(f"macOS {arch} report has no verified {field}") + artifact_dir = f"wsjtx-{version}-{arch}-macOS.pkg" + else: + if any(report.get(field) is not False for field in ("signed", "notarized", "publishable")): + raise ValueError(f"macOS {arch} validation report does not describe an unsigned package") + artifact_dir = f"wsjtx-{version}-{arch}-macOS-unsigned.pkg" + package = root / artifact_dir / report.get("artifact", "") + if not package.is_file() or report.get("sha256") != hash_file(package): + raise ValueError(f"macOS {arch} report hash does not match its package") + + if windows_mode == "unsigned": + for suffix in ("windows-signing-request", "windows-signing-verification"): + if (root / f"wsjtx-{version}-{suffix}").exists(): + raise ValueError(f"Windows signing report cannot accompany unsigned release: {suffix}") + return + + request = read_single_json(root / f"wsjtx-{version}-windows-signing-request") + verification = read_single_json(root / f"wsjtx-{version}-windows-signing-verification") + if request.get("policy") != "release-signing" or request.get("commit") != commit: + raise ValueError("Windows signing request does not match the release commit and policy") + if request.get("tag") != tag: + raise ValueError("Windows signing request does not match the release tag") + if verification.get("commit") != commit or verification.get("tag") != tag: + raise ValueError("Windows verification report does not match the release ref") + if verification.get("status") != "Valid" or not verification.get("timestamp_thumbprint"): + raise ValueError("Windows signature or timestamp is not trusted") + if verification.get("identity_verified") is not True: + raise ValueError("Windows signer identity was not verified against the release allowlist") + if not verification.get("signer_subject") or not verification.get("signer_thumbprint"): + raise ValueError("Windows signer identity is missing from the verification report") + installer = root / f"wsjtx-{version}-windows-x86_64-installer-signed" / verification.get("artifact", "") + if not installer.is_file() or verification.get("sha256") != hash_file(installer): + raise ValueError("Windows verification report hash does not match its installer") + + +def write_manifest(args: argparse.Namespace) -> None: + root = Path(args.artifacts) + digests = { + "x86_64": args.linux_x86_64_digest, + "aarch64": args.linux_aarch64_digest, + "armhf_cross": args.linux_armhf_cross_digest, + "armhf_runtime": args.linux_armhf_digest, + } + for arch, digest in digests.items(): + if not re.fullmatch(r"sha256:[0-9a-f]{64}", digest): + raise ValueError(f"Linux {arch} builder digest is not an immutable sha256 digest") + files = release_files(root, args.version, args.macos_mode, args.windows_mode) + replaceable_macos = ( + {f"wsjtx-{args.version}-{arch}-macOS.pkg" for arch in ("arm64", "x86_64")} + if args.macos_mode == "validation" + else set() + ) + entries = [ + {"name": path.name, "sha256": hash_file(path), "size": path.stat().st_size} + for path in sorted(files, key=lambda item: item.name) + if path.name not in replaceable_macos + ] + manifest = { + "schema": 1, + "repository": args.repository, + "tag": f"v{args.version}", + "commit": args.commit, + "workflow_run": args.run_id, + "linux_builders": digests, + "macos_signing": { + "mode": "manual" if args.macos_mode == "validation" else "distribution", + "replaceable_assets": sorted(replaceable_macos), + }, + "windows_signing": {"mode": args.windows_mode}, + "assets": entries, + } + output = root / "release-manifest.json" + output.write_text(json.dumps(manifest, indent=2) + "\n", encoding="utf-8") + checksums = root / "SHA256SUMS" + checksums.write_text( + "".join(f"{entry['sha256']} {entry['name']}\n" for entry in entries), + encoding="utf-8", + ) + + +def main() -> int: + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers(dest="command", required=True) + classify_parser = subparsers.add_parser("classify") + classify_parser.add_argument("version") + state_parser = subparsers.add_parser("read-state") + state_parser.add_argument("--root", default=".") + validate_parser = subparsers.add_parser("validate-source") + validate_parser.add_argument("version") + validate_parser.add_argument("--root", default=".") + archive_parser = subparsers.add_parser("validate-archive") + archive_parser.add_argument("version") + archive_parser.add_argument("archive") + archive_parser.add_argument("--commit", required=True) + assets_parser = subparsers.add_parser("verify-assets") + assets_parser.add_argument("version") + assets_parser.add_argument("artifacts") + assets_parser.add_argument("--distribution", action="store_true") + assets_parser.add_argument("--macos-mode", choices=MACOS_MODES) + assets_parser.add_argument("--windows-mode", choices=WINDOWS_MODES, default="signpath") + files_parser = subparsers.add_parser("release-files") + files_parser.add_argument("version") + files_parser.add_argument("artifacts") + files_parser.add_argument("--macos-mode", choices=MACOS_MODES, default="distribution") + files_parser.add_argument("--windows-mode", choices=WINDOWS_MODES, default="signpath") + reports_parser = subparsers.add_parser("verify-signing-reports") + reports_parser.add_argument("version") + reports_parser.add_argument("artifacts") + reports_parser.add_argument("--commit", required=True) + reports_parser.add_argument("--tag", required=True) + reports_parser.add_argument("--macos-mode", choices=MACOS_MODES, default="distribution") + reports_parser.add_argument("--windows-mode", choices=WINDOWS_MODES, default="signpath") + manifest_parser = subparsers.add_parser("write-manifest") + manifest_parser.add_argument("version") + manifest_parser.add_argument("artifacts") + manifest_parser.add_argument("--repository", required=True) + manifest_parser.add_argument("--commit", required=True) + manifest_parser.add_argument("--run-id", required=True) + manifest_parser.add_argument("--linux-x86-64-digest", required=True) + manifest_parser.add_argument("--linux-aarch64-digest", required=True) + manifest_parser.add_argument("--linux-armhf-cross-digest", required=True) + manifest_parser.add_argument("--linux-armhf-digest", required=True) + manifest_parser.add_argument("--macos-mode", choices=MACOS_MODES, default="distribution") + manifest_parser.add_argument("--windows-mode", choices=WINDOWS_MODES, default="signpath") + args = parser.parse_args() + try: + if args.command == "classify": + print(json.dumps(classify(args.version))) + elif args.command == "read-state": + print(json.dumps(read_state(Path(args.root)))) + elif args.command == "validate-source": + print(json.dumps(validate_source(Path(args.root), args.version))) + elif args.command == "validate-archive": + validate_archive(Path(args.archive), args.version, args.commit) + elif args.command == "verify-assets": + files = ( + find_public_asset_files(Path(args.artifacts), args.version, args.macos_mode, args.windows_mode) + if args.macos_mode + else find_asset_files(Path(args.artifacts), args.version, args.distribution) + ) + for path in files: + print(path) + elif args.command == "release-files": + for path in release_files(Path(args.artifacts), args.version, args.macos_mode, args.windows_mode): + print(path) + elif args.command == "verify-signing-reports": + verify_signing_reports( + Path(args.artifacts), args.version, args.commit, args.tag, args.macos_mode, + args.windows_mode, + ) + else: + write_manifest(args) + except (OSError, ValueError, tarfile.TarError, zipfile.BadZipFile) as error: + print(f"release policy error: {error}", file=sys.stderr) + return 1 + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/.github/scripts/resolve-linux-ci-image-tag.py b/.github/scripts/resolve-linux-ci-image-tag.py new file mode 100755 index 00000000..8f67bc0e --- /dev/null +++ b/.github/scripts/resolve-linux-ci-image-tag.py @@ -0,0 +1,124 @@ +#!/usr/bin/env python3 +"""Resolve the coherent immutable generation selected by linux-noble:stable.""" + +from __future__ import annotations + +import os +import re +import sys +from pathlib import Path + + +sys.path.insert(0, str(Path(__file__).parent)) +from ghcr_retention import GitHubPackagesClient, Version # noqa: E402, F401 + + +OWNER = "WSJTX" +NORMAL_PACKAGE = "wsjtx-internal/linux-noble" +TSAN_PACKAGE = "wsjtx-internal/linux-tsan-noble" +ARM64_PACKAGE = "wsjtx-internal/linux-arm64-bookworm" +ARMHF_PACKAGE = "wsjtx-internal/linux-armv7-bookworm" +ARMHF_CROSS_PACKAGE = "wsjtx-internal/linux-armhf-cross-bookworm" +ROUTINE_PACKAGES = (ARM64_PACKAGE,) +BUILD_TAG = re.compile(r"^build-\d{8}-\d+-\d+$") + + +def resolve(client: GitHubPackagesClient, *, require_armhf: bool = False) -> str: + versions = client.list_versions(OWNER, NORMAL_PACKAGE) + stable = [version for version in versions if "stable" in version.tags] + if not stable: + raise RuntimeError( + "No promoted Linux CI image generation is available: " + "linux-noble:stable is missing. Bootstrap the GHCR images with " + "warm-dependency-caches.yml before running Linux CI." + ) + if len(stable) != 1: + raise RuntimeError(f"expected one linux-noble:stable version, found {len(stable)}") + build_tags = [tag for tag in stable[0].tags if BUILD_TAG.fullmatch(tag)] + if len(build_tags) != 1: + raise RuntimeError( + "linux-noble:stable must share a version with exactly one immutable build tag" + ) + generation = build_tags[0] + required_packages = ROUTINE_PACKAGES + ((ARMHF_PACKAGE,) if require_armhf else ()) + for package in required_packages: + if not any(generation in version.tags for version in client.list_versions(OWNER, package)): + raise RuntimeError(f"{package}:{generation} does not exist") + return generation + + +def resolve_armhf(client: GitHubPackagesClient) -> str: + versions = client.list_versions(OWNER, ARMHF_PACKAGE) + stable = [version for version in versions if "stable" in version.tags] + if not stable: + raise RuntimeError( + "No promoted armhf Linux CI image generation is available: " + "linux-armv7-bookworm:stable is missing. Publish an armhf image " + "with include_armhf=true before running the armhf build." + ) + if len(stable) != 1: + raise RuntimeError( + "expected one linux-armv7-bookworm:stable version, " + f"found {len(stable)}" + ) + build_tags = [tag for tag in stable[0].tags if BUILD_TAG.fullmatch(tag)] + if len(build_tags) != 1: + raise RuntimeError( + "linux-armv7-bookworm:stable must share a version with exactly " + "one immutable build tag" + ) + generation = build_tags[0] + if not any( + generation in version.tags + for version in client.list_versions(OWNER, ARMHF_CROSS_PACKAGE) + ): + raise RuntimeError(f"{ARMHF_CROSS_PACKAGE}:{generation} does not exist") + return generation + + +def resolve_tsan(client: GitHubPackagesClient) -> str: + versions = client.list_versions(OWNER, TSAN_PACKAGE) + stable = [version for version in versions if "stable" in version.tags] + if not stable: + raise RuntimeError( + "No promoted TSan Linux CI image generation is available: " + "linux-tsan-noble:stable is missing. Publish an image with " + "image_set=tsan before running the TSan workflow." + ) + if len(stable) != 1: + raise RuntimeError( + "expected one linux-tsan-noble:stable version, " + f"found {len(stable)}" + ) + build_tags = [tag for tag in stable[0].tags if BUILD_TAG.fullmatch(tag)] + if len(build_tags) != 1: + raise RuntimeError( + "linux-tsan-noble:stable must share a version with exactly one " + "immutable build tag" + ) + return build_tags[0] + + +def main() -> int: + token = os.environ.get("GITHUB_TOKEN") + if not token: + print("GITHUB_TOKEN is required", file=sys.stderr) + return 2 + client = GitHubPackagesClient(token) + if os.environ.get("RESOLVE_ARMHF") == "true": + generation = resolve_armhf(client) + elif os.environ.get("RESOLVE_TSAN") == "true": + generation = resolve_tsan(client) + else: + require_armhf = os.environ.get("REQUIRE_ARMHF") == "true" + generation = resolve(client, require_armhf=require_armhf) + print(f"Resolved Linux CI image generation: {generation}") + output = os.environ.get("GITHUB_OUTPUT") + if output: + with open(output, "a", encoding="utf-8") as stream: + stream.write(f"image_tag={generation}\n") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/.github/scripts/run-apt-get.sh b/.github/scripts/run-apt-get.sh new file mode 100755 index 00000000..0e7c363e --- /dev/null +++ b/.github/scripts/run-apt-get.sh @@ -0,0 +1,96 @@ +#!/bin/bash + +set -euo pipefail + +if [ "$#" -eq 0 ]; then + echo "usage: $0 <apt-get arguments...>" >&2 + exit 2 +fi + +apt_options=( + -o Acquire::Retries=3 + -o Acquire::http::Timeout=30 + -o Acquire::https::Timeout=30 + -o DPkg::Lock::Timeout=60 +) + +run_privileged() { + if [ "$(id -u)" = "0" ]; then + "$@" + else + sudo "$@" + fi +} + +run_with_timeout() { + local timeout_limit="$1" + shift + run_privileged timeout --signal=TERM --kill-after=30s "$timeout_limit" "$@" +} + +is_timeout_status() { + [ "$1" -eq 124 ] || [ "$1" -eq 137 ] +} + +case "$1" in + update) + timeout_limit="${APT_UPDATE_TIMEOUT:-15m}" + status=0 + run_with_timeout "$timeout_limit" apt-get \ + "${apt_options[@]}" -o APT::Update::Error-Mode=any "$@" || status=$? + if is_timeout_status "$status"; then + echo "::error::apt-get update exceeded or was killed while enforcing its ${timeout_limit} wall-clock limit" + fi + exit "$status" + ;; + install) + download_timeout="${APT_DOWNLOAD_TIMEOUT:-${APT_INSTALL_TIMEOUT:-20m}}" + download_attempts="${APT_DOWNLOAD_ATTEMPTS:-2}" + case "$download_attempts" in + ''|*[!0-9]*|0) + echo "::error::APT_DOWNLOAD_ATTEMPTS must be a positive integer" >&2 + exit 2 + ;; + esac + + for ((attempt = 1; attempt <= download_attempts; ++attempt)); do + echo "::group::APT package acquisition attempt ${attempt}/${download_attempts}" + status=0 + run_with_timeout "$download_timeout" apt-get \ + "${apt_options[@]}" --download-only "$@" || status=$? + echo "::endgroup::" + + if [ "$status" -eq 0 ]; then + break + fi + if ! is_timeout_status "$status"; then + echo "::error::apt-get install failed during package acquisition with status ${status}" + exit "$status" + fi + if [ "$attempt" -eq "$download_attempts" ]; then + echo "::error::apt-get install package acquisition exceeded or was killed while enforcing its ${download_timeout} wall-clock limit" + exit "$status" + fi + echo "::warning::apt-get install package acquisition exceeded its ${download_timeout} wall-clock limit; retrying with cached partial downloads" + done + + echo "::group::APT package installation from local cache" + status=0 + run_privileged apt-get "${apt_options[@]}" --no-download "$@" || status=$? + echo "::endgroup::" + if [ "$status" -ne 0 ]; then + echo "::error::apt-get install failed during package unpacking or configuration with status ${status}" + run_privileged dpkg --audit || true + fi + exit "$status" + ;; + *) + timeout_limit="${APT_COMMAND_TIMEOUT:-20m}" + status=0 + run_with_timeout "$timeout_limit" apt-get "${apt_options[@]}" "$@" || status=$? + if is_timeout_status "$status"; then + echo "::error::apt-get $1 exceeded or was killed while enforcing its ${timeout_limit} wall-clock limit" + fi + exit "$status" + ;; +esac diff --git a/.github/scripts/select-ccache-key-suffix.sh b/.github/scripts/select-ccache-key-suffix.sh new file mode 100755 index 00000000..f4f501ef --- /dev/null +++ b/.github/scripts/select-ccache-key-suffix.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +set -euo pipefail + +# GitHub cache entries cannot be replaced. Per-attempt refresh keys let a +# forced rebuild supersede an older archive for the same SHA through prefix +# restoration without duplicating caches for ordinary reruns. +cache_key_suffix() { + local recache=$1 + local run_id=$2 + local run_attempt=$3 + + case "$recache" in + false) + return 0 + ;; + true) + if [ -z "$run_id" ] || [ -z "$run_attempt" ]; then + echo "GITHUB_RUN_ID and GITHUB_RUN_ATTEMPT are required for a ccache refresh key" >&2 + return 2 + fi + printf '%s' "-refresh-${run_id}-${run_attempt}" + ;; + *) + echo "RECACHE must be true or false" >&2 + return 2 + ;; + esac +} + +if [ "${1:-}" = --self-test ]; then + test -z "$(cache_key_suffix false 123 1)" + test -z "$(cache_key_suffix false '' '')" + test "$(cache_key_suffix true 123 1)" = "-refresh-123-1" + test "$(cache_key_suffix true 123 2)" = "-refresh-123-2" + if cache_key_suffix true "" 1 >/dev/null 2>&1; then + echo "self-test failed: empty run ID was accepted" >&2 + exit 1 + fi + if cache_key_suffix invalid 123 1 >/dev/null 2>&1; then + echo "self-test failed: invalid recache value was accepted" >&2 + exit 1 + fi + echo "select-ccache-key-suffix.sh self-test passed" + exit 0 +fi + +suffix="$(cache_key_suffix \ + "${RECACHE:-false}" \ + "${GITHUB_RUN_ID:-}" \ + "${GITHUB_RUN_ATTEMPT:-}")" + +echo "ccache key suffix: ${suffix:-<none>}" +if [ -n "${GITHUB_OUTPUT:-}" ]; then + echo "suffix=$suffix" >> "$GITHUB_OUTPUT" +fi diff --git a/.github/scripts/select-linux-ccache-save.sh b/.github/scripts/select-linux-ccache-save.sh new file mode 100755 index 00000000..730c3a2e --- /dev/null +++ b/.github/scripts/select-linux-ccache-save.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Base-branch caches are visible to pull requests. Keep publication limited to +# automatic develop builds and explicit maintainer requests on develop. +should_save_linux_ccache() { + local event_name=$1 + local ref=$2 + local requested_save=$3 + local recache=$4 + + if [ "$ref" != "refs/heads/develop" ]; then + return 1 + fi + + case "$event_name" in + push) + return 0 + ;; + workflow_dispatch) + [ "$requested_save" = true ] || [ "$recache" = true ] + ;; + *) + return 1 + ;; + esac +} + +expect_save() { + if ! should_save_linux_ccache "$@"; then + echo "self-test failed: expected cache save for $*" >&2 + exit 1 + fi +} + +expect_no_save() { + if should_save_linux_ccache "$@"; then + echo "self-test failed: expected no cache save for $*" >&2 + exit 1 + fi +} + +if [ "${1:-}" = --self-test ]; then + expect_save push refs/heads/develop false false + expect_save workflow_dispatch refs/heads/develop true false + expect_save workflow_dispatch refs/heads/develop false true + expect_save workflow_dispatch refs/heads/develop true true + + expect_no_save pull_request refs/pull/421/merge true true + expect_no_save workflow_dispatch refs/heads/topic true false + expect_no_save workflow_dispatch refs/heads/develop false false + expect_no_save schedule refs/heads/develop true true + + echo "select-linux-ccache-save.sh self-test passed" + exit 0 +fi + +save_ccache=false +if should_save_linux_ccache \ + "${EVENT_NAME:-}" \ + "${GITHUB_REF:-}" \ + "${REQUEST_SAVE_CCACHE:-false}" \ + "${RECACHE:-false}"; then + save_ccache=true +fi + +echo "Linux ccache save: $save_ccache" +if [ -n "${GITHUB_OUTPUT:-}" ]; then + echo "save_ccache=$save_ccache" >> "$GITHUB_OUTPUT" +fi diff --git a/.github/scripts/select-linux-packaging.sh b/.github/scripts/select-linux-packaging.sh new file mode 100755 index 00000000..371ea4fb --- /dev/null +++ b/.github/scripts/select-linux-packaging.sh @@ -0,0 +1,97 @@ +#!/usr/bin/env bash +# Decide whether a Linux CI build should create and upload packages. + +set -euo pipefail + +path_triggers_packaging() { + case "$1" in + CMakeLists.txt|*/CMakeLists.txt|CMake/*|cmake/*|CMakeCPackOptions.cmake.in|package_description.txt|\ + debian/*|bundle_fixup/*|artwork/*|icons/*|sounds/*|data/*|Palettes/*|translations/*|\ + example_log_configurations/*|contrib/Ephemeris/*|contrib/gpl-v3-logo.svg|*.desktop|\ + ALLCALL7.TXT|CALL3.TXT|cty.dat|cty.dat_copyright.txt|grid.dat|sat.dat|eclipse.txt|\ + COPYING|AUTHORS|THANKS|NEWS|BUGS|README.md|\ + .github/actions/build-linux-payload/*|\ + .github/workflows/ci.yml|.github/workflows/build-linux.yml|.github/workflows/build-selected-artifacts.yml|.github/workflows/release.yml|\ + .github/scripts/select-linux-packaging.sh|.github/scripts/linux-artifact-validation.sh|.github/scripts/package-linux-armhf.sh|\ + .github/scripts/validate-linux-armhf-runtime.sh|.github/scripts/build-linux-armhf-cross.sh|\ + .github/cmake/*|.github/images/linux-ci/*) + return 0 + ;; + *) + return 1 + ;; + esac +} + +expect_trigger() { + if ! path_triggers_packaging "$1"; then + echo "self-test failed: expected packaging for $1" >&2 + exit 1 + fi +} + +expect_no_trigger() { + if path_triggers_packaging "$1"; then + echo "self-test failed: did not expect packaging for $1" >&2 + exit 1 + fi +} + +if [ "${1:-}" = "--self-test" ]; then + expect_trigger "CMakeLists.txt" + expect_trigger "tests/unit/audio/CMakeLists.txt" + expect_trigger "CMake/Install.cmake" + expect_trigger "debian/postinst" + expect_trigger "sounds/73.wav" + expect_trigger "cty.dat" + expect_trigger "contrib/Ephemeris/JPLEPH" + expect_trigger "wsjtx.desktop" + expect_trigger ".github/actions/build-linux-payload/action.yml" + expect_trigger ".github/workflows/build-linux.yml" + expect_trigger ".github/scripts/select-linux-packaging.sh" + expect_trigger ".github/scripts/linux-artifact-validation.sh" + expect_trigger ".github/images/linux-ci/install-packages.sh" + + expect_no_trigger "widgets/mainwindow.cpp" + expect_no_trigger "tests/unit/audio/test_tx_request.cpp" + expect_no_trigger ".github/workflows/build-macos.yml" + expect_no_trigger "doc/user_guide/en/wsjtx-main.adoc" + + echo "select-linux-packaging.sh self-test passed" + exit 0 +fi + +build_packages=true +reason="${EVENT_NAME:-unknown} event" + +if [ "${EVENT_NAME:-}" = "pull_request" ] && [ "${FULL_CI:-false}" != "true" ]; then + base="${PR_BASE_SHA:-}" + head="${CURRENT_SHA:-}" + build_packages=false + reason="ordinary pull request" + + 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 && + git cat-file -e "${head}^{commit}" 2>/dev/null; then + while IFS= read -r path; do + [ -z "$path" ] && continue + if path_triggers_packaging "$path"; then + build_packages=true + reason="$path" + break + fi + done < <(git diff --name-only "$base" "$head") + else + build_packages=true + reason="unreadable ${base}..${head}" + fi +fi + +echo "Build Linux packages: $build_packages" +echo "Packaging policy reason: $reason" +if [ -n "${GITHUB_OUTPUT:-}" ]; then + echo "build_packages=$build_packages" >> "$GITHUB_OUTPUT" +fi diff --git a/.github/scripts/should-refresh-linux-ci-images.py b/.github/scripts/should-refresh-linux-ci-images.py new file mode 100644 index 00000000..44026a96 --- /dev/null +++ b/.github/scripts/should-refresh-linux-ci-images.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python3 +"""Decide whether the promoted Linux CI image is old enough to refresh.""" + +from __future__ import annotations + +import argparse +import os +import sys +from datetime import datetime, timedelta, timezone +from pathlib import Path + + +sys.path.insert(0, str(Path(__file__).parent)) +from ghcr_retention import GitHubPackagesClient, Version # noqa: E402 + + +OWNER = "WSJTX" +PACKAGE = "wsjtx-internal/linux-noble" +# Stable is a promoted pointer; age-gate scheduled refreshes to avoid image churn. + + +def stable_version(versions: list[Version]) -> Version: + stable = [version for version in versions if "stable" in version.tags] + if len(stable) != 1: + raise RuntimeError(f"expected one stable Linux CI image, found {len(stable)}") + return stable[0] + + +def should_refresh( + versions: list[Version], *, now: datetime, max_age_days: int +) -> tuple[bool, int]: + version = stable_version(versions) + age = now.astimezone(timezone.utc) - version.created_at + age_days = max(0, age.days) + return age >= timedelta(days=max_age_days), age_days + + +def main() -> int: + parser = argparse.ArgumentParser() + parser.add_argument("--max-age-days", type=int, default=30) + args = parser.parse_args() + if args.max_age_days < 1: + parser.error("--max-age-days must be positive") + + token = os.environ.get("GITHUB_TOKEN") + if not token: + print("GITHUB_TOKEN is required", file=sys.stderr) + return 2 + + client = GitHubPackagesClient(token) + refresh, age_days = should_refresh( + client.list_versions(OWNER, PACKAGE), + now=datetime.now(timezone.utc), + max_age_days=args.max_age_days, + ) + decision = "refresh" if refresh else "keep" + print(f"Linux CI stable image age: {age_days} days; decision: {decision}") + return 0 if refresh else 1 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/.github/scripts/smoke-launch-windows.sh b/.github/scripts/smoke-launch-windows.sh new file mode 100755 index 00000000..e6dda339 --- /dev/null +++ b/.github/scripts/smoke-launch-windows.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +# Launch a Windows executable with the MinGW runtime directory removed from +# PATH and assert it does NOT fail with STATUS_DLL_NOT_FOUND (0xC0000135). +# +# This reproduces the failure class behind "map65.exe won't start": a missing +# runtime DLL (libgomp-1.dll, libportaudio-2.dll, libgfortran-5.dll, ...) makes +# the process exit at load time, before main(), with exit code 0xC0000135. A +# build that links and packages correctly survives a launch from a clean PATH; +# one that relies on the dev shell's /mingw64/bin does not. +# +# The launched command must exit on its own. A bounded timeout turns a hung +# process or modal startup error into a test failure. +# +# Usage: smoke-launch-windows.sh <exe> [args...] +set -u + +# 0xC0000135 as a bash exit status. Windows returns the 32-bit NTSTATUS; MSYS2 +# bash surfaces it as 3221225781 (unsigned) for processes that exit on their +# own. The 128+signal form does not apply here — this is a real process exit. +readonly STATUS_DLL_NOT_FOUND=3221225781 +readonly TIMEOUT_SECS=20 + +exe="${1:?usage: smoke-launch-windows.sh <exe> [args...]}" +shift || true + +if [ ! -f "$exe" ]; then + echo "::error::smoke-launch: executable not found: $exe" + exit 1 +fi + +# Strip the MinGW runtime dir from PATH so only DLLs the build/packaging step +# placed beside the exe (or in still-present system dirs) can resolve. +cleaned_path=$(echo "$PATH" | tr ':' '\n' | grep -ivE '(^|/)mingw64/bin/?$' | paste -sd: -) +echo "smoke-launch: $exe $* (PATH cleaned of /mingw64/bin)" + +# timeout returns 124 when it had to kill the process. +PATH="$cleaned_path" timeout "${TIMEOUT_SECS}s" "$exe" "$@" >launch.out 2>&1 +code=$? + +if [ "$code" -eq "$STATUS_DLL_NOT_FOUND" ]; then + echo "::error::smoke-launch: $exe exited 0xC0000135 (STATUS_DLL_NOT_FOUND) — a runtime DLL is missing from the clean-PATH launch context" + echo "----- output -----"; cat launch.out || true + exit 1 +fi + +if [ "$code" -eq 124 ]; then + echo "::error::smoke-launch: $exe did not exit within ${TIMEOUT_SECS}s" + echo "----- output -----"; cat launch.out || true + exit 1 +fi + +if [ "$code" -eq 0 ]; then + cat launch.out || true + echo "smoke-launch OK: $exe loaded and exited cleanly" + exit 0 +fi + +# Any other non-zero code is a real fault (a missing DLL is the thing we guard +# against; a usage/help non-zero exit would also surface here, so print it). +echo "::error::smoke-launch: $exe exited with code $code" +echo "----- output -----"; cat launch.out || true +exit 1 diff --git a/.github/scripts/test-linux-ccache-compiler-signature.sh b/.github/scripts/test-linux-ccache-compiler-signature.sh new file mode 100755 index 00000000..0ec48b24 --- /dev/null +++ b/.github/scripts/test-linux-ccache-compiler-signature.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash +set -euo pipefail + +fixture="$(mktemp -d)" +trap 'rm -rf "$fixture"' EXIT +mkdir -p "$fixture/bin" "$fixture/libexec" + +for component in cc1 cc1plus lto1 as; do + printf '%s\n' "$component fixture contents" > "$fixture/libexec/$component" +done +printf '%s\n' 'fixture specs' > "$fixture/specs" +printf '%s\n' 'x86_64-fixture-linux-gnu' > "$fixture/target" +printf '%s\n' 'fixture runtime library' > "$fixture/libexec/libcompiler-runtime.so" + +cat > "$fixture/bin/gcc-99" <<'EOF' +#!/usr/bin/env bash +set -euo pipefail +root="$(cd "$(dirname "$0")/.." && pwd)" +case "$1" in + -dumpfullversion) echo 99.1.0 ;; + -dumpmachine) cat "$root/target" ;; + -dumpspecs) cat "$root/specs" ;; + -print-prog-name=*) echo "$root/libexec/${1#*=}" ;; + *) exit 2 ;; +esac +EOF +cp "$fixture/bin/gcc-99" "$fixture/bin/g++-99" +cat > "$fixture/bin/ldd" <<'EOF' +#!/usr/bin/env bash +set -euo pipefail +root="$(cd "$(dirname "$0")/.." && pwd)" +printf 'libcompiler-runtime.so => %s/libexec/libcompiler-runtime.so (0x00000000)\n' "$root" +EOF +chmod +x "$fixture/bin/gcc-99" "$fixture/bin/g++-99" "$fixture/bin/ldd" +cp "$fixture/bin/gcc-99" "$fixture/bin/arm-linux-gnueabihf-gcc" +cp "$fixture/bin/gcc-99" "$fixture/bin/arm-linux-gnueabihf-g++" + +signature() { + PATH="$fixture/bin:$PATH" \ + .github/scripts/linux-ccache-compiler-signature.sh gcc-99 +} + +first="$(signature)" +IFS=$'\t' read -r version target driver_sha compatibility_id signature_sha <<< "$first" +test "$version" = 99.1.0 +test "$target" = x86_64-fixture-linux-gnu +test "$compatibility_id" = gcc99-v2 +[[ "$driver_sha" =~ ^[0-9a-f]{64}$ ]] +[[ "$signature_sha" =~ ^[0-9a-f]{64}$ ]] + +cross_signature="$( + PATH="$fixture/bin:$PATH" \ + .github/scripts/linux-ccache-compiler-signature.sh \ + "$fixture/bin/arm-linux-gnueabihf-gcc" +)" +IFS=$'\t' read -r cross_version cross_target _ cross_compatibility_id _ \ + <<< "$cross_signature" +test "$cross_version" = 99.1.0 +test "$cross_target" = x86_64-fixture-linux-gnu +test "$cross_compatibility_id" = gcc99-v2 + +touch "$fixture/bin/gcc-99" "$fixture/libexec/cc1" +test "$(signature)" = "$first" + +previous=$first +for input in \ + "$fixture/bin/gcc-99" \ + "$fixture/bin/g++-99" \ + "$fixture/libexec/cc1" \ + "$fixture/libexec/cc1plus" \ + "$fixture/libexec/lto1" \ + "$fixture/libexec/as" \ + "$fixture/libexec/libcompiler-runtime.so" \ + "$fixture/specs"; do + printf '%s\n' '# signature change' >> "$input" + current="$(signature)" + if [ "$current" = "$previous" ]; then + echo "Expected compiler signature to change after modifying $input" >&2 + exit 1 + fi + previous=$current +done + +printf '%s\n' 'aarch64-fixture-linux-gnu' > "$fixture/target" +test "$(signature)" != "$previous" + +echo "linux-ccache-compiler-signature.sh self-test passed" diff --git a/.github/scripts/test-verify-linux-ci-image.sh b/.github/scripts/test-verify-linux-ci-image.sh new file mode 100755 index 00000000..38348f5d --- /dev/null +++ b/.github/scripts/test-verify-linux-ci-image.sh @@ -0,0 +1,160 @@ +#!/usr/bin/env bash +set -euo pipefail + +fixture="$(mktemp -d)" +trap 'rm -rf "$fixture"' EXIT +mkdir -p "$fixture/prefix/pfunit/cmake" "$fixture/prefix/hamlib/lib" +touch "$fixture/prefix/pfunit/cmake/PFUNITConfig.cmake" +touch "$fixture/prefix/hamlib/lib/libhamlib.a" + +# shellcheck source=.github/scripts/linux-ci-image-config.sh +. .github/scripts/linux-ci-image-config.sh +# shellcheck source=.github/scripts/tsan-linux-deps-config.sh +. .github/scripts/tsan-linux-deps-config.sh +recipe="$(.github/scripts/linux-ci-image-fingerprint.sh normal-noble)" +tsan_recipe="$(.github/scripts/linux-ci-image-fingerprint.sh tsan-noble)" +manifest="$fixture/image.env" +compiler=gcc +compiler_path="$(readlink -f "$(command -v "$compiler")")" +compiler_version="$($compiler -dumpfullversion -dumpversion)" +compiler_sha256="$(sha256sum "$compiler_path" | awk '{print $1}')" +compiler_target="$($compiler -dumpmachine)" +if command -v dpkg-query >/dev/null 2>&1; then + package_sha256="$(dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort | sha256sum | awk '{print $1}')" + toolchain_identity="$recipe:$compiler_target:$compiler_sha256:$package_sha256" + toolchain_sha256="$(printf '%s' "$toolchain_identity" | sha256sum | awk '{print $1}')" + toolchain_id="gcc${compiler_version}-x86_64-${toolchain_sha256:0:20}" +else + package_sha256=0000000000000000000000000000000000000000000000000000000000000000 + toolchain_id=fixture +fi +compiler_major=${compiler_version%%.*} +ccache_compatibility_id="gcc${compiler_major}-v2" +compiler_signature_sha256=1111111111111111111111111111111111111111111111111111111111111111 + +write_manifest() { + local hamlib_commit=${1:-$LINUX_HAMLIB_COMMIT} + local recipe_sha=${2:-$recipe} + local include_ccache_identity=${3:-true} + { + echo "schema=1" + echo "flavor=normal" + echo "architecture=x86_64" + echo "generation=build-20260818-1-1" + echo "compiler=$compiler" + echo "compiler_version=$compiler_version" + echo "compiler_sha256=$compiler_sha256" + echo "compiler_target=$compiler_target" + echo "package_sha256=$package_sha256" + echo "toolchain_id=$toolchain_id" + if [ "$include_ccache_identity" = true ]; then + echo "ccache_compatibility_id=$ccache_compatibility_id" + echo "compiler_signature_sha256=$compiler_signature_sha256" + fi + echo "hamlib_ref=$LINUX_HAMLIB_REF" + echo "hamlib_commit=$hamlib_commit" + echo "pfunit_version=$LINUX_PFUNIT_VERSION" + echo "pfunit_commit=$LINUX_PFUNIT_COMMIT" + echo "recipe_sha256=$recipe_sha" + } > "$manifest" +} + +run_verify() { + local allow_stale_image=${1:-false} + WSJTX_CI_IMAGE_MANIFEST="$manifest" \ + WSJTX_CI_PREFIX_OVERRIDE="$fixture/prefix" \ + WSJTX_CI_IMAGE_SKIP_RUNTIME_CHECKS=true \ + WSJTX_CI_IMAGE_ALLOW_RECIPE_MISMATCH="$allow_stale_image" \ + .github/scripts/verify-linux-ci-image.sh normal x86_64 "$LINUX_HAMLIB_REF" +} + +write_manifest +run_verify >/dev/null + +output="$fixture/output" +GITHUB_OUTPUT="$output" run_verify >/dev/null +grep -qx 'recipe_match=true' "$output" +grep -qx "ccache_compatibility_id=$ccache_compatibility_id" "$output" +grep -qx "ccache_compiler_check=string:$compiler_signature_sha256" "$output" + +write_manifest "$LINUX_HAMLIB_COMMIT" "$recipe" false +if run_verify >/dev/null 2>&1; then + echo "Expected a current image without ccache identity fields to fail" >&2 + exit 1 +fi + +write_manifest +printf '%s\n' 'compiler_signature_sha256=invalid' >> "$manifest" +if run_verify >/dev/null 2>&1; then + echo "Expected an invalid compiler signature to fail" >&2 + exit 1 +fi + +write_manifest 0000000000000000000000000000000000000000 +if run_verify >/dev/null 2>&1; then + echo "Expected a mismatched Hamlib commit to fail" >&2 + exit 1 +fi + +write_manifest "$LINUX_HAMLIB_COMMIT" 0000000000000000000000000000000000000000000000000000000000000000 false +if run_verify >/dev/null 2>&1; then + echo "Expected a mismatched recipe fingerprint to fail" >&2 + exit 1 +fi +if ! run_verify true >/dev/null 2>&1; then + echo "Expected stale image allowance to accept a mismatched recipe fingerprint" >&2 + exit 1 +fi +output="$fixture/stale-output" +GITHUB_OUTPUT="$output" run_verify true >/dev/null 2>&1 +grep -qx 'recipe_match=false' "$output" +grep -qx "ccache_compatibility_id=$toolchain_id" "$output" +grep -qx 'ccache_compiler_check=mtime' "$output" + +tsan_config_dir="$fixture/tsan-config" +mkdir -p "$tsan_config_dir" "$fixture/prefix/tsan/boost/cmake" +cp .github/scripts/verify-linux-ci-image.sh \ + .github/scripts/linux-ccache-compiler-signature.sh \ + .github/scripts/linux-ci-image-config.sh \ + .github/scripts/tsan-linux-deps-config.sh \ + "$tsan_config_dir/" +cp .github/scripts/linux-ci-image-fingerprint.sh "$tsan_config_dir/" +cat > "$tsan_config_dir/verify-tsan-deps-linux.sh" <<'EOF' +#!/usr/bin/env bash +set -euo pipefail +EOF +chmod +x "$tsan_config_dir/verify-tsan-deps-linux.sh" +touch "$fixture/prefix/tsan/boost/cmake/BoostConfig.cmake" + +tsan_manifest="$fixture/tsan-image.env" +cat > "$tsan_manifest" <<EOF +schema=1 +flavor=tsan +architecture=x86_64 +generation=build-20260818-1-1 +compiler=gcc-13 +compiler_version=$TSAN_GCC_VERSION +compiler_sha256=0000000000000000000000000000000000000000000000000000000000000000 +compiler_target=fixture +package_sha256=0000000000000000000000000000000000000000000000000000000000000000 +toolchain_id=fixture +ccache_compatibility_id=gcc${TSAN_GCC_VERSION%%.*}-v2 +compiler_signature_sha256=1111111111111111111111111111111111111111111111111111111111111111 +hamlib_ref=$TSAN_HAMLIB_REF +hamlib_commit=$TSAN_HAMLIB_COMMIT +hamlib_patch_commit=$TSAN_HAMLIB_PATCH_COMMIT +qt_version=$TSAN_QT_VERSION +boost_version=$TSAN_BOOST_VERSION +recipe_sha256=$tsan_recipe +EOF +if ! WSJTX_CI_IMAGE_MANIFEST="$tsan_manifest" \ + WSJTX_CI_PREFIX_OVERRIDE="$fixture/prefix" \ + WSJTX_CI_IMAGE_SKIP_RUNTIME_CHECKS=true \ + IMAGE_RECIPE_SHA256="$tsan_recipe" \ + "$tsan_config_dir/verify-linux-ci-image.sh" \ + tsan x86_64 "$TSAN_HAMLIB_REF" >/dev/null; then + echo "Expected TSan image verification to load its dependency configuration" >&2 + exit 1 +fi + +echo "verify-linux-ci-image.sh self-test passed" diff --git a/.github/scripts/tests/test_armhf_ci_manifest.py b/.github/scripts/tests/test_armhf_ci_manifest.py new file mode 100644 index 00000000..c438d62d --- /dev/null +++ b/.github/scripts/tests/test_armhf_ci_manifest.py @@ -0,0 +1,90 @@ +import hashlib +import os +import pathlib +import subprocess +import tempfile +import unittest + + +ROOT = pathlib.Path(__file__).resolve().parents[3] +WRITER = ROOT / ".github/scripts/write-armhf-ci-manifest.sh" + + +class ArmhfCiManifestTests(unittest.TestCase): + def test_runtime_manifest_preserves_requested_image_identity(self): + with tempfile.TemporaryDirectory() as temporary: + fixture = pathlib.Path(temporary) + config = fixture / "config" + output = fixture / "output" + runtime = fixture / "runtime" + fixture_bin = fixture / "bin" + config.mkdir() + output.mkdir() + runtime.mkdir() + fixture_bin.mkdir() + + dpkg_query = fixture_bin / "dpkg-query" + dpkg_query.write_text( + "#!/bin/sh\nprintf '%s\\n' fixture-package=1.0\n", + encoding="utf-8", + ) + dpkg_query.chmod(0o755) + + library = runtime / "libgcc_s.so.1" + library.write_bytes(b"fixture GCC runtime\n") + library_sha = hashlib.sha256(library.read_bytes()).hexdigest() + runtime_records = f"libgcc_s.so.1={library_sha}\n".encode() + runtime_sha = hashlib.sha256(runtime_records).hexdigest() + + (config / "armhf-ci-image-config.sh").write_text( + "ARMHF_CI_IMAGE_SCHEMA=1\n" + f"ARMHF_RUNTIME_PREFIX={runtime}\n" + "ARMHF_GCC_RUNTIME_LIBRARIES=(libgcc_s.so.1)\n" + "ARMHF_GLIBC_VERSION=2.36\n", + encoding="utf-8", + ) + (config / "cross-builder.env").write_text( + "role=cross-builder\n" + "generation=build-20260901-10-1\n" + f"recipe_sha256={'1' * 64}\n" + "toolchain_id=gcc13.4.0-armhf-fixture\n" + f"runtime_sha256={runtime_sha}\n" + "hamlib_ref=4.7.2\n" + f"hamlib_commit={'2' * 40}\n", + encoding="utf-8", + ) + + environment = os.environ.copy() + environment.update( + PATH=f"{fixture_bin}:{environment['PATH']}", + WSJTX_ARMHF_CONFIG_DIR=str(config), + WSJTX_CI_MANIFEST_DIR=str(output), + ) + subprocess.run( + [ + str(WRITER), + "runtime", + "armhf", + "build-20260901-20-1", + "3" * 64, + ], + cwd=ROOT, + env=environment, + check=True, + ) + + fields = dict( + line.split("=", 1) + for line in (output / "image.env").read_text().splitlines() + ) + self.assertEqual(fields["role"], "runtime") + self.assertEqual(fields["architecture"], "armhf") + self.assertEqual(fields["generation"], "build-20260901-20-1") + self.assertEqual(fields["recipe_sha256"], "3" * 64) + self.assertEqual(fields["cross_generation"], "build-20260901-10-1") + self.assertEqual(fields["cross_recipe_sha256"], "1" * 64) + self.assertEqual(fields["runtime_sha256"], runtime_sha) + + +if __name__ == "__main__": + unittest.main() diff --git a/.github/scripts/tests/test_armhf_cross_configuration.py b/.github/scripts/tests/test_armhf_cross_configuration.py new file mode 100644 index 00000000..0893e99a --- /dev/null +++ b/.github/scripts/tests/test_armhf_cross_configuration.py @@ -0,0 +1,176 @@ +import pathlib +import unittest + + +ROOT = pathlib.Path(__file__).resolve().parents[3] + + +class ArmhfCrossConfigurationTests(unittest.TestCase): + def read(self, relative_path): + return (ROOT / relative_path).read_text(encoding="utf-8") + + def test_cross_toolchain_pins_armv7_hard_float_and_bookworm_abi(self): + config = self.read(".github/images/linux-ci/armhf-cross-toolchain.config") + for setting in ( + "CT_ARCH_ARM=y", + "CT_ARCH_ARM_MODE_THUMB=y", + 'CT_ARCH_ARCH="armv7-a+fp"', + "CT_ARCH_FLOAT_HW=y", + "CT_LINUX_V_6_1=y", + "CT_BINUTILS_V_2_40=y", + "CT_GLIBC_V_2_36=y", + 'CT_GLIBC_MIN_KERNEL_VERSION="3.2.0"', + "CT_GCC_V_13=y", + "CT_CC_GCC_LIBGOMP=y", + "CT_CC_LANG_CXX=y", + "CT_CC_LANG_FORTRAN=y", + "CT_PARALLEL_JOBS=1", + 'CT_TARGET_CFLAGS="-g0"', + ): + self.assertIn(setting, config) + self.assertNotIn("CT_CC_GCC_LIBQUADMATH=y", config) + + image_config = self.read(".github/scripts/armhf-ci-image-config.sh") + self.assertIn("ARMHF_GCC_VERSION=13.4.0", image_config) + self.assertIn("ARMHF_GLIBC_VERSION=2.36", image_config) + self.assertIn("ARMHF_TARGET_TRIPLET=arm-linux-gnueabihf", image_config) + + verifier = self.read(".github/scripts/verify-armhf-ci-image.sh") + audit = self.read(".github/scripts/audit-armhf-cross-build.sh") + self.assertIn("reject_quadmath_dependency", verifier) + self.assertIn("unexpectedly depends on libquadmath", audit) + self.assertIn("reject_private_glibc_dependency", verifier) + self.assertIn("private glibc symbol", audit) + + def test_armhf_cache_identity_parsing_fails_closed(self): + workflow = self.read(".github/workflows/build-linux.yml") + self.assertIn( + '''ccache_compatibility_id=$(awk -F= '$1 == "cross_ccache_compatibility_id" { print $2 }' "$output_file")''', + workflow, + ) + self.assertIn( + 'if [ -z "$ccache_compatibility_id" ] || ' + '[ -z "$ccache_compiler_check" ]; then', + workflow, + ) + self.assertNotIn('\\"cross_ccache_compatibility_id\\"', workflow) + + def test_armhf_qemu_registration_uses_one_immutable_release(self): + expected = ( + "image: tonistiigi/binfmt:qemu-v10.2.3-68@sha256:" + "400a4873b838d1b89194d982c45e5fb3cda4593fbfd7e08a02e76b03b21166f0" + ) + for path in ( + ".github/workflows/build-linux.yml", + ".github/workflows/publish-linux-ci-images.yml", + ): + self.assertIn(expected, self.read(path)) + + def test_cmake_separates_host_programs_from_target_dependencies(self): + toolchain = self.read(".github/cmake/armhf-toolchain.cmake") + self.assertIn("set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)", toolchain) + self.assertIn("set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)", toolchain) + self.assertIn("set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)", toolchain) + self.assertIn("set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)", toolchain) + self.assertIn("set(_wsjt_armhf_triplet arm-linux-gnueabihf)", toolchain) + self.assertIn("${_wsjt_armhf_triplet}-gfortran", toolchain) + self.assertIn("set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE armhf", toolchain) + self.assertIn("set(CPACK_RPM_PACKAGE_ARCHITECTURE armv7l", toolchain) + + dependencies = self.read("CMake/Dependencies.cmake") + self.assertIn("WSJT_QT_HOST_PATH", dependencies) + self.assertIn("IMPORTED_LOCATION", dependencies) + + def test_builder_and_runtime_keep_distinct_native_architectures(self): + builder = self.read(".github/images/linux-ci/Dockerfile.armhf-cross") + runtime = self.read(".github/images/linux-ci/Dockerfile.armhf-runtime") + self.assertTrue(builder.startswith("FROM debian:bookworm\n")) + self.assertIn("--architectures=armhf", builder) + self.assertIn("qemu-user-static", builder) + self.assertIn("normalize-armhf-sysroot-symlinks.sh", builder) + self.assertIn("tail -n 300 build.log", builder) + self.assertIn("ARG CROSS_BUILDER_PLATFORM=linux/amd64", runtime) + self.assertIn( + "FROM --platform=${CROSS_BUILDER_PLATFORM} ${CROSS_BUILDER_IMAGE}", + runtime, + ) + self.assertIn("FROM arm32v7/debian:bookworm", runtime) + self.assertIn("install-armhf-runtime-packages", runtime) + self.assertIn( + "COPY --from=cross_builder /usr/bin/qemu-arm-static", runtime + ) + + cross_build = self.read(".github/scripts/build-linux-armhf-cross.sh") + runtime_package = self.read(".github/scripts/package-linux-armhf.sh") + self.assertNotIn("qemu", cross_build.lower()) + self.assertIn("cmake --install wsjtx-build", cross_build) + self.assertIn("cpack -G DEB", runtime_package) + self.assertIn("cpack -G RPM", runtime_package) + self.assertIn("CPACK_INSTALL_CMAKE_PROJECTS=", runtime_package) + self.assertIn("CPACK_INSTALLED_DIRECTORIES=/work/AppDir;/", runtime_package) + self.assertIn('"$ARMHF_QEMU_EXECUTABLE"', runtime_package) + self.assertIn( + 'LINUX_APPIMAGE_RUNNER="$ARMHF_QEMU_EXECUTABLE"', runtime_package + ) + self.assertIn("armhf-static-ldd.sh", runtime_package) + self.assertIn('PATH="/work/wsjtx-build/appimage-tools:$PATH"', runtime_package) + + def test_hybrid_is_the_only_armhf_build_implementation(self): + workflow = self.read(".github/workflows/build-linux.yml") + native_action = self.read( + ".github/actions/build-linux-payload/action.yml" + ) + self.assertFalse( + (ROOT / ".github/scripts/build-linux-payload.sh").exists() + ) + self.assertNotIn("build-linux-payload.sh", workflow) + self.assertEqual(workflow.count("build-linux-armhf-cross.sh"), 1) + self.assertIn("docker run --rm --platform linux/amd64", workflow) + self.assertNotIn("inputs.arch != 'armhf'", native_action) + self.assertNotIn("linuxdeploy-armhf", native_action) + + def test_armhf_joins_only_the_opt_in_full_ci_matrix(self): + workflow = self.read(".github/workflows/ci.yml") + prepare = workflow.split(" prepare:\n", 1)[1].split("\n macos:\n", 1)[0] + armhf_job = workflow.split(" linux-armhf:\n", 1)[1].split( + "\n windows:\n", 1 + )[0] + + self.assertIn("RESOLVE_ARMHF=true", prepare) + self.assertIn("inputs.armhf_image_tag", prepare) + self.assertIn( + "contains(github.event.pull_request.labels.*.name, 'full-ci')", + armhf_job, + ) + self.assertIn("github.event_name == 'workflow_dispatch'", armhf_job) + self.assertIn('arch: \"armhf\"', armhf_job) + self.assertIn( + "image_tag: ${{ needs.prepare.outputs.armhf_image_tag }}", + armhf_job, + ) + + def test_slow_decoder_timeouts_are_at_most_four_minutes(self): + jtty = self.read("tests/unit/jtty/CMakeLists.txt") + for test_name, timeout in ( + ("test_jtty_adjacent_decode", 180), + ("test_jtty_structured_decode", 240), + ("test_jtty_overlap_decode", 180), + ("test_jtty_overlap_decode_480", 240), + ("test_jtty_windowed_decode", 180), + ("test_jtty_gap_merge", 180), + ("test_jtty_surface_ranges", 180), + ): + properties = jtty.split( + f"set_tests_properties ({test_name}", 1 + )[1].split(")", 1)[0] + self.assertIn(f"TIMEOUT {timeout}", properties) + + q65 = self.read("tests/unit/q65/CMakeLists.txt") + properties = q65.split( + "set_tests_properties (test_q65_decode_pipeline", 1 + )[1].split(")", 1)[0] + self.assertIn("TIMEOUT 180", properties) + + +if __name__ == "__main__": + unittest.main() diff --git a/.github/scripts/tests/test_armhf_static_ldd.py b/.github/scripts/tests/test_armhf_static_ldd.py new file mode 100644 index 00000000..a1db1618 --- /dev/null +++ b/.github/scripts/tests/test_armhf_static_ldd.py @@ -0,0 +1,123 @@ +import os +import pathlib +import subprocess +import tempfile +import unittest + + +ROOT = pathlib.Path(__file__).resolve().parents[3] +VALIDATOR = ROOT / ".github/scripts/armhf-static-ldd.sh" + + +class ArmhfStaticLddTests(unittest.TestCase): + def run_validator(self, needed, libraries, runpath=None, transitive=None): + with tempfile.TemporaryDirectory() as temporary: + fixture = pathlib.Path(temporary) + fixture_bin = fixture / "bin" + fixture_lib = fixture / "lib" + fixture_bin.mkdir() + fixture_lib.mkdir() + target = fixture / "program" + target.write_text("target\n", encoding="utf-8") + + transitive = transitive or {} + dynamic_output = "".join( + f"printf '%s\\n' ' 0x00000001 (NEEDED) Shared library: [{library}]'\n" + for library in needed + ) + if runpath is not None: + dynamic_output += ( + "printf '%s\\n' ' 0x0000001d (RUNPATH) " + f"Library runpath: [{runpath}]'\n" + ) + transitive_cases = "".join( + " *" + parent + "*)\n" + + "".join( + f" printf '%s\\n' ' 0x00000001 (NEEDED) Shared library: [{library}]'\n" + for library in dependencies + ) + + " ;;\n" + for parent, dependencies in transitive.items() + ) + (fixture_bin / "readelf").write_text( + "#!/bin/sh\n" + "case \"$*\" in\n" + + transitive_cases + + " *)\n" + + "".join(f" {line}\n" for line in dynamic_output.splitlines()) + + " ;;\n" + "esac\n", + encoding="utf-8", + ) + (fixture_bin / "file").write_text( + "#!/bin/sh\n" + "case \"$*\" in\n" + " *libhost.so*) echo \"$*: ELF 64-bit LSB shared object, x86-64\" ;;\n" + " *) echo \"$*: ELF 32-bit LSB shared object, ARM, EABI5\" ;;\n" + "esac\n", + encoding="utf-8", + ) + for tool in (fixture_bin / "readelf", fixture_bin / "file"): + tool.chmod(0o755) + for library in libraries: + library_path = fixture_lib / library + library_path.parent.mkdir(parents=True, exist_ok=True) + library_path.write_text("fixture\n", encoding="utf-8") + + environment = os.environ.copy() + environment.update( + PATH=f"{fixture_bin}:{environment['PATH']}", + WSJT_ARMHF_RUNTIME_PREFIX=str(fixture / "empty-runtime"), + ARMHF_STATIC_LDD_LIBRARY_PATH=str(fixture_lib), + ) + return subprocess.run( + ["bash", str(VALIDATOR), str(target)], + cwd=ROOT, + env=environment, + text=True, + capture_output=True, + check=False, + ) + + def test_resolves_armhf_dependency_without_executing_target(self): + result = self.run_validator(["libfixture.so.1"], ["libfixture.so.1"]) + self.assertEqual(result.returncode, 0, result.stderr) + self.assertIn("libfixture.so.1 => ", result.stdout) + + def test_rejects_missing_dependency(self): + result = self.run_validator(["libmissing.so.1"], []) + self.assertNotEqual(result.returncode, 0) + self.assertIn("libmissing.so.1 => not found", result.stdout) + + def test_rejects_quadmath_dependency(self): + result = self.run_validator(["libquadmath.so.0"], ["libquadmath.so.0"]) + self.assertNotEqual(result.returncode, 0) + self.assertIn("unavailable ARMHF runtime", result.stderr) + + def test_rejects_host_library(self): + result = self.run_validator(["libhost.so.1"], ["libhost.so.1"]) + self.assertNotEqual(result.returncode, 0) + self.assertIn("non-ARMHF ELF", result.stderr) + + def test_resolves_origin_relative_runpath(self): + result = self.run_validator( + ["libpulsecommon-fixture.so"], + ["pulseaudio/libpulsecommon-fixture.so"], + runpath="$ORIGIN/lib/pulseaudio", + ) + self.assertEqual(result.returncode, 0, result.stderr) + self.assertIn("pulseaudio/libpulsecommon-fixture.so", result.stdout) + + def test_resolves_transitive_dependency_closure(self): + result = self.run_validator( + ["libparent.so.1"], + ["libparent.so.1", "libchild.so.1"], + transitive={"libparent.so.1": ["libchild.so.1"]}, + ) + self.assertEqual(result.returncode, 0, result.stderr) + self.assertIn("libparent.so.1 => ", result.stdout) + self.assertIn("libchild.so.1 => ", result.stdout) + + +if __name__ == "__main__": + unittest.main() diff --git a/.github/scripts/tests/test_armhf_sysroot_symlinks.py b/.github/scripts/tests/test_armhf_sysroot_symlinks.py new file mode 100644 index 00000000..991971f6 --- /dev/null +++ b/.github/scripts/tests/test_armhf_sysroot_symlinks.py @@ -0,0 +1,42 @@ +import os +import pathlib +import subprocess +import tempfile +import unittest + + +ROOT = pathlib.Path(__file__).resolve().parents[3] +NORMALIZER = ROOT / ".github/scripts/normalize-armhf-sysroot-symlinks.sh" + + +class ArmhfSysrootSymlinkTests(unittest.TestCase): + def test_absolute_links_are_rebased_inside_sysroot(self): + with tempfile.TemporaryDirectory() as temporary: + sysroot = pathlib.Path(temporary) + target = sysroot / "lib/arm-linux-gnueabihf/libm.so.6" + target.parent.mkdir(parents=True) + target.write_text("fixture\n", encoding="utf-8") + link = sysroot / "usr/lib/arm-linux-gnueabihf/libm.so" + link.parent.mkdir(parents=True) + link.symlink_to("/lib/arm-linux-gnueabihf/libm.so.6") + + subprocess.run(["bash", str(NORMALIZER), str(sysroot)], check=True) + + self.assertFalse(os.readlink(link).startswith("/")) + self.assertEqual(link.resolve(), target) + + def test_relative_links_remain_unchanged(self): + with tempfile.TemporaryDirectory() as temporary: + sysroot = pathlib.Path(temporary) + directory = sysroot / "usr/lib" + directory.mkdir(parents=True) + link = directory / "libfixture.so" + link.symlink_to("libfixture.so.1") + + subprocess.run(["bash", str(NORMALIZER), str(sysroot)], check=True) + + self.assertEqual(os.readlink(link), "libfixture.so.1") + + +if __name__ == "__main__": + unittest.main() diff --git a/.github/scripts/tests/test_check_candidate_tag.py b/.github/scripts/tests/test_check_candidate_tag.py new file mode 100644 index 00000000..cf44ccf4 --- /dev/null +++ b/.github/scripts/tests/test_check_candidate_tag.py @@ -0,0 +1,81 @@ +import subprocess +import tempfile +import unittest +from pathlib import Path + + +SCRIPT = Path(__file__).resolve().parents[1] / "check-candidate-tag.sh" +TAG = "build/v3.2.0-rc1" + + +class CheckCandidateTagTest(unittest.TestCase): + def setUp(self): + self.directory = tempfile.TemporaryDirectory() + self.addCleanup(self.directory.cleanup) + self.repo = Path(self.directory.name) + self.git("init", "-q") + self.git( + "-c", "user.name=Test", "-c", "user.email=test@example.com", + "commit", "--allow-empty", "-qm", "first", + ) + self.first = self.git("rev-parse", "HEAD").stdout.strip() + self.git( + "-c", "user.name=Test", "-c", "user.email=test@example.com", + "commit", "--allow-empty", "-qm", "second", + ) + self.second = self.git("rev-parse", "HEAD").stdout.strip() + + def git(self, *args, input=None): + return subprocess.run( + ["git", *args], cwd=self.repo, input=input, text=True, + capture_output=True, check=True, + ) + + def check_tag(self, expected_sha=None, cwd=None): + return subprocess.run( + ["bash", SCRIPT, TAG, expected_sha or self.second], + cwd=cwd or self.repo, text=True, capture_output=True, + ) + + def test_missing_tag_allows_creation(self): + result = self.check_tag() + self.assertEqual(result.returncode, 0, result.stderr) + self.assertEqual(result.stdout, "exists=false\n") + + def test_matching_lightweight_tag_is_idempotent(self): + self.git("tag", TAG, self.second) + result = self.check_tag() + self.assertEqual(result.returncode, 0, result.stderr) + self.assertEqual(result.stdout, "exists=true\n") + + def test_matching_annotated_tag_is_idempotent(self): + self.git( + "-c", "user.name=Test", "-c", "user.email=test@example.com", + "tag", "-am", "candidate", TAG, self.second, + ) + result = self.check_tag() + self.assertEqual(result.returncode, 0, result.stderr) + self.assertEqual(result.stdout, "exists=true\n") + + def test_different_commit_is_rejected(self): + self.git("tag", TAG, self.first) + result = self.check_tag() + self.assertNotEqual(result.returncode, 0) + self.assertIn("release tags are never moved", result.stderr) + + def test_noncommit_tag_is_rejected(self): + blob = self.git("hash-object", "-w", "--stdin", input="not a commit").stdout.strip() + self.git("update-ref", f"refs/tags/{TAG}", blob) + result = self.check_tag() + self.assertNotEqual(result.returncode, 0) + self.assertIn("does not identify a commit", result.stderr) + + def test_git_failure_is_not_treated_as_missing_tag(self): + with tempfile.TemporaryDirectory() as directory: + result = self.check_tag(cwd=directory) + self.assertNotEqual(result.returncode, 0) + self.assertIn("Could not inspect", result.stderr) + + +if __name__ == "__main__": + unittest.main() diff --git a/.github/scripts/tests/test_ghcr_retention.py b/.github/scripts/tests/test_ghcr_retention.py new file mode 100755 index 00000000..9bffad2d --- /dev/null +++ b/.github/scripts/tests/test_ghcr_retention.py @@ -0,0 +1,143 @@ +#!/usr/bin/env python3 + +import importlib.util +import sys +import unittest +from datetime import datetime, timedelta, timezone +from pathlib import Path + + +SCRIPT = Path(__file__).parents[1] / "ghcr_retention.py" +SPEC = importlib.util.spec_from_file_location("ghcr_retention", SCRIPT) +MODULE = importlib.util.module_from_spec(SPEC) +sys.modules[SPEC.name] = MODULE +SPEC.loader.exec_module(MODULE) + + +def version(version_id, age_days, tags, now): + return MODULE.Version( + id=version_id, + digest=f"sha256:{version_id:064x}", + created_at=now - timedelta(days=age_days), + tags=tuple(tags), + ) + + +class RetentionPlanTests(unittest.TestCase): + def setUp(self): + self.now = datetime(2026, 8, 18, tzinfo=timezone.utc) + + def plan(self, versions, keep=3): + return { + item.version.id: item + for item in MODULE.plan_retention(versions, self.now, 60, keep) + } + + def test_deletes_only_expired_recognized_versions_outside_keep_set(self): + versions = [ + version(1, 90, ("build-20260101-1-1",), self.now), + version(2, 10, ("build-20260808-2-1",), self.now), + version(3, 20, ("build-20260729-3-1",), self.now), + version(4, 30, ("build-20260719-4-1",), self.now), + ] + plan = self.plan(versions) + self.assertTrue(plan[1].delete) + self.assertFalse(plan[2].delete) + self.assertFalse(plan[3].delete) + self.assertFalse(plan[4].delete) + + def test_stable_unknown_and_untagged_versions_are_protected(self): + versions = [ + version(1, 100, ("stable", "build-20260101-1-1"), self.now), + version(2, 100, ("debug",), self.now), + version(3, 100, (), self.now), + ] + plan = self.plan(versions, keep=1) + self.assertEqual(plan[1].reason, "stable") + self.assertEqual(plan[2].reason, "unknown-or-untagged") + self.assertEqual(plan[3].reason, "unknown-or-untagged") + + def test_exact_sixty_day_boundary_is_kept(self): + plan = self.plan([version(1, 60, ("candidate-1-1",), self.now)], keep=1) + self.assertFalse(plan[1].delete) + + def test_equal_timestamps_use_id_as_tiebreaker(self): + versions = [ + version(1, 90, ("candidate-1-1",), self.now), + version(2, 90, ("candidate-2-1",), self.now), + ] + plan = self.plan(versions, keep=1) + self.assertTrue(plan[1].delete) + self.assertFalse(plan[2].delete) + + def test_nested_package_name_is_encoded(self): + path = MODULE.GitHubPackagesClient.package_path( + "WSJTX", "wsjtx-internal/linux-noble" + ) + self.assertEqual( + path, + "/orgs/WSJTX/packages/container/wsjtx-internal%2Flinux-noble", + ) + + def test_malformed_version_fails_closed(self): + with self.assertRaises(ValueError): + MODULE.parse_version({"id": 1, "name": "sha256:x", "metadata": {}}) + + +class FakeClient: + def __init__(self, versions, refreshed=None): + self.versions = versions + self.refreshed = refreshed or {} + self.deleted = [] + + def list_versions(self, owner, package): + return list(self.versions) + + def get_version(self, owner, package, version_id): + return self.refreshed.get( + version_id, + next(item for item in self.versions if item.id == version_id), + ) + + def delete_version(self, owner, package, version_id): + self.deleted.append(version_id) + + +class RetentionApplicationTests(unittest.TestCase): + def setUp(self): + self.now = datetime(2026, 8, 18, tzinfo=timezone.utc) + self.versions = [ + version(1, 100, ("candidate-1-1",), self.now), + version(2, 30, ("candidate-2-1",), self.now), + ] + + def run_process(self, client, apply): + return MODULE.process_package( + client, + "WSJTX", + "wsjtx-internal/linux-noble", + self.now, + 60, + 1, + apply, + ) + + def test_dry_run_never_deletes(self): + client = FakeClient(self.versions) + self.assertEqual(self.run_process(client, False), 0) + self.assertEqual(client.deleted, []) + + def test_apply_deletes_planned_version(self): + client = FakeClient(self.versions) + self.assertEqual(self.run_process(client, True), 1) + self.assertEqual(client.deleted, [1]) + + def test_refetch_protects_new_stable_tag(self): + stable = version(1, 100, ("stable", "candidate-1-1"), self.now) + client = FakeClient(self.versions, {1: stable}) + self.assertEqual(self.run_process(client, True), 0) + self.assertEqual(client.deleted, []) + + +if __name__ == "__main__": + unittest.main() diff --git a/.github/scripts/tests/test_linux_artifact_validation.py b/.github/scripts/tests/test_linux_artifact_validation.py new file mode 100644 index 00000000..655d0d24 --- /dev/null +++ b/.github/scripts/tests/test_linux_artifact_validation.py @@ -0,0 +1,230 @@ +import os +import subprocess +import tempfile +import unittest +from pathlib import Path + + +REPO_ROOT = Path(__file__).resolve().parents[3] +HELPER = REPO_ROOT / ".github/scripts/linux-artifact-validation.sh" + + +class LinuxArtifactValidationTests(unittest.TestCase): + def run_helper(self, command, **environment): + env = os.environ.copy() + env["VALIDATION_HELPER"] = str(HELPER) + env.update({name: str(value) for name, value in environment.items()}) + return subprocess.run( + ["bash", "-c", f'source "$VALIDATION_HELPER"; {command}'], + check=False, + capture_output=True, + env=env, + text=True, + ) + + def make_application_tree(self, kind="appimage"): + temporary = tempfile.TemporaryDirectory() + root = Path(temporary.name) + executables = ["wsjtx", "jt9", "qmap", "map65", "ft8code"] + if kind == "appimage": + executables.append("wsprd") + for executable in executables: + path = root / "usr/bin" / executable + path.parent.mkdir(parents=True, exist_ok=True) + path.touch(mode=0o755) + for relative in ( + "usr/share/wsjtx/ALLCALL7.TXT", + "usr/share/wsjtx/CALL3.TXT", + "usr/share/wsjtx/sounds/Message.wav", + "usr/share/wsjtx/sounds/Testing123.wav", + ): + path = root / relative + path.parent.mkdir(parents=True, exist_ok=True) + path.touch() + + if kind == "appdir": + for relative in ( + "usr/share/applications/wsjtx.desktop", + "usr/share/pixmaps/wsjtx_icon.png", + ): + path = root / relative + path.parent.mkdir(parents=True, exist_ok=True) + path.touch() + else: + qt_conf = root / "usr/bin/qt.conf" + qt_conf.write_text("[Paths]\nPlugins = plugins\n", encoding="utf-8") + for relative in ( + "usr/plugins/platforms/libqxcb.so", + "usr/plugins/sqldrivers/libqsqlite.so", + "usr/plugins/audio/libqtaudio_alsa.so", + "usr/lib/libQt5Core.so.5", + "usr/lib/libQt5Widgets.so.5", + "usr/lib/libQt5Multimedia.so.5", + ): + path = root / relative + path.parent.mkdir(parents=True, exist_ok=True) + path.touch() + return temporary, root + + def test_package_manifest_accepts_expected_payload(self): + manifest = "\n".join( + ( + "/usr/bin/wsjtx", + "/usr/bin/jt9", + "/usr/bin/qmap", + "/usr/bin/map65", + "/usr/share/wsjtx/ALLCALL7.TXT", + "/usr/share/wsjtx/CALL3.TXT", + "/usr/share/wsjtx/sounds/Message.wav", + "/usr/share/wsjtx/sounds/Testing123.wav", + ) + ) + result = self.run_helper( + 'validate_linux_package_manifest "$MANIFEST" fixture', MANIFEST=manifest + ) + self.assertEqual(result.returncode, 0, result.stderr) + + def test_package_manifest_rejects_missing_executable_data_or_sound(self): + required = [ + "/usr/bin/wsjtx", + "/usr/bin/jt9", + "/usr/bin/qmap", + "/usr/bin/map65", + "/usr/share/wsjtx/ALLCALL7.TXT", + "/usr/share/wsjtx/CALL3.TXT", + "/usr/share/wsjtx/sounds/Message.wav", + "/usr/share/wsjtx/sounds/Testing123.wav", + ] + for missing in ( + "/usr/bin/map65", + "/usr/share/wsjtx/ALLCALL7.TXT", + "/usr/share/wsjtx/sounds/Message.wav", + ): + with self.subTest(missing=missing): + manifest = "\n".join(path for path in required if path != missing) + result = self.run_helper( + 'validate_linux_package_manifest "$MANIFEST" fixture', + MANIFEST=manifest, + ) + self.assertNotEqual(result.returncode, 0) + self.assertIn(missing, result.stderr) + + def test_package_manifest_rejects_executable_adjacent_sounds(self): + manifest = "\n".join( + ( + "/usr/bin/wsjtx", + "/usr/bin/jt9", + "/usr/bin/qmap", + "/usr/bin/map65", + "/usr/bin/sounds/Message.wav", + "/usr/share/wsjtx/ALLCALL7.TXT", + "/usr/share/wsjtx/CALL3.TXT", + "/usr/share/wsjtx/sounds/Message.wav", + "/usr/share/wsjtx/sounds/Testing123.wav", + ) + ) + result = self.run_helper( + 'validate_linux_package_manifest "$MANIFEST" fixture', MANIFEST=manifest + ) + self.assertNotEqual(result.returncode, 0) + self.assertIn("/usr/bin/sounds", result.stderr) + + def test_application_layout_rejects_missing_executable_data_or_sound(self): + for relative in ( + "usr/bin/map65", + "usr/share/wsjtx/ALLCALL7.TXT", + "usr/share/wsjtx/sounds/Message.wav", + ): + with self.subTest(relative=relative): + temporary, root = self.make_application_tree("appdir") + self.addCleanup(temporary.cleanup) + (root / relative).unlink() + result = self.run_helper( + 'validate_linux_application_layout "$TREE" appdir', TREE=root + ) + self.assertNotEqual(result.returncode, 0) + self.assertIn(str(root / relative), result.stderr) + + def test_application_layout_rejects_executable_adjacent_sounds(self): + temporary, root = self.make_application_tree("appdir") + self.addCleanup(temporary.cleanup) + (root / "usr/bin/sounds").mkdir() + result = self.run_helper( + 'validate_linux_application_layout "$TREE" appdir', TREE=root + ) + self.assertNotEqual(result.returncode, 0) + self.assertIn("usr/bin/sounds", result.stderr) + + def test_appimage_layout_requires_qt_runtime_payload(self): + for relative in ( + "usr/bin/qt.conf", + "usr/plugins/platforms/libqxcb.so", + "usr/plugins/sqldrivers/libqsqlite.so", + "usr/plugins/audio/libqtaudio_alsa.so", + "usr/lib/libQt5Core.so.5", + ): + with self.subTest(relative=relative): + temporary, root = self.make_application_tree() + self.addCleanup(temporary.cleanup) + (root / relative).unlink() + result = self.run_helper( + 'validate_linux_application_layout "$TREE" appimage', TREE=root + ) + self.assertNotEqual(result.returncode, 0) + + def test_armhf_elf_metadata_accepts_eabi5_hard_float_loader(self): + result = self.run_helper( + 'validate_elf_metadata armhf fixture "$FILE_OUT" "$HEADER_OUT" "$PROGRAM_OUT"', + FILE_OUT=( + "fixture: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 " + "(SYSV), dynamically linked" + ), + HEADER_OUT=( + "Class: ELF32\nMachine: ARM\n" + "Flags: 0x5000400, Version5 EABI, hard-float ABI" + ), + PROGRAM_OUT=( + "INTERP 0x000174 [Requesting program interpreter: " + "/lib/ld-linux-armhf.so.3]" + ), + ) + self.assertEqual(result.returncode, 0, result.stderr) + + def test_armhf_elf_metadata_rejects_wrong_abi_properties(self): + good = { + "FILE_OUT": ( + "fixture: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 " + "(SYSV), dynamically linked" + ), + "HEADER_OUT": ( + "Class: ELF32\nMachine: ARM\n" + "Flags: 0x5000400, Version5 EABI, hard-float ABI" + ), + "PROGRAM_OUT": ( + "INTERP 0x000174 [Requesting program interpreter: " + "/lib/ld-linux-armhf.so.3]" + ), + } + mutations = { + "class": {"HEADER_OUT": good["HEADER_OUT"].replace("ELF32", "ELF64")}, + "machine": { + "HEADER_OUT": good["HEADER_OUT"].replace("Machine: ARM", "Machine: X86-64") + }, + "eabi": {"HEADER_OUT": good["HEADER_OUT"].replace("Version5", "Version4")}, + "hard_float": { + "HEADER_OUT": good["HEADER_OUT"].replace("hard-float", "soft-float") + }, + "loader": {"PROGRAM_OUT": good["PROGRAM_OUT"].replace("armhf", "arm")}, + } + for fault, mutation in mutations.items(): + with self.subTest(fault=fault): + environment = good | mutation + result = self.run_helper( + 'validate_elf_metadata armhf fixture "$FILE_OUT" "$HEADER_OUT" "$PROGRAM_OUT"', + **environment, + ) + self.assertNotEqual(result.returncode, 0) + + +if __name__ == "__main__": + unittest.main() diff --git a/.github/scripts/tests/test_linux_ccache_policy.py b/.github/scripts/tests/test_linux_ccache_policy.py new file mode 100644 index 00000000..42c97e01 --- /dev/null +++ b/.github/scripts/tests/test_linux_ccache_policy.py @@ -0,0 +1,99 @@ +import pathlib +import unittest + + +REPOSITORY = pathlib.Path(__file__).resolve().parents[3] + + +class LinuxCcachePolicyTests(unittest.TestCase): + def read(self, relative_path): + return (REPOSITORY / relative_path).read_text(encoding="utf-8") + + def assert_cache_tiers(self, text, prefix): + primary = ( + f"{prefix}${{{{ steps.image.outputs.ccache_compatibility_id }}}}-" + "${{ steps.image.outputs.generation }}-${{ github.sha }}" + "${{ steps.ccache-key.outputs.suffix }}" + ) + generation = ( + f"{prefix}${{{{ steps.image.outputs.ccache_compatibility_id }}}}-" + "${{ steps.image.outputs.generation }}-" + ) + compatible = ( + f"{prefix}${{{{ steps.image.outputs.ccache_compatibility_id }}}}-" + ) + self.assertIn(f"key: {primary}", text) + generation_index = text.index(f" {generation}") + compatible_index = text.index(f" {compatible}", generation_index + 1) + self.assertLess(generation_index, compatible_index) + + def test_normal_cache_prefers_current_image_generation(self): + action = self.read(".github/actions/build-linux-payload/action.yml") + self.assert_cache_tiers(action, "ccache-linux-${{ inputs.arch }}-") + self.assertIn( + 'export CCACHE_COMPILERCHECK="${{ steps.image.outputs.ccache_compiler_check }}"', + action, + ) + self.assertIn('if: inputs.runtime_base == \'host\'', action) + self.assertIn('echo "CC=gcc"', action) + self.assertIn('echo "CXX=g++"', action) + self.assertIn( + "if: inputs.save_ccache == 'true' && steps.image.outputs.recipe_match == 'true' && steps.ccache.outputs.cache-hit != 'true'", + action, + ) + + def test_sanitizer_cache_keeps_profile_and_generation(self): + action = self.read(".github/actions/build-linux-sanitizers/action.yml") + self.assert_cache_tiers( + action, + "ccache-linux-x86_64-${{ steps.sanitizer.outputs.cache_key }}-", + ) + self.assertIn( + 'export CCACHE_COMPILERCHECK="${{ steps.image.outputs.ccache_compiler_check }}"', + action, + ) + self.assertIn( + "if: inputs.save_ccache == 'true' && steps.image.outputs.recipe_match == 'true' && steps.ccache.outputs.cache-hit != 'true'", + action, + ) + + def test_armhf_verifies_and_forwards_cache_identity(self): + workflow = self.read(".github/workflows/build-linux.yml") + self.assert_cache_tiers(workflow, "ccache-linux-armhf-") + self.assertIn( + "verify-armhf-ci-image.sh cross-builder armhf", workflow + ) + self.assertIn("verify-armhf-ci-image.sh runtime armhf", workflow) + self.assertIn( + "CROSS_BUILDER_IMAGE: ${{ needs.resolve-image.outputs.cross_image_reference }}", + workflow, + ) + self.assertEqual( + workflow.count( + "RUNTIME_IMAGE: ${{ needs.resolve-image.outputs.image_reference }}" + ), + 2, + ) + self.assertIn("build-linux-armhf-cross.sh", workflow) + self.assertIn("validate-linux-armhf-runtime.sh", workflow) + self.assertIn("HAMLIB_BRANCH: ${{ inputs.hamlib_branch }}", workflow) + self.assertIn("CCACHE_COMPILERCHECK: ${{ steps.image.outputs.ccache_compiler_check }}", workflow) + self.assertIn("-e CCACHE_COMPILERCHECK", workflow) + self.assertIn("-e WSJTX_CI_IMAGE_ALLOW_RECIPE_MISMATCH", workflow) + self.assertIn("cross_recipe_match", workflow) + self.assertIn("runtime_recipe_match", workflow) + self.assertIn( + "if: inputs.save_ccache && steps.image.outputs.recipe_match == 'true' && steps.ccache.outputs.cache-hit != 'true'", + workflow, + ) + + def test_release_accepts_separately_promoted_armhf_recipe(self): + workflow = self.read(".github/workflows/release.yml") + armhf_job = workflow.split(" linux-armhf:\n", 1)[1].split( + "\n windows:\n", 1 + )[0] + self.assertIn("allow_stale_image: true", armhf_job) + + +if __name__ == "__main__": + unittest.main() diff --git a/.github/scripts/tests/test_linux_image_publication_policy.py b/.github/scripts/tests/test_linux_image_publication_policy.py new file mode 100644 index 00000000..cb88ac95 --- /dev/null +++ b/.github/scripts/tests/test_linux_image_publication_policy.py @@ -0,0 +1,181 @@ +import pathlib +import re +import unittest + + +ROOT = pathlib.Path(__file__).resolve().parents[3] +PUBLISH = (ROOT / ".github/workflows/publish-linux-ci-images.yml").read_text() +BUILD = (ROOT / ".github/workflows/build-linux.yml").read_text() +WARM = (ROOT / ".github/workflows/warm-dependency-caches.yml").read_text() +CLASSIFIER = (ROOT / ".github/scripts/is-linux-ci-image-input.sh").read_text() + + +def job(name: str) -> str: + match = re.search( + rf"^ {re.escape(name)}:\n(?P<body>.*?)(?=^ [a-z][a-z0-9-]*:\n|\Z)", + PUBLISH, + re.MULTILINE | re.DOTALL, + ) + if not match: + raise AssertionError(f"job not found: {name}") + return match.group("body") + + +class LinuxImagePublicationPolicyTests(unittest.TestCase): + def test_public_release_publication_is_tag_scoped_and_complete(self): + validate = job("validate-inputs") + self.assertIn('[ "$REQUEST_REPOSITORY" != WSJTX/wsjtx ]', validate) + self.assertIn("^refs/tags/v[0-9]+\\.[0-9]+\\.[0-9]+", validate) + self.assertIn('[ "$PROMOTE" != false ]', validate) + self.assertIn('[ "$IMAGE_SET" != normal ]', validate) + self.assertIn('[ "$INCLUDE_ARMHF" != true ]', validate) + + def test_public_release_images_use_release_tag_and_public_package_root(self): + metadata = job("metadata") + public_block = re.search( + r'if \[ "\$PUBLICATION_TARGET" = public-release \]; then(?P<body>.*?)else', + metadata, + re.DOTALL, + ).group("body") + self.assertIn( + 'release-${GITHUB_REF_NAME}-${GITHUB_SHA}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}', + public_block, + ) + self.assertIn("package_root=ghcr.io/wsjtx/wsjtx", public_block) + self.assertNotIn(":stable", public_block) + self.assertIn("type=gha", public_block) + self.assertEqual( + PUBLISH.count( + "labels: ${{ inputs.publication_target == 'public-release' && 'org.opencontainers.image.source=https://github.com/WSJTX/wsjtx' || '' }}" + ), + 5, + ) + + def test_reusable_publisher_exports_all_release_image_digests(self): + self.assertIn("x86_64_digest:", PUBLISH) + self.assertIn("value: ${{ jobs.build-normal.outputs.digest }}", PUBLISH) + self.assertIn("aarch64_digest:", PUBLISH) + self.assertIn("value: ${{ jobs.build-arm64.outputs.digest }}", PUBLISH) + self.assertIn("armhf_digest:", PUBLISH) + self.assertIn("value: ${{ jobs.build-armhf-runtime.outputs.digest }}", PUBLISH) + self.assertIn("armhf_cross_digest:", PUBLISH) + self.assertIn("value: ${{ jobs.build-armhf-cross.outputs.digest }}", PUBLISH) + + def test_public_release_builds_require_and_consume_digest_references(self): + self.assertIn("^sha256:[0-9a-f]{64}$", BUILD) + self.assertIn("public-release images require an immutable sha256 digest", BUILD) + self.assertIn( + 'image_reference=${package_root}/${package}@${IMAGE_DIGEST}', BUILD + ) + self.assertIn( + 'cross_image_reference=${package_root}/${cross_package}@${ARMHF_CROSS_IMAGE_DIGEST}', + BUILD, + ) + self.assertEqual( + BUILD.count("image: ${{ needs.resolve-image.outputs.image_reference }}"), 2 + ) + self.assertIn( + "CROSS_BUILDER_IMAGE: ${{ needs.resolve-image.outputs.cross_image_reference }}", + BUILD, + ) + self.assertIn( + "RUNTIME_IMAGE: ${{ needs.resolve-image.outputs.image_reference }}", BUILD + ) + + def test_manual_target_mapping_keeps_tsan_independent(self): + self.assertRegex(WARM, r"linux\|linux-images\)\n\s+normal_images=true") + self.assertRegex(WARM, r"linux-tsan\)\n\s+tsan_images=true") + all_case = re.search(r"all\)\n(?P<body>.*?);;", WARM, re.DOTALL).group("body") + self.assertIn("enable_all", all_case) + self.assertNotIn("tsan_images=true", all_case) + self.assertIn("image_set: ${{ needs.detect.outputs.image_set }}", WARM) + self.assertRegex( + WARM, + r'if \[ "\$SCHEDULE" = "17 9 1 \* \*" \][\s\S]*?normal_images=true\s+tsan_images=true', + ) + + def test_push_selection_uses_tested_profile_classifier(self): + self.assertIn('is-linux-ci-image-input.sh --classify "$path"', WARM) + self.assertIn("expect_image_set normal ", CLASSIFIER) + self.assertIn("expect_image_set tsan ", CLASSIFIER) + self.assertIn("expect_image_set normal-and-tsan ", CLASSIFIER) + self.assertIn('expect_image_set none "CMake/Sources.cmake"', CLASSIFIER) + self.assertIn("armhf-cross-bookworm", CLASSIFIER) + self.assertIn("armhf-runtime-bookworm", CLASSIFIER) + self.assertIn('include_armhf: true', WARM) + + def test_candidate_warm_uses_exact_tag_and_publishes_without_recache(self): + warm = job("warm-normal-ccache") + self.assertIn("- build-normal", warm) + self.assertIn("uses: ./.github/workflows/build-linux.yml", warm) + self.assertIn("image_tag: ${{ needs.metadata.outputs.build_tag }}", warm) + self.assertIn("allow_stale_image: false", warm) + self.assertIn("recache: false", warm) + self.assertIn("save_ccache: true", warm) + + promote = job("promote") + self.assertIn("needs.warm-normal-ccache.result == 'success'", promote) + self.assertIn("- warm-normal-ccache", promote) + + def test_metadata_loads_only_the_selected_image_cohort(self): + metadata = job("metadata") + self.assertIn('if [ "$IMAGE_SET" != tsan ]; then', metadata) + self.assertIn(". .github/scripts/linux-ci-image-config.sh", metadata) + self.assertIn("linux-ci-image-fingerprint.sh armhf-cross-bookworm", metadata) + self.assertIn("linux-ci-image-fingerprint.sh armhf-runtime-bookworm", metadata) + self.assertIn('if [ "$IMAGE_SET" != normal ]; then', metadata) + self.assertIn(". .github/scripts/tsan-linux-deps-config.sh", metadata) + + def test_armhf_images_are_built_and_promoted_as_one_generation(self): + cross = job("build-armhf-cross") + runtime = job("build-armhf-runtime") + promote = job("promote") + + self.assertIn("platforms: linux/amd64", cross) + self.assertIn("Dockerfile.armhf-cross", cross) + self.assertIn("/usr/local/lib/android /usr/share/dotnet /opt/ghc", cross) + self.assertNotIn("/usr/local/lib/android", job("build-normal")) + self.assertIn("- build-armhf-cross", runtime) + self.assertIn("platforms: linux/arm/v7", runtime) + self.assertIn("Dockerfile.armhf-runtime", runtime) + self.assertIn( + "CROSS_BUILDER_IMAGE=${{ needs.metadata.outputs.package_root }}/" + "linux-armhf-cross-bookworm:${{ needs.metadata.outputs.build_tag }}", + runtime, + ) + self.assertIn("linux-armhf-cross-bookworm:${VALIDATED_TAG}", promote) + self.assertIn("linux-armv7-bookworm:${VALIDATED_TAG}", promote) + self.assertIn("linux-armhf-cross-bookworm:stable", promote) + self.assertIn("linux-armv7-bookworm:stable", promote) + + def test_publication_mutations_require_develop(self): + validate = job("validate-inputs") + self.assertIn('[ "$MODE" = rollback ] || [ "$PROMOTE" = true ]', validate) + self.assertIn('[ "$REQUEST_REF" != refs/heads/develop ]', validate) + + def test_tsan_only_jobs_and_tag_moves_exclude_normal_images(self): + validate = job("validate-inputs") + self.assertIn("normal|tsan|normal-and-tsan", validate) + self.assertIn('[ "$IMAGE_SET" = tsan ] && [ "$INCLUDE_ARMHF" = true ]', validate) + self.assertIn("inputs.image_set == 'tsan'", job("build-tsan")) + self.assertIn("inputs.image_set == 'normal'", job("build-normal")) + self.assertIn('if [ "$IMAGE_SET" != tsan ]; then', job("promote")) + self.assertIn('if [ "$IMAGE_SET" != normal ]; then', job("promote")) + self.assertIn('if [ "$IMAGE_SET" != tsan ]; then', job("rollback")) + self.assertIn('if [ "$IMAGE_SET" != normal ]; then', job("rollback")) + + def test_rollback_uses_only_explicitly_selected_packages(self): + rollback = job("rollback") + self.assertNotIn("tsan_available", rollback) + self.assertNotIn("armhf_available", rollback) + self.assertIn("packages+=(linux-noble linux-arm64-bookworm)", rollback) + self.assertIn( + "packages+=(linux-armhf-cross-bookworm linux-armv7-bookworm)", + rollback, + ) + self.assertIn("packages+=(linux-tsan-noble)", rollback) + self.assertIn("stable_packages+=(linux-noble)", rollback) + + +if __name__ == "__main__": + unittest.main() diff --git a/.github/scripts/tests/test_release_policy.py b/.github/scripts/tests/test_release_policy.py new file mode 100644 index 00000000..a7929484 --- /dev/null +++ b/.github/scripts/tests/test_release_policy.py @@ -0,0 +1,383 @@ +import importlib.util +import json +import io +import shutil +import subprocess +import sys +import tarfile +import tempfile +import unittest +import zipfile +from pathlib import Path + + +SCRIPT = Path(__file__).parents[1] / "release-policy.py" +SPEC = importlib.util.spec_from_file_location("release_policy", SCRIPT) +release_policy = importlib.util.module_from_spec(SPEC) +assert SPEC.loader +SPEC.loader.exec_module(release_policy) + + +class ReleasePolicyTest(unittest.TestCase): + def test_classifies_ga_and_rc(self): + self.assertEqual(release_policy.classify("3.2.0")["channel"], "GA") + identity = release_policy.classify("3.2.0-rc2") + self.assertEqual(identity["channel"], "RC") + self.assertEqual(identity["rc_number"], "2") + self.assertEqual(identity["release_branch"], "release/3.2") + + def test_rejects_non_release_versions(self): + for version in ("v3.2.0", "3.2.0-beta1", "3.2", "3.2.0-rc0"): + with self.subTest(version=version), self.assertRaises(ValueError): + release_policy.classify(version) + + def test_validates_tracked_release_state(self): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + (root / "release-state.txt").write_text( + "version=3.2.0\n" + "channel=RC\n" + "rc=1\n" + "revision=$Format:%H$\n" + ) + identity = release_policy.validate_source(root, "3.2.0-rc1") + self.assertEqual(identity["channel"], "RC") + self.assertEqual(identity["windows_signing"], "signpath") + with self.assertRaisesRegex(ValueError, "release channel"): + release_policy.validate_source(root, "3.2.0") + (root / "release-state.txt").write_text( + "version=3.2.0\nchannel=RC\nrc=1\nrevision=" + "a" * 40 + "\n" + ) + with self.assertRaisesRegex(ValueError, "revision"): + release_policy.validate_source(root, "3.2.0-rc1") + + def test_read_state_cli_accepts_single_digit_rc(self): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + (root / "release-state.txt").write_text( + "version=3.2.0\n" + "channel=RC\n" + "rc=1\n" + "revision=$Format:%H$\n" + ) + result = subprocess.run( + [sys.executable, SCRIPT, "read-state", "--root", root], + check=True, + capture_output=True, + text=True, + ) + self.assertEqual( + json.loads(result.stdout), + { + "version": "3.2.0", + "channel": "RC", + "rc": "1", + "revision": "$Format:%H$", + "windows_signing": "signpath", + }, + ) + + (root / "release-state.txt").write_text( + "version=3.2.0\n" + "channel=RC\n" + "rc=1beta\n" + "revision=$Format:%H$\n" + ) + result = subprocess.run( + [sys.executable, SCRIPT, "read-state", "--root", root], + capture_output=True, + text=True, + ) + self.assertNotEqual(result.returncode, 0) + self.assertIn("positive RC number", result.stderr) + + def test_source_pins_unsigned_mode_and_rejects_unknown_mode(self): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + state = ( + "version=3.2.0\nchannel=RC\nrc=1\n" + "revision=$Format:%H$\nwindows_signing=unsigned\n" + ) + (root / "release-state.txt").write_text(state) + self.assertEqual( + release_policy.validate_source(root, "3.2.0-rc1")["windows_signing"], + "unsigned", + ) + archive = root / "source.zip" + commit = "c" * 40 + with zipfile.ZipFile(archive, "w") as output: + output.writestr( + "wsjtx-3.2.0-rc1/release-state.txt", + state.replace("$Format:%H$", commit), + ) + release_policy.validate_archive(archive, "3.2.0-rc1", commit) + with self.assertRaisesRegex(ValueError, "windows_signing"): + release_policy.parse_state(state.replace("unsigned", "ephemeral")) + + def test_validates_exported_tar_and_zip_identity(self): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + commit = "b" * 40 + state = f"version=3.2.0\nchannel=RC\nrc=1\nrevision={commit}\n".encode() + tar_path = root / "source.tar.gz" + with tarfile.open(tar_path, "w:gz") as archive: + info = tarfile.TarInfo("wsjtx-3.2.0-rc1/release-state.txt") + info.size = len(state) + archive.addfile(info, io.BytesIO(state)) + zip_path = root / "source.zip" + with zipfile.ZipFile(zip_path, "w") as archive: + archive.writestr("wsjtx-3.2.0-rc1/release-state.txt", state) + release_policy.validate_archive(tar_path, "3.2.0-rc1", commit) + release_policy.validate_archive(zip_path, "3.2.0-rc1", commit) + with self.assertRaisesRegex(ValueError, "revision"): + release_policy.validate_archive(tar_path, "3.2.0-rc1", "c" * 40) + + def test_distribution_gate_rejects_unsigned_package(self): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + version = "3.2.0-rc1" + for name in release_policy.expected_assets(version, True): + target = root / name + target.mkdir() + suffix = ".pkg" if "macOS" in name else ".AppImage" if "linux" in name else ".exe" + (target / f"artifact{suffix}").write_bytes(b"signed") + (root / "extra").mkdir() + (root / "extra" / "unexpected-unsigned.pkg").write_bytes(b"unsigned") + with self.assertRaisesRegex(ValueError, "unsigned macOS"): + release_policy.find_asset_files(root, version, True) + + def test_manifest_binds_assets_to_tag_and_commit(self): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + version = "3.2.0" + for name in release_policy.expected_assets(version, True): + target = root / name + target.mkdir() + suffix = ".pkg" if "macOS" in name else ".AppImage" if "linux" in name else ".exe" + (target / f"{name}{suffix}" if not name.endswith(suffix) else target / name).write_bytes(name.encode()) + for arch in ("x86_64", "aarch64", "armhf"): + for package_type in ("deb", "rpm"): + target = root / f"wsjtx-{version}-linux-{arch}-{package_type}" + target.mkdir() + (target / f"wsjtx-{arch}.{package_type}").write_bytes(arch.encode()) + (root / f"wsjtx-{version}-src.tar.gz").write_bytes(b"source") + args = type("Args", (), { + "artifacts": str(root), "version": version, "repository": "WSJTX/wsjtx", + "commit": "a" * 40, "run_id": "123", + "linux_x86_64_digest": "sha256:" + "1" * 64, + "linux_aarch64_digest": "sha256:" + "2" * 64, + "linux_armhf_cross_digest": "sha256:" + "3" * 64, + "linux_armhf_digest": "sha256:" + "4" * 64, + "macos_mode": "distribution", + "windows_mode": "signpath", + })() + release_policy.write_manifest(args) + manifest = json.loads((root / "release-manifest.json").read_text()) + self.assertEqual(manifest["tag"], "v3.2.0") + self.assertEqual(manifest["commit"], "a" * 40) + self.assertEqual(manifest["linux_builders"]["armhf_cross"], "sha256:" + "3" * 64) + self.assertEqual(manifest["linux_builders"]["armhf_runtime"], "sha256:" + "4" * 64) + self.assertEqual(manifest["macos_signing"]["mode"], "distribution") + self.assertEqual(manifest["macos_signing"]["replaceable_assets"], []) + self.assertEqual(manifest["windows_signing"]["mode"], "signpath") + self.assertEqual(len(manifest["assets"]), 13) + + def test_manual_macos_assets_keep_release_names_without_immutable_hashes(self): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + version = "3.2.0" + for name in release_policy.public_expected_assets(version, "validation"): + target = root / name + target.mkdir() + if "macOS" in name: + filename = name.replace("-unsigned", "") + elif "linux" in name: + filename = f"{name}.AppImage" + else: + filename = "wsjtx-win64.exe" + (target / filename).write_bytes(name.encode()) + for arch in ("x86_64", "aarch64", "armhf"): + for package_type in ("deb", "rpm"): + target = root / f"wsjtx-{version}-linux-{arch}-{package_type}" + target.mkdir() + (target / f"wsjtx-{arch}.{package_type}").write_bytes(arch.encode()) + (root / f"wsjtx-{version}-src.tar.gz").write_bytes(b"source") + args = type("Args", (), { + "artifacts": str(root), "version": version, "repository": "WSJTX/wsjtx", + "commit": "a" * 40, "run_id": "123", + "linux_x86_64_digest": "sha256:" + "1" * 64, + "linux_aarch64_digest": "sha256:" + "2" * 64, + "linux_armhf_cross_digest": "sha256:" + "3" * 64, + "linux_armhf_digest": "sha256:" + "4" * 64, + "macos_mode": "validation", + "windows_mode": "signpath", + })() + + release_policy.write_manifest(args) + + manifest = json.loads((root / "release-manifest.json").read_text()) + replaceable = { + f"wsjtx-{version}-arm64-macOS.pkg", + f"wsjtx-{version}-x86_64-macOS.pkg", + } + release_names = {path.name for path in release_policy.release_files(root, version, "validation")} + immutable_names = {entry["name"] for entry in manifest["assets"]} + checksum_names = { + line.split(" ", 1)[1] + for line in (root / "SHA256SUMS").read_text().splitlines() + } + self.assertEqual(manifest["macos_signing"]["mode"], "manual") + self.assertEqual(set(manifest["macos_signing"]["replaceable_assets"]), replaceable) + self.assertTrue(replaceable <= release_names) + self.assertTrue(replaceable.isdisjoint(immutable_names)) + self.assertTrue(replaceable.isdisjoint(checksum_names)) + self.assertIn("wsjtx-win64.exe", immutable_names) + + def test_unsigned_windows_manifest_selects_and_hashes_installer(self): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + version = "3.2.0-rc1" + for name in release_policy.public_expected_assets(version, "validation", "unsigned"): + target = root / name + target.mkdir() + if "macOS" in name: + filename = name.replace("-unsigned", "") + elif "linux" in name: + filename = f"{name}.AppImage" + else: + filename = f"wsjtx-{version}-win64.exe" + (target / filename).write_bytes(name.encode()) + for arch in ("x86_64", "aarch64", "armhf"): + for package_type in ("deb", "rpm"): + target = root / f"wsjtx-{version}-linux-{arch}-{package_type}" + target.mkdir() + (target / f"wsjtx-{arch}.{package_type}").write_bytes(arch.encode()) + (root / f"wsjtx-{version}-src.tar.gz").write_bytes(b"source") + args = type("Args", (), { + "artifacts": str(root), "version": version, "repository": "WSJTX/wsjtx", + "commit": "a" * 40, "run_id": "123", + "linux_x86_64_digest": "sha256:" + "1" * 64, + "linux_aarch64_digest": "sha256:" + "2" * 64, + "linux_armhf_cross_digest": "sha256:" + "3" * 64, + "linux_armhf_digest": "sha256:" + "4" * 64, + "macos_mode": "validation", "windows_mode": "unsigned", + })() + release_policy.write_manifest(args) + manifest = json.loads((root / "release-manifest.json").read_text()) + installer = f"wsjtx-{version}-win64.exe" + self.assertEqual(manifest["windows_signing"]["mode"], "unsigned") + self.assertIn(installer, {entry["name"] for entry in manifest["assets"]}) + self.assertIn(installer, (root / "SHA256SUMS").read_text()) + installer_path = root / f"wsjtx-{version}-windows-x86_64-installer" / installer + installer_path.rename(installer_path.with_name("unexpected.exe")) + with self.assertRaisesRegex(ValueError, "unexpected unsigned Windows installer"): + release_policy.find_public_asset_files(root, version, "validation", "unsigned") + installer_path.with_name("unexpected.exe").rename(installer_path) + signed_dir = root / f"wsjtx-{version}-windows-x86_64-installer-signed" + signed_dir.mkdir() + with self.assertRaisesRegex(ValueError, "signed Windows installer"): + release_policy.find_public_asset_files(root, version, "validation", "unsigned") + + def test_signing_reports_bind_hashes_and_source(self): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + version = "3.2.0-rc1" + commit = "b" * 40 + tag = f"v{version}" + for arch in ("arm64", "x86_64"): + package_dir = root / f"wsjtx-{version}-{arch}-macOS.pkg" + package_dir.mkdir() + package = package_dir / f"wsjtx-{version}-{arch}-macOS.pkg" + package.write_bytes(arch.encode()) + report_dir = root / f"macos-signing-report-{version}-{arch}" + report_dir.mkdir() + (report_dir / "macos-signing-report.json").write_text(json.dumps({ + "mode": "distribution", "git_sha": commit, "artifact": package.name, + "sha256": release_policy.hash_file(package), "notarization": {"status": "Accepted"}, + "stapled": True, "gatekeeper_accepted": True, "team_id": "ABCDE12345", + "application_certificate_sha1": "A" * 40, + "installer_certificate_sha1": "B" * 40, + })) + installer_dir = root / f"wsjtx-{version}-windows-x86_64-installer-signed" + installer_dir.mkdir() + installer = installer_dir / "wsjtx.exe" + installer.write_bytes(b"windows") + request_dir = root / f"wsjtx-{version}-windows-signing-request" + request_dir.mkdir() + (request_dir / "request.json").write_text(json.dumps({ + "policy": "release-signing", "commit": commit, "tag": tag, + })) + verification_dir = root / f"wsjtx-{version}-windows-signing-verification" + verification_dir.mkdir() + (verification_dir / "verification.json").write_text(json.dumps({ + "commit": commit, "tag": tag, "artifact": installer.name, + "sha256": release_policy.hash_file(installer), "status": "Valid", + "timestamp_thumbprint": "1234", "signer_subject": "WSJT-X", + "signer_thumbprint": "5678", "identity_verified": True, + })) + release_policy.verify_signing_reports(root, version, commit, tag) + (verification_dir / "verification.json").write_text("{}") + with self.assertRaisesRegex(ValueError, "release ref"): + release_policy.verify_signing_reports(root, version, commit, tag) + + def test_validation_reports_allow_unsigned_macos_with_signed_windows(self): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + version = "3.2.0-rc1" + commit = "b" * 40 + tag = f"v{version}" + for arch in ("arm64", "x86_64"): + package_dir = root / f"wsjtx-{version}-{arch}-macOS-unsigned.pkg" + package_dir.mkdir() + package = package_dir / f"wsjtx-{version}-{arch}-macOS.pkg" + package.write_bytes(arch.encode()) + report_dir = root / f"macos-signing-report-{version}-{arch}" + report_dir.mkdir() + (report_dir / "macos-signing-report.json").write_text(json.dumps({ + "mode": "validation", "git_sha": commit, "artifact": package.name, + "sha256": release_policy.hash_file(package), "signed": False, + "notarized": False, "publishable": False, + })) + installer_dir = root / f"wsjtx-{version}-windows-x86_64-installer-signed" + installer_dir.mkdir() + installer = installer_dir / "wsjtx.exe" + installer.write_bytes(b"windows") + request_dir = root / f"wsjtx-{version}-windows-signing-request" + request_dir.mkdir() + (request_dir / "request.json").write_text(json.dumps({ + "policy": "release-signing", "commit": commit, "tag": tag, + })) + verification_dir = root / f"wsjtx-{version}-windows-signing-verification" + verification_dir.mkdir() + (verification_dir / "verification.json").write_text(json.dumps({ + "commit": commit, "tag": tag, "artifact": installer.name, + "sha256": release_policy.hash_file(installer), "status": "Valid", + "timestamp_thumbprint": "1234", "signer_subject": "WSJT-X", + "signer_thumbprint": "5678", "identity_verified": True, + })) + + release_policy.verify_signing_reports(root, version, commit, tag, "validation") + + report = json.loads( + (root / f"macos-signing-report-{version}-arm64" / "macos-signing-report.json").read_text() + ) + report["signed"] = True + (root / f"macos-signing-report-{version}-arm64" / "macos-signing-report.json").write_text( + json.dumps(report) + ) + with self.assertRaisesRegex(ValueError, "unsigned package"): + release_policy.verify_signing_reports(root, version, commit, tag, "validation") + + report["signed"] = False + (root / f"macos-signing-report-{version}-arm64" / "macos-signing-report.json").write_text( + json.dumps(report) + ) + with self.assertRaisesRegex(ValueError, "Windows signing report"): + release_policy.verify_signing_reports(root, version, commit, tag, "validation", "unsigned") + shutil.rmtree(request_dir) + shutil.rmtree(verification_dir) + release_policy.verify_signing_reports(root, version, commit, tag, "validation", "unsigned") + + +if __name__ == "__main__": + unittest.main() diff --git a/.github/scripts/tests/test_resolve_linux_ci_image_tag.py b/.github/scripts/tests/test_resolve_linux_ci_image_tag.py new file mode 100755 index 00000000..b8a3c1bd --- /dev/null +++ b/.github/scripts/tests/test_resolve_linux_ci_image_tag.py @@ -0,0 +1,125 @@ +#!/usr/bin/env python3 + +import importlib.util +import sys +import unittest +from datetime import datetime, timezone +from pathlib import Path + + +SCRIPT = Path(__file__).parents[1] / "resolve-linux-ci-image-tag.py" +SPEC = importlib.util.spec_from_file_location("resolve_linux_ci_image_tag", SCRIPT) +MODULE = importlib.util.module_from_spec(SPEC) +sys.modules[SPEC.name] = MODULE +SPEC.loader.exec_module(MODULE) + + +def version(version_id, tags): + return MODULE.Version( + id=version_id, + digest=f"sha256:{version_id:064x}", + created_at=datetime(2026, 8, 18, tzinfo=timezone.utc), + tags=tuple(tags), + ) + + +class FakeClient: + def __init__(self, packages): + self.packages = packages + + def list_versions(self, owner, package): + return self.packages.get(package, []) + + +class ResolveTests(unittest.TestCase): + def coherent(self): + tag = "build-20260818-123-1" + return tag, { + package: [ + version( + index, + (tag, "stable") + if package in (MODULE.NORMAL_PACKAGE, MODULE.ARMHF_PACKAGE) + else (tag,), + ) + ] + for index, package in enumerate( + ( + MODULE.NORMAL_PACKAGE, + *MODULE.ROUTINE_PACKAGES, + MODULE.ARMHF_PACKAGE, + MODULE.ARMHF_CROSS_PACKAGE, + ), + start=1, + ) + } + + def test_resolves_build_tag_attached_to_stable_pointer(self): + tag, packages = self.coherent() + self.assertEqual(MODULE.resolve(FakeClient(packages)), tag) + + def test_rejects_missing_generation_member(self): + _, packages = self.coherent() + packages[MODULE.ARM64_PACKAGE] = [] + with self.assertRaisesRegex(RuntimeError, "does not exist"): + MODULE.resolve(FakeClient(packages)) + + def test_strict_resolution_rejects_missing_armhf(self): + _, packages = self.coherent() + packages[MODULE.ARMHF_PACKAGE] = [] + with self.assertRaisesRegex(RuntimeError, "does not exist"): + MODULE.resolve(FakeClient(packages), require_armhf=True) + + def test_routine_resolution_does_not_require_armhf(self): + tag, packages = self.coherent() + packages.pop(MODULE.ARMHF_PACKAGE) + self.assertEqual(MODULE.resolve(FakeClient(packages)), tag) + + def test_armhf_resolution_uses_armhf_stable_pointer(self): + tag, packages = self.coherent() + self.assertEqual(MODULE.resolve_armhf(FakeClient(packages)), tag) + + def test_armhf_resolution_requires_armhf_stable_pointer(self): + _, packages = self.coherent() + packages[MODULE.ARMHF_PACKAGE] = [] + with self.assertRaisesRegex(RuntimeError, "armhf.*stable is missing"): + MODULE.resolve_armhf(FakeClient(packages)) + + def test_armhf_resolution_requires_matching_cross_builder(self): + _, packages = self.coherent() + packages[MODULE.ARMHF_CROSS_PACKAGE] = [] + with self.assertRaisesRegex(RuntimeError, "linux-armhf-cross-bookworm"): + MODULE.resolve_armhf(FakeClient(packages)) + + def test_tsan_resolution_uses_tsan_stable_pointer(self): + tag, packages = self.coherent() + packages[MODULE.TSAN_PACKAGE] = [version(8, (tag, "stable"))] + self.assertEqual(MODULE.resolve_tsan(FakeClient(packages)), tag) + + def test_tsan_resolution_requires_tsan_stable_pointer(self): + _, packages = self.coherent() + packages[MODULE.TSAN_PACKAGE] = [] + with self.assertRaisesRegex(RuntimeError, "TSan.*stable is missing"): + MODULE.resolve_tsan(FakeClient(packages)) + + def test_rejects_ambiguous_stable_pointer(self): + _, packages = self.coherent() + packages[MODULE.NORMAL_PACKAGE].append(version(9, ("stable",))) + with self.assertRaisesRegex(RuntimeError, "expected one"): + MODULE.resolve(FakeClient(packages)) + + def test_reports_missing_promoted_generation(self): + _, packages = self.coherent() + packages[MODULE.NORMAL_PACKAGE] = [] + with self.assertRaisesRegex(RuntimeError, "No promoted Linux CI image generation"): + MODULE.resolve(FakeClient(packages)) + + def test_rejects_stable_without_build_tag(self): + _, packages = self.coherent() + packages[MODULE.NORMAL_PACKAGE] = [version(1, ("stable", "candidate-123-1"))] + with self.assertRaisesRegex(RuntimeError, "exactly one"): + MODULE.resolve(FakeClient(packages)) + + +if __name__ == "__main__": + unittest.main() diff --git a/.github/scripts/tests/test_should_refresh_linux_ci_images.py b/.github/scripts/tests/test_should_refresh_linux_ci_images.py new file mode 100644 index 00000000..0b589dac --- /dev/null +++ b/.github/scripts/tests/test_should_refresh_linux_ci_images.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 + +import importlib.util +import sys +import unittest +from datetime import datetime, timedelta, timezone +from pathlib import Path + + +SCRIPT = Path(__file__).parents[1] / "should-refresh-linux-ci-images.py" +SPEC = importlib.util.spec_from_file_location("should_refresh_linux_ci_images", SCRIPT) +MODULE = importlib.util.module_from_spec(SPEC) +sys.modules[SPEC.name] = MODULE +SPEC.loader.exec_module(MODULE) + + +def version(version_id, age_days, tags, now): + return MODULE.Version( + id=version_id, + digest=f"sha256:{version_id:064x}", + created_at=now - timedelta(days=age_days), + tags=tuple(tags), + ) + + +class RefreshDecisionTests(unittest.TestCase): + def setUp(self): + self.now = datetime(2026, 8, 25, tzinfo=timezone.utc) + + def test_keeps_recent_stable_image(self): + refresh, age_days = MODULE.should_refresh( + [version(1, 29, ("stable", "build-20260801-1-1"), self.now)], + now=self.now, + max_age_days=30, + ) + self.assertFalse(refresh) + self.assertEqual(age_days, 29) + + def test_refreshes_old_stable_image(self): + refresh, age_days = MODULE.should_refresh( + [version(1, 30, ("stable", "build-20260726-1-1"), self.now)], + now=self.now, + max_age_days=30, + ) + self.assertTrue(refresh) + self.assertEqual(age_days, 30) + + def test_rejects_missing_or_ambiguous_stable_image(self): + with self.assertRaisesRegex(RuntimeError, "found 0"): + MODULE.should_refresh([], now=self.now, max_age_days=30) + with self.assertRaisesRegex(RuntimeError, "found 2"): + MODULE.should_refresh( + [ + version(1, 1, ("stable",), self.now), + version(2, 2, ("stable",), self.now), + ], + now=self.now, + max_age_days=30, + ) + + +if __name__ == "__main__": + unittest.main() diff --git a/.github/scripts/tsan-linux-deps-config.sh b/.github/scripts/tsan-linux-deps-config.sh new file mode 100755 index 00000000..0f4118f8 --- /dev/null +++ b/.github/scripts/tsan-linux-deps-config.sh @@ -0,0 +1,210 @@ +#!/usr/bin/env bash + +# Shared, pinned build tuple for Linux ThreadSanitizer dependencies. +# shellcheck disable=SC2034 + +TSAN_CACHE_EPOCH=1 +TSAN_RUNTIME_BASE=ubuntu24.04 +TSAN_ARCH=x86_64 + +TSAN_GCC_SUFFIX=13 +TSAN_GCC_VERSION=13.3.0 +TSAN_CC=gcc-${TSAN_GCC_SUFFIX} +TSAN_CXX=g++-${TSAN_GCC_SUFFIX} +TSAN_FC=gfortran-${TSAN_GCC_SUFFIX} +TSAN_SANITIZER_FLAGS="-fsanitize=thread -fno-omit-frame-pointer -g1 -O1" +TSAN_LINK_FLAGS="-fsanitize=thread" + +TSAN_QT_VERSION=5.15.18 +TSAN_QT_SOURCE_SHA256=cea1fbabf02455f3f0e8eaa839f5d6f45cdb56b62c8a83af5c1d00ac05f912ea +TSAN_QT_SOURCE_URL="https://download.qt.io/archive/qt/5.15/${TSAN_QT_VERSION}/single/qt-everywhere-opensource-src-${TSAN_QT_VERSION}.tar.xz" + +TSAN_BOOST_VERSION=1.83.0 +TSAN_BOOST_SOURCE_SHA256=6478edfe2f3305127cffe8caf73ea0176c53769f4bf1585be237eb30798c3b8e +TSAN_BOOST_SOURCE_URL="https://archives.boost.io/release/${TSAN_BOOST_VERSION}/source/boost_1_83_0.tar.bz2" + +TSAN_HAMLIB_REF=4.7.2 +TSAN_HAMLIB_COMMIT=40f63488fe0bd751b147f48d62fd217bf53713a0 +TSAN_HAMLIB_PATCH_COMMIT=141e1b19a0e2d65571e5b0783c43ab2615c0cdf7 + +tsan_config_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" + +tsan_sha256_files() { + local file digest hashes= + + for file in "$@"; do + if [ ! -f "$file" ]; then + echo "Cannot hash missing file: $file" >&2 + return 1 + fi + digest="$(sha256sum "$file" | awk '{print $1}')" + hashes+="${digest}"$'\n' + done + printf '%s' "$hashes" | sha256sum | awk '{print $1}' +} + +tsan_require_toolchain() { + local compiler actual_version linker_path + + for compiler in "$TSAN_CC" "$TSAN_CXX" "$TSAN_FC"; do + if ! command -v "$compiler" >/dev/null 2>&1; then + echo "Pinned TSan compiler not found: $compiler" >&2 + return 1 + fi + actual_version="$($compiler -dumpfullversion -dumpversion)" + if [ "$actual_version" != "$TSAN_GCC_VERSION" ]; then + echo "Pinned TSan compiler mismatch for $compiler: expected $TSAN_GCC_VERSION, got $actual_version" >&2 + return 1 + fi + done + + TSAN_TARGET="$($TSAN_CC -dumpmachine)" + TSAN_CC_PATH="$(readlink -f "$(command -v "$TSAN_CC")")" + TSAN_CXX_PATH="$(readlink -f "$(command -v "$TSAN_CXX")")" + TSAN_FC_PATH="$(readlink -f "$(command -v "$TSAN_FC")")" + linker_path="$($TSAN_CC -print-prog-name=ld)" + if [[ "$linker_path" != */* ]]; then + linker_path="$(command -v "$linker_path")" + fi + TSAN_LINKER_PATH="$(readlink -f "$linker_path")" + TSAN_LIBTSAN_PATH="$(readlink -f "$($TSAN_CC -print-file-name=libtsan.so)")" + TSAN_LIBSTDCXX_PATH="$(readlink -f "$($TSAN_CXX -print-file-name=libstdc++.so)")" + TSAN_LIBGCC_PATH="$(readlink -f "$($TSAN_CC -print-file-name=libgcc_s.so)")" + + for compiler in \ + "$TSAN_CC_PATH" "$TSAN_CXX_PATH" "$TSAN_FC_PATH" "$TSAN_LINKER_PATH" \ + "$TSAN_LIBTSAN_PATH" "$TSAN_LIBSTDCXX_PATH" "$TSAN_LIBGCC_PATH"; do + if [ ! -f "$compiler" ]; then + echo "Pinned TSan toolchain component not found: $compiler" >&2 + return 1 + fi + done + + TSAN_GLIBC_VERSION="$(getconf GNU_LIBC_VERSION | tr ' ' '-')" + TSAN_COMPILER_SHA256="$(tsan_sha256_files \ + "$TSAN_CC_PATH" "$TSAN_CXX_PATH" "$TSAN_FC_PATH" "$TSAN_LINKER_PATH")" + TSAN_RUNTIME_SHA256="$({ + printf '%s\n' "$TSAN_GCC_VERSION" "$TSAN_TARGET" "$TSAN_GLIBC_VERSION" + sha256sum "$TSAN_LIBTSAN_PATH" "$TSAN_LIBSTDCXX_PATH" "$TSAN_LIBGCC_PATH" + } | sha256sum | awk '{print $1}')" + TSAN_TOOLCHAIN_ID="gcc${TSAN_GCC_VERSION}-${TSAN_TARGET}-${TSAN_COMPILER_SHA256:0:12}-${TSAN_RUNTIME_SHA256:0:12}" +} + +tsan_dependency_recipe_hash() { + local dependency=$1 build_script + + case "$dependency" in + qt) build_script=build-qt-tsan-linux.sh ;; + boost) build_script=build-boost-tsan-linux.sh ;; + hamlib) build_script=build-hamlib-tsan-linux.sh ;; + *) + echo "Unsupported TSan dependency: $dependency" >&2 + return 2 + ;; + esac + + tsan_sha256_files \ + "${tsan_config_dir}/tsan-linux-deps-config.sh" \ + "${tsan_config_dir}/${build_script}" \ + "${tsan_config_dir}/verify-tsan-deps-linux.sh" +} + +tsan_dependency_version() { + case "$1" in + qt) printf '%s\n' "$TSAN_QT_VERSION" ;; + boost) printf '%s\n' "$TSAN_BOOST_VERSION" ;; + hamlib) printf '%s\n' "$TSAN_HAMLIB_REF" ;; + *) return 2 ;; + esac +} + +tsan_dependency_source_id() { + case "$1" in + qt) printf '%s\n' "$TSAN_QT_SOURCE_SHA256" ;; + boost) printf '%s\n' "$TSAN_BOOST_SOURCE_SHA256" ;; + hamlib) printf '%s+%s\n' "$TSAN_HAMLIB_COMMIT" "$TSAN_HAMLIB_PATCH_COMMIT" ;; + *) return 2 ;; + esac +} + +tsan_dependency_cache_key() { + local dependency=$1 version source_id recipe_hash + + if [ -z "${TSAN_TOOLCHAIN_ID:-}" ]; then + tsan_require_toolchain + fi + version="$(tsan_dependency_version "$dependency")" + source_id="$(tsan_dependency_source_id "$dependency")" + recipe_hash="$(tsan_dependency_recipe_hash "$dependency")" + printf '%s\n' "${dependency}-tsan-linux-${TSAN_ARCH}-${TSAN_RUNTIME_BASE}-${TSAN_TOOLCHAIN_ID}-${version}-${source_id}-epoch${TSAN_CACHE_EPOCH}-${recipe_hash}" +} + +tsan_write_dependency_manifest() { + local dependency=$1 prefix=$2 version source_id recipe_hash cache_key manifest + + tsan_require_toolchain + version="$(tsan_dependency_version "$dependency")" + source_id="$(tsan_dependency_source_id "$dependency")" + recipe_hash="$(tsan_dependency_recipe_hash "$dependency")" + cache_key="$(tsan_dependency_cache_key "$dependency")" + manifest="${prefix}/.wsjtx-tsan-manifest" + + { + printf 'schema=%s\n' "$TSAN_CACHE_EPOCH" + printf 'dependency=%s\n' "$dependency" + printf 'version=%s\n' "$version" + printf 'source_id=%s\n' "$source_id" + printf 'runtime_base=%s\n' "$TSAN_RUNTIME_BASE" + printf 'architecture=%s\n' "$TSAN_ARCH" + printf 'compiler=%s\n' "$TSAN_CC" + printf 'compiler_version=%s\n' "$TSAN_GCC_VERSION" + printf 'compiler_target=%s\n' "$TSAN_TARGET" + printf 'compiler_sha256=%s\n' "$TSAN_COMPILER_SHA256" + printf 'glibc_version=%s\n' "$TSAN_GLIBC_VERSION" + printf 'runtime_sha256=%s\n' "$TSAN_RUNTIME_SHA256" + printf 'recipe_sha256=%s\n' "$recipe_hash" + printf 'cache_key=%s\n' "$cache_key" + printf 'sanitizer_flags=%s\n' "$TSAN_SANITIZER_FLAGS" + printf 'link_flags=%s\n' "$TSAN_LINK_FLAGS" + } > "$manifest" +} + +tsan_emit_github_output() { + if [ -z "${GITHUB_OUTPUT:-}" ]; then + echo "GITHUB_OUTPUT is required for --github-output" >&2 + return 2 + fi + + tsan_require_toolchain + { + printf 'cc=%s\n' "$TSAN_CC" + printf 'cxx=%s\n' "$TSAN_CXX" + printf 'fc=%s\n' "$TSAN_FC" + printf 'gcc_version=%s\n' "$TSAN_GCC_VERSION" + printf 'toolchain_id=%s\n' "$TSAN_TOOLCHAIN_ID" + printf 'qt_key=%s\n' "$(tsan_dependency_cache_key qt)" + printf 'boost_key=%s\n' "$(tsan_dependency_cache_key boost)" + printf 'hamlib_key=%s\n' "$(tsan_dependency_cache_key hamlib)" + printf 'hamlib_ref=%s\n' "$TSAN_HAMLIB_REF" + } >> "$GITHUB_OUTPUT" +} + +if [ "${BASH_SOURCE[0]}" = "$0" ]; then + set -euo pipefail + case "${1:-}" in + --github-output) + tsan_emit_github_output + ;; + --print) + tsan_require_toolchain + printf 'toolchain_id=%s\n' "$TSAN_TOOLCHAIN_ID" + printf 'qt_key=%s\n' "$(tsan_dependency_cache_key qt)" + printf 'boost_key=%s\n' "$(tsan_dependency_cache_key boost)" + printf 'hamlib_key=%s\n' "$(tsan_dependency_cache_key hamlib)" + ;; + *) + echo "Usage: $0 --github-output|--print" >&2 + exit 2 + ;; + esac +fi diff --git a/.github/scripts/validate-ci-inputs.sh b/.github/scripts/validate-ci-inputs.sh new file mode 100755 index 00000000..e801a6eb --- /dev/null +++ b/.github/scripts/validate-ci-inputs.sh @@ -0,0 +1,177 @@ +#!/usr/bin/env bash +# Validate CI string inputs passed through environment variables. +# +# GitHub Actions expands ${{ }} expressions before the shell parses a +# `run:` script. Quoting in YAML does not stop command substitution or +# quote-breaking payloads in those expansions. Callers must pass +# workflow inputs through `env:` (which is not shell-parsed) and invoke +# this script before any later step interpolates the same values. +# +# Only variables that are set are checked, so each workflow can pass +# the subset it uses. Empty values are rejected except for +# WSJT_RC_NUMBER, which is optional. +# +# Usage: +# WSJTX_VERSION=... HAMLIB_BRANCH=... .github/scripts/validate-ci-inputs.sh +# .github/scripts/validate-ci-inputs.sh --self-test + +set -euo pipefail + +fail() { + echo "::error::$*" >&2 + exit 1 +} + +# POSIX case patterns keep this working on bash 3.2 (macOS) and MSYS2. +require_nonempty() { + if [ -z "$2" ]; then + fail "Invalid $1: value must not be empty" + fi +} + +require_boolean() { + case "$2" in + true|false) ;; + *) fail "Invalid $1 '$2': use true or false" ;; + esac +} + +validate_inputs() { + if [ -n "${WSJTX_VERSION+x}" ]; then + require_nonempty "version" "$WSJTX_VERSION" + case "$WSJTX_VERSION" in + *[!A-Za-z0-9._+-]*) + fail "Invalid version '${WSJTX_VERSION}': use only letters, numbers, '.', '_', '+', and '-'" + ;; + esac + fi + + if [ -n "${HAMLIB_BRANCH+x}" ]; then + require_nonempty "hamlib_branch" "$HAMLIB_BRANCH" + case "$HAMLIB_BRANCH" in + *[!A-Za-z0-9._/-]*) + fail "Invalid hamlib_branch '${HAMLIB_BRANCH}': use only letters, numbers, '.', '_', '/', and '-'" + ;; + esac + fi + + if [ -n "${WSJT_RELEASE_CHANNEL+x}" ]; then + case "$WSJT_RELEASE_CHANNEL" in + DEVEL|RC|GA) ;; + *) + fail "Invalid release_channel '${WSJT_RELEASE_CHANNEL}': use DEVEL, RC, or GA" + ;; + esac + fi + + if [ -n "${WSJT_RC_NUMBER+x}" ]; then + case "$WSJT_RC_NUMBER" in + ''|*[!0-9]*) + if [ -n "$WSJT_RC_NUMBER" ]; then + fail "Invalid rc_number '${WSJT_RC_NUMBER}': use digits only" + fi + ;; + esac + fi + + if [ -n "${ARCH+x}" ]; then + case "$ARCH" in + x86_64|aarch64|armhf|arm64) ;; + *) + fail "Invalid arch '${ARCH}': use x86_64, aarch64, armhf, or arm64" + ;; + esac + fi + + if [ -n "${VALIDATE_FORTRAN_FALLBACK+x}" ]; then + require_boolean "validate_fortran_fallback" "$VALIDATE_FORTRAN_FALLBACK" + fi + + if [ -n "${IMAGE_TAG+x}" ]; then + require_nonempty "image_tag" "$IMAGE_TAG" + if [ "${#IMAGE_TAG}" -gt 128 ]; then + fail "Invalid image_tag: value exceeds the 128-character container tag limit" + fi + case "$IMAGE_TAG" in + *[!A-Za-z0-9._-]*) + fail "Invalid image_tag '${IMAGE_TAG}': use a letter or number followed by letters, numbers, '.', '_', or '-'" + ;; + esac + case "$IMAGE_TAG" in + [A-Za-z0-9]*) ;; + *) fail "Invalid image_tag '${IMAGE_TAG}': the first character must be a letter or number" ;; + esac + fi + + if [ -n "${DEPLOYMENT_TARGET+x}" ]; then + case "$DEPLOYMENT_TARGET" in + ''|*[!0-9.]*) + fail "Invalid deployment_target '${DEPLOYMENT_TARGET}': use a dotted numeric version such as 10.13 or 11.0" + ;; + esac + fi + + if [ -n "${RUNNER+x}" ]; then + require_nonempty "runner" "$RUNNER" + case "$RUNNER" in + *[!A-Za-z0-9._-]*) + fail "Invalid runner '${RUNNER}': use only letters, numbers, '.', '_', and '-'" + ;; + esac + fi +} + +run_isolated() { + env -u WSJTX_VERSION -u HAMLIB_BRANCH -u WSJT_RELEASE_CHANNEL \ + -u WSJT_RC_NUMBER -u ARCH -u IMAGE_TAG -u DEPLOYMENT_TARGET -u RUNNER \ + -u VALIDATE_FORTRAN_FALLBACK \ + "$@" "$0" +} + +expect_failure() { + local label="$1" + shift + if run_isolated env "$@" >/dev/null 2>&1; then + echo "self-test failed: expected rejection of ${label}" >&2 + exit 1 + fi +} + +if [ "${1:-}" = "--self-test" ]; then + run_isolated \ + env WSJTX_VERSION="3.2.0-devel" HAMLIB_BRANCH="4.7.2" \ + WSJT_RELEASE_CHANNEL="DEVEL" WSJT_RC_NUMBER="" \ + >/dev/null + run_isolated \ + env WSJTX_VERSION="3.0.1-rc1" HAMLIB_BRANCH="4.7.2" \ + WSJT_RELEASE_CHANNEL="RC" WSJT_RC_NUMBER="1" \ + ARCH="x86_64" DEPLOYMENT_TARGET="10.13" RUNNER="macos-15-intel" \ + IMAGE_TAG="candidate-123-1" \ + VALIDATE_FORTRAN_FALLBACK="true" \ + >/dev/null + run_isolated env HAMLIB_BRANCH="integration/4.7" VALIDATE_FORTRAN_FALLBACK="false" >/dev/null + + expect_failure 'command substitution in version' WSJTX_VERSION='3.1.0$(id)' + expect_failure 'backticks in version' WSJTX_VERSION='3.1.0`id`' + expect_failure 'quote break in version' WSJTX_VERSION='3.1.0"; echo pwned #' + expect_failure 'command substitution in hamlib_branch' HAMLIB_BRANCH='4.7.2$(touch /tmp/x)' + expect_failure 'shell metacharacters in hamlib_branch' HAMLIB_BRANCH='4.7.2; id' + expect_failure 'invalid channel' WSJT_RELEASE_CHANNEL='dev' + expect_failure 'non-numeric rc' WSJT_RC_NUMBER='1a' + expect_failure 'empty version' WSJTX_VERSION='' + expect_failure 'invalid arch' ARCH='x86_64; id' + expect_failure 'slash in image tag' IMAGE_TAG='candidate/unsafe' + expect_failure 'leading punctuation in image tag' IMAGE_TAG='-candidate' + expect_failure 'empty image tag' IMAGE_TAG='' + expect_failure 'overlong image tag' IMAGE_TAG="$(printf 'a%.0s' {1..129})" + expect_failure 'command substitution in deployment_target' DEPLOYMENT_TARGET='11.0$(id)' + expect_failure 'empty fallback boolean' VALIDATE_FORTRAN_FALLBACK='' + expect_failure 'uppercase fallback boolean' VALIDATE_FORTRAN_FALLBACK='TRUE' + expect_failure 'numeric fallback boolean' VALIDATE_FORTRAN_FALLBACK='1' + expect_failure 'shell payload in fallback boolean' VALIDATE_FORTRAN_FALLBACK='true$(id)' + + echo "validate-ci-inputs.sh self-test passed" + exit 0 +fi + +validate_inputs diff --git a/.github/scripts/validate-linux-armhf-runtime.sh b/.github/scripts/validate-linux-armhf-runtime.sh new file mode 100755 index 00000000..0909d512 --- /dev/null +++ b/.github/scripts/validate-linux-armhf-runtime.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash +set -euo pipefail + +VERSION="${VERSION:?missing}" +ARCH="${ARCH:?missing}" +HAMLIB_BRANCH="${HAMLIB_BRANCH:?missing}" +phase=${ARMHF_RUNTIME_PHASE:-all} +if [ "$ARCH" != armhf ]; then + echo "validate-linux-armhf-runtime.sh supports only arch=armhf" >&2 + exit 2 +fi +case "$phase" in + all|test|package) ;; + *) echo "Unsupported ARMHF runtime phase: $phase" >&2; exit 2 ;; +esac + +github_api_token="${GITHUB_TOKEN:-}" +unset GITHUB_TOKEN +cd /work +# shellcheck source=.github/scripts/armhf-ci-image-config.sh +source .github/scripts/armhf-ci-image-config.sh +.github/scripts/verify-armhf-ci-image.sh runtime "$ARCH" "$HAMLIB_BRANCH" + +if [ "$phase" = all ] || [ "$phase" = test ]; then + echo "::group::ARMHF CTest under QEMU" + started="$(date +%s)" + set +e + ( + cd wsjtx-build + LD_LIBRARY_PATH="$ARMHF_RUNTIME_PREFIX" \ + QT_QPA_PLATFORM=xcb \ + xvfb-run -a -s "-screen 0 1280x1024x24" \ + ctest --output-on-failure --output-junit ctest-results.xml + ) 2>&1 | tee wsjtx-build/ctest-armhf.log + status=${PIPESTATUS[0]} + set -e + ended="$(date +%s)" + { + printf 'started_epoch=%s\n' "$started" + printf 'ended_epoch=%s\n' "$ended" + printf 'duration_seconds=%s\n' "$((ended - started))" + printf 'status=%s\n' "$status" + } > wsjtx-build/armhf-ctest-timing.env + echo "::endgroup::" + if [ "$status" -ne 0 ]; then + exit "$status" + fi +fi + +if [ "$phase" = all ] || [ "$phase" = package ]; then + started="$(date +%s)" + set +e + GITHUB_TOKEN="$github_api_token" .github/scripts/package-linux-armhf.sh + status=$? + set -e + ended="$(date +%s)" + { + printf 'started_epoch=%s\n' "$started" + printf 'ended_epoch=%s\n' "$ended" + printf 'duration_seconds=%s\n' "$((ended - started))" + printf 'status=%s\n' "$status" + } > wsjtx-build/armhf-package-timing.env + if [ "$status" -ne 0 ]; then + exit "$status" + fi +fi diff --git a/.github/scripts/validate-workflow-timeouts.py b/.github/scripts/validate-workflow-timeouts.py new file mode 100755 index 00000000..256f5782 --- /dev/null +++ b/.github/scripts/validate-workflow-timeouts.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python3 + +import re +import sys +from pathlib import Path + + +JOB_PATTERN = re.compile( + r"^ (?P<quote>[\"']?)(?P<name>[A-Za-z_][A-Za-z0-9_-]*)(?P=quote):" + r"(?:\s+&[A-Za-z_][A-Za-z0-9_-]*)?(?:\s*#.*)?$" +) + + +def unbounded_jobs(path: Path) -> list[str]: + failures: list[str] = [] + in_jobs = False + job_name: str | None = None + job_line = 0 + has_runner = False + has_timeout = False + + def finish_job() -> None: + if job_name is not None and has_runner and not has_timeout: + failures.append(f"{path}:{job_line}: job '{job_name}' has runs-on but no timeout-minutes") + + for line_number, line in enumerate(path.read_text().splitlines(), start=1): + if line == "jobs:": + in_jobs = True + continue + if not in_jobs: + continue + if line and not line[0].isspace() and not line.startswith("#"): + finish_job() + break + + match = JOB_PATTERN.match(line) + if match: + finish_job() + job_name = match.group("name") + job_line = line_number + has_runner = False + has_timeout = False + elif ( + line.startswith(" ") + and not line.startswith(" ") + and line.strip() + and not line.lstrip().startswith("#") + ): + finish_job() + failures.append(f"{path}:{line_number}: unsupported job declaration; timeout cannot be verified") + job_name = None + has_runner = False + has_timeout = False + elif job_name is not None: + has_runner = has_runner or line.startswith(" runs-on:") + has_timeout = has_timeout or line.startswith(" timeout-minutes:") + else: + finish_job() + + return failures + + +def main() -> int: + workflow_dir = Path(".github/workflows") + workflows = sorted((*workflow_dir.glob("*.yml"), *workflow_dir.glob("*.yaml"))) + failures = [failure for path in workflows for failure in unbounded_jobs(path)] + if failures: + print("Every runner-backed GitHub Actions job must define timeout-minutes:", file=sys.stderr) + print("\n".join(failures), file=sys.stderr) + return 1 + print(f"Validated explicit timeouts for runner-backed jobs in {len(workflows)} workflows") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/.github/scripts/verify-armhf-ci-image.sh b/.github/scripts/verify-armhf-ci-image.sh new file mode 100755 index 00000000..b6746269 --- /dev/null +++ b/.github/scripts/verify-armhf-ci-image.sh @@ -0,0 +1,253 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -ne 3 ]; then + echo "Usage: verify-armhf-ci-image.sh ROLE ARCH HAMLIB_REF" >&2 + exit 2 +fi + +expected_role=$1 +expected_arch=$2 +expected_hamlib_ref=$3 +manifest=${WSJTX_CI_IMAGE_MANIFEST:-/opt/wsjtx-ci/image.env} +config_dir=/usr/local/share/wsjtx-ci +if [ ! -f "$config_dir/armhf-ci-image-config.sh" ]; then + config_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +fi +# shellcheck source=.github/scripts/armhf-ci-image-config.sh +. "$config_dir/armhf-ci-image-config.sh" + +if [ ! -f "$manifest" ]; then + echo "ARMHF CI image manifest not found: $manifest" >&2 + exit 1 +fi +declare schema='' role='' architecture='' generation='' recipe_sha256='' +declare compiler_version='' compiler_target='' compiler_sha256='' +declare compiler_signature_sha256='' ccache_compatibility_id='' toolchain_id='' +declare host_dpkg_arch='' package_sha256='' sysroot_package_sha256='' runtime_sha256='' +declare hamlib_ref='' hamlib_commit='' hamlib_sha256='' glibc_version='' +declare binutils_version='' linux_headers_version='' minimum_kernel_version='' +declare quadmath_runtime='' cross_generation='' cross_recipe_sha256='' cross_toolchain_id='' +# shellcheck disable=SC1090 +. "$manifest" + +require_equal() { + local field=$1 expected=$2 actual=$3 + if [ "$actual" != "$expected" ]; then + echo "ARMHF CI image $field mismatch: expected $expected, got $actual" >&2 + exit 1 + fi +} + +require_sha256() { + local field=$1 value=$2 + if [[ ! "$value" =~ ^[0-9a-f]{64}$ ]]; then + echo "ARMHF CI image $field is not a SHA-256 value: ${value:-missing}" >&2 + exit 1 + fi +} + +hash_package_set() { + dpkg-query -W -f='${binary:Package}=${Version}\n' | + LC_ALL=C sort | + sha256sum | + awk '{print $1}' +} + +hash_runtime_set() { + local library records="" + for library in "${ARMHF_GCC_RUNTIME_LIBRARIES[@]}"; do + test -f "$ARMHF_RUNTIME_PREFIX/$library" + records+="$library=$(sha256sum "$ARMHF_RUNTIME_PREFIX/$library" | awk '{print $1}')"$'\n' + done + printf '%s' "$records" | sha256sum | awk '{print $1}' +} + +require_armhf_elf() { + local path=$1 metadata headers attributes + metadata="$(file -L "$path")" + headers="$(readelf -hW "$path")" + attributes="$(readelf -AW "$path")" + case "$metadata:$headers:$attributes" in + *"ELF 32-bit"*"ARM, EABI5"*"hard-float ABI"*"Tag_ABI_VFP_args: VFP registers"*) ;; + *) + echo "Expected ARM EABI5 hard-float ELF: $path" >&2 + echo "$metadata" >&2 + exit 1 + ;; + esac +} + +verify_glibc_ceiling() { + local path=$1 versions maximum + versions="$(readelf --version-info -W "$path")" + maximum="$( + awk ' + { + remaining = $0 + while (match(remaining, /GLIBC_[0-9]+\.[0-9]+/)) { + version = substr(remaining, RSTART + 6, RLENGTH - 6) + split(version, parts, ".") + if (parts[1] > major || (parts[1] == major && parts[2] > minor)) { + major = parts[1] + minor = parts[2] + } + remaining = substr(remaining, RSTART + RLENGTH) + } + } + END { printf "%d.%d\n", major, minor } + ' <<< "$versions" + )" + if dpkg --compare-versions "$maximum" gt "$ARMHF_GLIBC_VERSION"; then + echo "$path requires GLIBC_$maximum, newer than Bookworm GLIBC_$ARMHF_GLIBC_VERSION" >&2 + exit 1 + fi +} + +reject_quadmath_dependency() { + local path=$1 dynamic + dynamic="$(readelf -dW "$path")" + if [[ "$dynamic" == *"Shared library: [libquadmath.so"* ]]; then + echo "$path unexpectedly depends on libquadmath" >&2 + exit 1 + fi +} + +reject_private_glibc_dependency() { + local path=$1 versions + versions="$(readelf --version-info -W "$path")" + if [[ "$versions" == *"GLIBC_PRIVATE"* ]]; then + echo "$path unexpectedly depends on a private glibc symbol" >&2 + exit 1 + fi +} + +require_equal schema "$ARMHF_CI_IMAGE_SCHEMA" "${schema:-}" +require_equal role "$expected_role" "${role:-}" +require_equal architecture "$expected_arch" "${architecture:-}" +require_equal hamlib_ref "$expected_hamlib_ref" "${hamlib_ref:-}" +require_equal glibc_version "$ARMHF_GLIBC_VERSION" "${glibc_version:-}" +require_equal quadmath_runtime unavailable-on-arm "${quadmath_runtime:-}" +require_sha256 recipe_sha256 "${recipe_sha256:-}" +require_sha256 package_sha256 "${package_sha256:-}" +require_sha256 runtime_sha256 "${runtime_sha256:-}" + +profile=armhf-cross-bookworm +if [ "$expected_role" = runtime ]; then + profile=armhf-runtime-bookworm +fi +if [ -n "${IMAGE_RECIPE_SHA256:-}" ]; then + expected_recipe=$IMAGE_RECIPE_SHA256 +else + expected_recipe="$(.github/scripts/linux-ci-image-fingerprint.sh "$profile")" +fi +recipe_match=true +if [ "${WSJTX_CI_IMAGE_ALLOW_RECIPE_MISMATCH:-false}" = true ] && + [ "$recipe_sha256" != "$expected_recipe" ]; then + echo "::warning::ARMHF $expected_role image recipe differs from this checkout; using its retained immutable generation" >&2 + recipe_match=false +else + require_equal recipe_sha256 "$expected_recipe" "$recipe_sha256" +fi + +actual_package_sha256="$(hash_package_set)" +require_equal package_sha256 "$package_sha256" "$actual_package_sha256" +require_equal runtime_sha256 "$runtime_sha256" "$(hash_runtime_set)" +for library in "${ARMHF_GCC_RUNTIME_LIBRARIES[@]}"; do + require_armhf_elf "$ARMHF_RUNTIME_PREFIX/$library" + verify_glibc_ceiling "$ARMHF_RUNTIME_PREFIX/$library" + reject_quadmath_dependency "$ARMHF_RUNTIME_PREFIX/$library" + reject_private_glibc_dependency "$ARMHF_RUNTIME_PREFIX/$library" +done + +case "$expected_role" in + cross-builder) + compiler="$ARMHF_TOOLCHAIN_PREFIX/bin/$ARMHF_TARGET_TRIPLET-gcc" + require_equal host_dpkg_arch amd64 "${host_dpkg_arch:-}" + require_equal compiler_version "$ARMHF_GCC_VERSION" "${compiler_version:-}" + require_equal compiler_target "$ARMHF_TARGET_TRIPLET" "${compiler_target:-}" + require_equal binutils_version "$ARMHF_BINUTILS_VERSION" "${binutils_version:-}" + require_equal linux_headers_version "$ARMHF_LINUX_HEADERS_VERSION" "${linux_headers_version:-}" + require_equal minimum_kernel_version "$ARMHF_MIN_KERNEL_VERSION" "${minimum_kernel_version:-}" + require_equal compiler_version "$compiler_version" "$($compiler -dumpfullversion -dumpversion)" + require_equal compiler_target "$compiler_target" "$($compiler -dumpmachine)" + compiler_metadata="$(file -L "$compiler")" + case "$compiler_metadata" in + *"ELF 64-bit"*"x86-64"*) ;; + *) echo "Cross compiler is not a native x86-64 executable: $compiler_metadata" >&2; exit 1 ;; + esac + signature_helper="$config_dir/linux-ccache-compiler-signature.sh" + IFS=$'\t' read -r actual_version actual_target actual_sha256 \ + actual_ccache_id actual_signature < <("$signature_helper" "$compiler") + require_equal compiler_version "$compiler_version" "$actual_version" + require_equal compiler_target "$compiler_target" "$actual_target" + require_equal compiler_sha256 "$compiler_sha256" "$actual_sha256" + require_equal ccache_compatibility_id "$ccache_compatibility_id" "$actual_ccache_id" + require_equal compiler_signature_sha256 "$compiler_signature_sha256" "$actual_signature" + require_equal sysroot_package_sha256 "$sysroot_package_sha256" \ + "$(sha256sum /opt/wsjtx-ci/armhf-sysroot-packages.txt | awk '{print $1}')" + require_equal hamlib_commit "$LINUX_HAMLIB_COMMIT" "${hamlib_commit:-}" + require_equal hamlib_sha256 "$hamlib_sha256" \ + "$(sha256sum "$ARMHF_SYSROOT/usr/lib/libhamlib.a" | awk '{print $1}')" + for target_file in \ + "$ARMHF_SYSROOT/usr/bin/rigctl" \ + "$ARMHF_SYSROOT/usr/bin/rigctld" \ + "$ARMHF_SYSROOT/usr/bin/rigctlcom" \ + "$ARMHF_SYSROOT/usr/lib/$ARMHF_TARGET_TRIPLET/libQt5Core.so.5" \ + "$ARMHF_SYSROOT/usr/lib/$ARMHF_TARGET_TRIPLET/qt5/plugins/platforms/libqxcb.so"; do + require_armhf_elf "$target_file" + reject_quadmath_dependency "$target_file" + reject_private_glibc_dependency "$target_file" + done + for smoke in /opt/wsjtx-ci/toolchain-smoke/*-smoke; do + require_armhf_elf "$smoke" + reject_quadmath_dependency "$smoke" + reject_private_glibc_dependency "$smoke" + done + ;; + runtime) + require_equal host_dpkg_arch armhf "$(dpkg --print-architecture)" + require_equal cross_generation "$generation" "${cross_generation:-}" + require_sha256 cross_recipe_sha256 "${cross_recipe_sha256:-}" + if [ -e /opt/wsjtx/hamlib ]; then + echo "ARMHF runtime image must not provide the build-image Hamlib prefix" >&2 + exit 1 + fi + qemu_metadata="$(file -L "$ARMHF_QEMU_EXECUTABLE")" + case "$qemu_metadata" in + *"ELF 64-bit"*"x86-64"*) ;; + *) echo "ARMHF AppImage QEMU helper is not x86-64: $qemu_metadata" >&2; exit 1 ;; + esac + for plugin in \ + /usr/lib/arm-linux-gnueabihf/qt5/plugins/platforms/libqxcb.so \ + /usr/lib/arm-linux-gnueabihf/qt5/plugins/sqldrivers/libqsqlite.so; do + require_armhf_elf "$plugin" + done + for smoke in /opt/wsjtx-ci/toolchain-smoke/*-smoke; do + require_armhf_elf "$smoke" + reject_quadmath_dependency "$smoke" + reject_private_glibc_dependency "$smoke" + LD_LIBRARY_PATH="$ARMHF_RUNTIME_PREFIX" OMP_NUM_THREADS=2 "$smoke" + done + ;; + *) + echo "Unsupported ARMHF image role: $expected_role" >&2 + exit 2 + ;; +esac + +echo "ARMHF CI image: $role ${generation:-unknown} (${toolchain_id:-${cross_toolchain_id:-unknown}})" +if [ -n "${GITHUB_OUTPUT:-}" ]; then + output_prefix=${WSJTX_CI_OUTPUT_PREFIX:-} + { + printf '%sgeneration=%s\n' "$output_prefix" "$generation" + printf '%srecipe_match=%s\n' "$output_prefix" "$recipe_match" + if [ "$expected_role" = cross-builder ]; then + printf '%stoolchain_id=%s\n' "$output_prefix" "$toolchain_id" + printf '%sccache_compatibility_id=%s\n' "$output_prefix" "$ccache_compatibility_id" + printf '%sccache_compiler_check=string:%s\n' "$output_prefix" "$compiler_signature_sha256" + else + printf '%stoolchain_id=%s\n' "$output_prefix" "$cross_toolchain_id" + fi + } >> "$GITHUB_OUTPUT" +fi diff --git a/.github/scripts/verify-linux-ci-image.sh b/.github/scripts/verify-linux-ci-image.sh new file mode 100755 index 00000000..dc03dbe4 --- /dev/null +++ b/.github/scripts/verify-linux-ci-image.sh @@ -0,0 +1,268 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -ne 3 ]; then + echo "Usage: verify-linux-ci-image.sh FLAVOR ARCH HAMLIB_REF" >&2 + exit 2 +fi + +expected_flavor=$1 +expected_arch=$2 +expected_hamlib_ref=$3 +manifest=${WSJTX_CI_IMAGE_MANIFEST:-/opt/wsjtx-ci/image.env} +image_prefix=${WSJTX_CI_PREFIX_OVERRIDE:-/opt/wsjtx} + +config_dir=/usr/local/share/wsjtx-ci +if [ ! -f "$config_dir/linux-ci-image-config.sh" ]; then + config_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +fi +# shellcheck source=.github/scripts/linux-ci-image-config.sh +. "$config_dir/linux-ci-image-config.sh" +if [ "$expected_flavor" = tsan ]; then + # shellcheck source=.github/scripts/tsan-linux-deps-config.sh + . "$config_dir/tsan-linux-deps-config.sh" +fi + +if [ ! -f "$manifest" ]; then + echo "Linux CI image manifest not found: $manifest" >&2 + exit 1 +fi + +# shellcheck disable=SC1090 +. "$manifest" + +require_equal() { + local field=$1 expected=$2 actual=$3 + if [ "$actual" != "$expected" ]; then + echo "Linux CI image $field mismatch: expected $expected, got $actual" >&2 + exit 1 + fi +} + +require_sha256() { + local field=$1 value=$2 + if [[ ! "$value" =~ ^[0-9a-f]{64}$ ]]; then + echo "Linux CI image $field is not a SHA-256 value: ${value:-missing}" >&2 + exit 1 + fi +} + +require_key_component() { + local field=$1 value=$2 + if [[ ! "$value" =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ ]]; then + echo "Linux CI image $field is not a safe cache-key component: ${value:-missing}" >&2 + exit 1 + fi +} + +require_equal schema 1 "${schema:-}" +require_equal flavor "$expected_flavor" "${flavor:-}" +require_equal architecture "$expected_arch" "${architecture:-}" +require_equal hamlib_ref "$expected_hamlib_ref" "${hamlib_ref:-}" +require_key_component generation "${generation:-}" + +case "$expected_flavor" in + normal) + expected_compiler=gcc + require_equal hamlib_commit "$LINUX_HAMLIB_COMMIT" "${hamlib_commit:-}" + require_equal pfunit_version "$LINUX_PFUNIT_VERSION" "${pfunit_version:-}" + require_equal pfunit_commit "$LINUX_PFUNIT_COMMIT" "${pfunit_commit:-}" + profile=normal-noble + if [ "$expected_arch" != x86_64 ]; then + profile=normal-bookworm + fi + pfunit_config="$(find "$image_prefix/pfunit" -name PFUNITConfig.cmake -print -quit)" + if [ -z "$pfunit_config" ]; then + echo "PFUNITConfig.cmake not found in the Linux CI image" >&2 + exit 1 + fi + test -f "$image_prefix/hamlib/lib/libhamlib.a" + if [ "${WSJTX_CI_IMAGE_SKIP_RUNTIME_CHECKS:-false}" != true ]; then + qt_core_config="$(find /usr -path '*/cmake/Qt5Core/Qt5CoreConfig.cmake' -print -quit)" + qt_multimedia_config="$(find /usr -path '*/cmake/Qt5Multimedia/Qt5MultimediaConfig.cmake' -print -quit)" + qt_plugin="$(find /usr -path '*/plugins/platforms/*' -type f -print -quit)" + test -n "$qt_core_config" + test -n "$qt_multimedia_config" + test -n "$qt_plugin" + fi + pfunit_dir="$(dirname "$pfunit_config")" + hamlib_prefix=$image_prefix/hamlib + ;; + tsan) + expected_compiler=gcc-13 + profile=tsan-noble + hamlib_prefix=$image_prefix/tsan/hamlib + require_equal hamlib_commit "$TSAN_HAMLIB_COMMIT" "${hamlib_commit:-}" + require_equal hamlib_patch_commit "$TSAN_HAMLIB_PATCH_COMMIT" "${hamlib_patch_commit:-}" + require_equal qt_version "$TSAN_QT_VERSION" "${qt_version:-}" + require_equal boost_version "$TSAN_BOOST_VERSION" "${boost_version:-}" + "$config_dir/verify-tsan-deps-linux.sh" \ + "$image_prefix/tsan/qt" "$image_prefix/tsan/boost" "$image_prefix/tsan/hamlib" + boost_config="$(find "$image_prefix/tsan/boost" -name BoostConfig.cmake -print -quit)" + test -n "$boost_config" + if [ "${WSJTX_CI_IMAGE_SKIP_RUNTIME_CHECKS:-false}" != true ]; then + test -d "$image_prefix/tsan/qt/plugins" + test -n "$(find "$image_prefix/tsan/qt/plugins" -type f -print -quit)" + fi + ;; + *) + echo "Unsupported Linux CI image flavor: $expected_flavor" >&2 + exit 2 + ;; +esac + +if [ -n "${IMAGE_RECIPE_SHA256:-}" ]; then + expected_recipe=$IMAGE_RECIPE_SHA256 +else + expected_recipe="$(.github/scripts/linux-ci-image-fingerprint.sh "$profile")" +fi +toolchain_recipe=$expected_recipe +recipe_match=true +if [ "${WSJTX_CI_IMAGE_ALLOW_RECIPE_MISMATCH:-false}" = true ] && + [ "${recipe_sha256:-}" != "$expected_recipe" ]; then + echo "::warning::Linux CI image recipe fingerprint differs from this checkout; using the last known-good image generation" >&2 + if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then + { + echo "### Linux CI image fallback" + echo + echo "This job used a previously promoted image while the dependency refresh was in progress." + echo + echo "- Image recipe in the image: \`${recipe_sha256:-missing}\`" + echo "- Recipe in this checkout: \`$expected_recipe\`" + } >> "$GITHUB_STEP_SUMMARY" + fi + toolchain_recipe=${recipe_sha256:-} + recipe_match=false +else + require_equal recipe_sha256 "$expected_recipe" "${recipe_sha256:-}" +fi +require_equal compiler "$expected_compiler" "${compiler:-}" +test -n "${compiler:-}" +test -n "${compiler_version:-}" +test -n "${compiler_sha256:-}" +test -n "${compiler_target:-}" +test -n "${package_sha256:-}" +require_key_component toolchain_id "${toolchain_id:-}" +if [[ ! "${compiler_version:-}" =~ ^[0-9]+([.][0-9]+)*$ ]]; then + echo "Linux CI image compiler_version is invalid: ${compiler_version:-missing}" >&2 + exit 1 +fi +require_key_component compiler_target "${compiler_target:-}" +require_sha256 compiler_sha256 "${compiler_sha256:-}" +require_sha256 package_sha256 "${package_sha256:-}" +require_sha256 recipe_sha256 "${recipe_sha256:-}" + +if [ "$recipe_match" = true ]; then + compiler_major=${compiler_version%%.*} + require_equal ccache_compatibility_id \ + "gcc${compiler_major}-v2" "${ccache_compatibility_id:-}" + require_key_component ccache_compatibility_id "$ccache_compatibility_id" + require_sha256 compiler_signature_sha256 "${compiler_signature_sha256:-}" + verified_ccache_compatibility_id=$ccache_compatibility_id + verified_ccache_compiler_check="string:$compiler_signature_sha256" +else + verified_ccache_compatibility_id=$toolchain_id + verified_ccache_compiler_check=mtime +fi + +if [ "${WSJTX_CI_IMAGE_SKIP_RUNTIME_CHECKS:-false}" != true ]; then + compiler_path="$(readlink -f "$(command -v "$compiler")")" + require_equal dpkg_arch "$(dpkg --print-architecture)" "${dpkg_arch:-}" + require_equal compiler_version "$compiler_version" "$($compiler -dumpfullversion -dumpversion)" + require_equal compiler_target "$compiler_target" "$($compiler -dumpmachine)" + require_equal compiler_sha256 "$compiler_sha256" "$(sha256sum "$compiler_path" | awk '{print $1}')" + actual_package_sha256="$(dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort | sha256sum | awk '{print $1}')" + require_equal package_sha256 "$package_sha256" "$actual_package_sha256" + toolchain_identity="$toolchain_recipe:$compiler_target:$compiler_sha256:$package_sha256" + toolchain_sha256="$(printf '%s' "$toolchain_identity" | sha256sum | awk '{print $1}')" + require_equal toolchain_id "$toolchain_id" "gcc${compiler_version}-${expected_arch}-${toolchain_sha256:0:20}" + + if [ "$recipe_match" = true ]; then + signature_helper="$config_dir/linux-ccache-compiler-signature.sh" + if [ ! -x "$signature_helper" ]; then + echo "Linux ccache compiler signature helper not found: $signature_helper" >&2 + exit 1 + fi + IFS=$'\t' read -r actual_compiler_version actual_compiler_target \ + actual_compiler_sha256 actual_ccache_compatibility_id \ + actual_compiler_signature_sha256 \ + < <("$signature_helper" "$compiler") + require_equal compiler_version "$compiler_version" "$actual_compiler_version" + require_equal compiler_target "$compiler_target" "$actual_compiler_target" + require_equal compiler_sha256 "$compiler_sha256" "$actual_compiler_sha256" + require_equal ccache_compatibility_id "$ccache_compatibility_id" \ + "$actual_ccache_compatibility_id" + require_equal compiler_signature_sha256 "$compiler_signature_sha256" \ + "$actual_compiler_signature_sha256" + fi +fi + +if [ "${WSJTX_CI_IMAGE_SKIP_RUNTIME_CHECKS:-false}" != true ]; then + smoke_dir="$(mktemp -d)" + cat > "$smoke_dir/CMakeLists.txt" <<'EOF' +cmake_minimum_required(VERSION 3.16) +project(wsjt_ci_image_smoke LANGUAGES CXX) + +find_package(Qt5 REQUIRED COMPONENTS Core) +find_package(Boost REQUIRED COMPONENTS log_setup log) +find_package(PkgConfig REQUIRED) +set(PKG_CONFIG_USE_STATIC_LIBS TRUE) +pkg_check_modules(HAMLIB REQUIRED IMPORTED_TARGET hamlib) + +add_executable(wsjt_ci_image_smoke main.cpp) +target_include_directories(wsjt_ci_image_smoke PRIVATE "${WSJTX_HAMLIB_PREFIX}/include") +target_link_libraries(wsjt_ci_image_smoke PRIVATE Qt5::Core Boost::log_setup Boost::log PkgConfig::HAMLIB) +EOF + cat > "$smoke_dir/main.cpp" <<'EOF' +#include <QCoreApplication> +#include <boost/log/trivial.hpp> +#include <hamlib/rig.h> + +int main(int argc, char **argv) +{ + QCoreApplication application(argc, argv); + BOOST_LOG_TRIVIAL(info) << "WSJT-X CI image smoke test"; + return 0; +} +EOF + + cmake_args=( + -S "$smoke_dir" + -B "$smoke_dir/build" + -DCMAKE_BUILD_TYPE=Release + "-DWSJTX_HAMLIB_PREFIX=$hamlib_prefix" + ) + if [ "$expected_flavor" = tsan ]; then + cmake_args+=( + "-DCMAKE_PREFIX_PATH=$image_prefix/tsan/qt;$image_prefix/tsan/boost;$image_prefix/tsan/hamlib" + "-DBOOST_ROOT=$image_prefix/tsan/boost" + -DBoost_NO_SYSTEM_PATHS=ON + -DCMAKE_CXX_FLAGS=-fsanitize=thread + -DCMAKE_EXE_LINKER_FLAGS=-fsanitize=thread + ) + fi + export PKG_CONFIG_PATH="$hamlib_prefix/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}" + cmake "${cmake_args[@]}" + cmake --build "$smoke_dir/build" --parallel "$(nproc)" + rm -rf "$smoke_dir" +fi + +echo "Linux CI image: ${generation:-unknown} (${toolchain_id:-unknown}; ccache ${verified_ccache_compatibility_id:-unknown})" + +if [ -n "${GITHUB_OUTPUT:-}" ]; then + { + printf 'generation=%s\n' "$generation" + printf 'toolchain_id=%s\n' "$toolchain_id" + printf 'ccache_compatibility_id=%s\n' "$verified_ccache_compatibility_id" + printf 'ccache_compiler_check=%s\n' "$verified_ccache_compiler_check" + printf 'recipe_match=%s\n' "$recipe_match" + if [ "$expected_flavor" = normal ]; then + printf 'pfunit_dir=%s\n' "$pfunit_dir" + printf 'hamlib_prefix=%s\n' "$hamlib_prefix" + else + printf 'qt_prefix=%s\n' "$image_prefix/tsan/qt" + printf 'boost_prefix=%s\n' "$image_prefix/tsan/boost" + printf 'hamlib_prefix=%s\n' "$image_prefix/tsan/hamlib" + fi + } >> "$GITHUB_OUTPUT" +fi diff --git a/.github/scripts/verify-macos-artifacts.sh b/.github/scripts/verify-macos-artifacts.sh index 954c54e9..981e60d6 100755 --- a/.github/scripts/verify-macos-artifacts.sh +++ b/.github/scripts/verify-macos-artifacts.sh @@ -88,7 +88,9 @@ version_gt() { is_macho() { local file="$1" - file "$file" 2>/dev/null | grep -Eq 'Mach-O|universal binary' + local file_type + file_type=$(file "$file" 2>/dev/null || true) + [[ "$file_type" == *"Mach-O"* || "$file_type" == *"universal binary"* ]] } is_allowed_reference() { @@ -124,10 +126,13 @@ check_file() { echo "::error file=${file}::Could not determine Mach-O architecture" return 1 fi - if ! printf '%s\n' "$archs" | tr ' ' '\n' | grep -qx "$arch"; then + case " ${archs} " in + *" ${arch} "*) ;; + *) echo "::error file=${file}::Expected architecture ${arch}, found: ${archs}" return 1 - fi + ;; + esac minos=$(otool -arch "$arch" -l "$file" 2>/dev/null | awk ' /LC_BUILD_VERSION/ { in_build = 1; next } diff --git a/.github/scripts/verify-macos-static-archives.sh b/.github/scripts/verify-macos-static-archives.sh index 2c20875e..419e0674 100755 --- a/.github/scripts/verify-macos-static-archives.sh +++ b/.github/scripts/verify-macos-static-archives.sh @@ -116,9 +116,14 @@ check_archive() { fi archs=$(lipo -archs "$archive" 2>/dev/null || true) - if [ -n "$archs" ] && ! printf '%s\n' "$archs" | tr ' ' '\n' | grep -qx "$arch"; then - echo "::error file=${archive}::Expected architecture ${arch}, found: ${archs}" - structural_fail=1 + if [ -n "$archs" ]; then + case " ${archs} " in + *" ${arch} "*) ;; + *) + echo "::error file=${archive}::Expected architecture ${arch}, found: ${archs}" + structural_fail=1 + ;; + esac fi while IFS= read -r line; do diff --git a/.github/scripts/verify-sanitizer-instrumentation.py b/.github/scripts/verify-sanitizer-instrumentation.py new file mode 100755 index 00000000..6f5279b9 --- /dev/null +++ b/.github/scripts/verify-sanitizer-instrumentation.py @@ -0,0 +1,136 @@ +#!/usr/bin/env python3 + +import argparse +import json +import subprocess +from pathlib import Path + + +SANITIZERS = { + "asan-ubsan": { + "flag": "-fsanitize=address,undefined", + "symbols": ("__asan_", "__ubsan_"), + "runtimes": ("libasan.so", "libubsan.so"), + }, + "tsan": { + "flag": "-fsanitize=thread", + "symbols": ("__tsan_",), + "runtimes": ("libtsan.so",), + }, +} +LANGUAGE_SUFFIXES = { + "C": {".c"}, + "C++": {".cc", ".cpp", ".cxx"}, + "Fortran": {".f", ".f03", ".f08", ".f90", ".f95", ".for", ".ftn"}, +} + + +def fail(message): + raise SystemExit(f"ERROR: {message}") + + +def command_text(entry): + if "command" in entry: + return entry["command"] + return " ".join(entry.get("arguments", [])) + + +def require_file(path): + if not path.is_file(): + fail(f"expected build artifact is missing: {path}") + + +def tool_output(*arguments): + result = subprocess.run( + arguments, + check=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + ) + return result.stdout + + +def verify_compile_commands(build_dir, sanitizer_flag): + commands_path = build_dir / "compile_commands.json" + require_file(commands_path) + commands = json.loads(commands_path.read_text(encoding="utf-8")) + + language_counts = {language: 0 for language in LANGUAGE_SUFFIXES} + uninstrumented = [] + for entry in commands: + suffix = Path(entry.get("file", "")).suffix.lower() + for language, suffixes in LANGUAGE_SUFFIXES.items(): + if suffix not in suffixes: + continue + language_counts[language] += 1 + if sanitizer_flag not in command_text(entry): + uninstrumented.append(entry.get("file", "<unknown>")) + + missing_languages = [ + language for language, count in language_counts.items() if count == 0 + ] + if missing_languages: + fail( + "no compile commands were found for: " + ", ".join(missing_languages) + ) + if uninstrumented: + examples = ", ".join(uninstrumented[:10]) + suffix = "" if len(uninstrumented) <= 10 else ", ..." + fail(f"compile commands without sanitizer instrumentation: {examples}{suffix}") + return language_counts + + +def verify_archive(path, symbol): + require_file(path) + symbols = tool_output("nm", "-A", "--undefined-only", str(path)) + if symbol not in symbols: + fail(f"{path.name} has no reference to {symbol}") + + +def verify_link(build_dir, target, sanitizer_flag, runtimes): + link_command_path = build_dir / "CMakeFiles" / f"{target}.dir" / "link.txt" + executable_path = build_dir / target + require_file(link_command_path) + require_file(executable_path) + + if sanitizer_flag not in link_command_path.read_text(encoding="utf-8"): + fail(f"{target} final link command does not contain {sanitizer_flag}") + + dynamic_section = tool_output("readelf", "-d", str(executable_path)) + for runtime in runtimes: + if runtime not in dynamic_section: + fail(f"{target} does not declare a dependency on {runtime}") + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("build_dir", type=Path) + parser.add_argument( + "--sanitizer", choices=SANITIZERS, default="asan-ubsan" + ) + args = parser.parse_args() + + build_dir = args.build_dir.resolve() + if not build_dir.is_dir(): + fail(f"build directory does not exist: {build_dir}") + + sanitizer = SANITIZERS[args.sanitizer] + language_counts = verify_compile_commands(build_dir, sanitizer["flag"]) + for symbol in sanitizer["symbols"]: + verify_archive(build_dir / "libwsjt_cxx.a", symbol) + verify_archive(build_dir / "libwsjt_fort_omp.a", symbol) + verify_link(build_dir, "jt9", sanitizer["flag"], sanitizer["runtimes"]) + verify_link(build_dir, "wsjtx", sanitizer["flag"], sanitizer["runtimes"]) + + print("Sanitizer instrumentation verified") + compile_summary = ", ".join( + f"{language}={count}" for language, count in language_counts.items() + ) + print(f" compile commands: {compile_summary}") + print(" static archives: libwsjt_cxx.a, libwsjt_fort_omp.a") + print(" final executables: jt9, wsjtx") + + +if __name__ == "__main__": + main() diff --git a/.github/scripts/verify-tsan-deps-linux.sh b/.github/scripts/verify-tsan-deps-linux.sh new file mode 100755 index 00000000..54e2ed2f --- /dev/null +++ b/.github/scripts/verify-tsan-deps-linux.sh @@ -0,0 +1,138 @@ +#!/usr/bin/env bash +set -euo pipefail + +usage() { + echo "Usage: verify-tsan-deps-linux.sh QT_PREFIX BOOST_PREFIX HAMLIB_PREFIX [CMAKE_CACHE [BINARY]]" >&2 +} + +if [ "$#" -lt 3 ] || [ "$#" -gt 5 ]; then + usage + exit 2 +fi + +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +# shellcheck source=.github/scripts/tsan-linux-deps-config.sh +. "${script_dir}/tsan-linux-deps-config.sh" + +qt_prefix=$1 +boost_prefix=$2 +hamlib_prefix=$3 +cmake_cache=${4:-} +binary=${5:-} + +manifest_value() { + local manifest=$1 key=$2 + awk -F= -v key="$key" '$1 == key {sub(/^[^=]*=/, ""); print; exit}' "$manifest" +} + +cmake_cache_value() { + local cache=$1 key=$2 + awk -F= -v key="$key" '$1 ~ ("^" key ":[^=]+$") {sub(/^[^=]*=/, ""); print; exit}' "$cache" +} + +verify_cmake_cache_prefix() { + local cache=$1 key=$2 prefix=$3 value + value="$(cmake_cache_value "$cache" "$key")" + if [[ "$value" != "$prefix"/* ]]; then + echo "CMake resolved $key outside $prefix: ${value:-<unset>}" >&2 + return 1 + fi +} + +verify_manifest() { + local dependency=$1 prefix=$2 manifest expected_key actual_key + manifest="${prefix}/.wsjtx-tsan-manifest" + if [ ! -f "$manifest" ]; then + echo "Missing $dependency TSan manifest: $manifest" >&2 + return 1 + fi + if [ "$(manifest_value "$manifest" dependency)" != "$dependency" ]; then + echo "Unexpected dependency identity in $manifest" >&2 + return 1 + fi + expected_key="$(tsan_dependency_cache_key "$dependency")" + actual_key="$(manifest_value "$manifest" cache_key)" + if [ "$actual_key" != "$expected_key" ]; then + echo "$dependency TSan cache manifest mismatch" >&2 + echo "Expected: $expected_key" >&2 + echo "Actual: $actual_key" >&2 + return 1 + fi +} + +verify_dynamic_tsan_symbols() { + local label=$1 library=$2 + if [ ! -f "$library" ]; then + echo "Missing $label library: $library" >&2 + return 1 + fi + if ! nm -D "$library" | awk '$0 ~ /__tsan_/ {found=1} END {exit !found}'; then + echo "$label does not reference the TSan runtime: $library" >&2 + return 1 + fi +} + +verify_manifest qt "$qt_prefix" +verify_manifest boost "$boost_prefix" +verify_manifest hamlib "$hamlib_prefix" + +qt_core="${qt_prefix}/lib/libQt5Core.so.5" +boost_candidates=("${boost_prefix}"/lib/libboost_log.so*) +boost_log=${boost_candidates[0]} +hamlib_archive="${hamlib_prefix}/lib/libhamlib.a" + +verify_dynamic_tsan_symbols Qt5Core "$qt_core" +verify_dynamic_tsan_symbols Boost.Log "$boost_log" + +if [ ! -f "$hamlib_archive" ]; then + echo "Missing Hamlib archive: $hamlib_archive" >&2 + exit 1 +fi +if ! nm -A "$hamlib_archive" | awk '$0 ~ /__tsan_/ {found=1} END {exit !found}'; then + echo "Hamlib does not reference the TSan runtime: $hamlib_archive" >&2 + exit 1 +fi + +for required in \ + "${qt_prefix}/lib/cmake/Qt5Core/Qt5CoreConfig.cmake" \ + "${qt_prefix}/lib/cmake/Qt5Test/Qt5TestConfig.cmake" \ + "${qt_prefix}/lib/cmake/Qt5Multimedia/Qt5MultimediaConfig.cmake" \ + "${qt_prefix}/lib/cmake/Qt5SerialPort/Qt5SerialPortConfig.cmake" \ + "${qt_prefix}/lib/cmake/Qt5WebSockets/Qt5WebSocketsConfig.cmake" \ + "${boost_prefix}/include/boost/log/core.hpp"; do + if [ ! -e "$required" ]; then + echo "Missing cached TSan dependency file: $required" >&2 + exit 1 + fi +done + +if [ -n "$cmake_cache" ]; then + if [ ! -f "$cmake_cache" ]; then + echo "CMake cache not found: $cmake_cache" >&2 + exit 1 + fi + verify_cmake_cache_prefix "$cmake_cache" Qt5Core_DIR "$qt_prefix" + verify_cmake_cache_prefix "$cmake_cache" Boost_INCLUDE_DIR "$boost_prefix" + verify_cmake_cache_prefix "$cmake_cache" Boost_LOG_LIBRARY_RELEASE "$boost_prefix" + verify_cmake_cache_prefix "$cmake_cache" Boost_LOG_SETUP_LIBRARY_RELEASE "$boost_prefix" + verify_cmake_cache_prefix "$cmake_cache" Hamlib_INCLUDE_DIR "$hamlib_prefix" + verify_cmake_cache_prefix "$cmake_cache" Hamlib_LIBRARY "$hamlib_prefix" +fi + +if [ -n "$binary" ]; then + if [ ! -x "$binary" ]; then + echo "TSan binary not found or not executable: $binary" >&2 + exit 1 + fi + linked="$(ldd "$binary")" + if ! printf '%s\n' "$linked" | awk -v prefix="$qt_prefix" '$0 ~ /libQt5Core/ && index($0, prefix) {found=1} END {exit !found}'; then + echo "Binary is not using cached TSan Qt: $binary" >&2 + exit 1 + fi + if ! printf '%s\n' "$linked" | awk -v prefix="$boost_prefix" '$0 ~ /libboost_log/ && index($0, prefix) {found=1} END {exit !found}'; then + echo "Binary is not using cached TSan Boost.Log: $binary" >&2 + exit 1 + fi +fi + +echo "Verified pinned TSan Qt, Boost, and Hamlib prefixes" diff --git a/.github/scripts/write-armhf-ci-manifest.sh b/.github/scripts/write-armhf-ci-manifest.sh new file mode 100755 index 00000000..93ea9e77 --- /dev/null +++ b/.github/scripts/write-armhf-ci-manifest.sh @@ -0,0 +1,121 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -ne 4 ]; then + echo "Usage: write-armhf-ci-manifest.sh ROLE ARCH GENERATION RECIPE_SHA256" >&2 + exit 2 +fi + +requested_role=$1 +requested_arch=$2 +requested_generation=$3 +requested_recipe_sha256=$4 +role=$requested_role +arch=$requested_arch +generation=$requested_generation +recipe_sha256=$requested_recipe_sha256 +config_dir=${WSJTX_ARMHF_CONFIG_DIR:-/usr/local/share/wsjtx-ci} +manifest_dir=${WSJTX_CI_MANIFEST_DIR:-/opt/wsjtx-ci} +declare toolchain_id='' runtime_sha256='' hamlib_ref='' hamlib_commit='' + +# shellcheck source=.github/scripts/armhf-ci-image-config.sh +. "$config_dir/armhf-ci-image-config.sh" + +hash_package_set() { + dpkg-query -W -f='${binary:Package}=${Version}\n' | + LC_ALL=C sort | + sha256sum | + awk '{print $1}' +} + +hash_runtime_set() { + local library records="" + for library in "${ARMHF_GCC_RUNTIME_LIBRARIES[@]}"; do + records+="$library=$(sha256sum "$ARMHF_RUNTIME_PREFIX/$library" | awk '{print $1}')"$'\n' + done + printf '%s' "$records" | sha256sum | awk '{print $1}' +} + +mkdir -p "$manifest_dir" +case "$role" in + cross-builder) + compiler="$ARMHF_TOOLCHAIN_PREFIX/bin/$ARMHF_TARGET_TRIPLET-gcc" + signature_helper="$config_dir/linux-ccache-compiler-signature.sh" + IFS=$'\t' read -r compiler_version compiler_target compiler_sha256 \ + ccache_compatibility_id compiler_signature_sha256 \ + < <("$signature_helper" "$compiler") + sysroot_package_sha256="$(sha256sum "$manifest_dir/armhf-sysroot-packages.txt" | awk '{print $1}')" + runtime_sha256="$(hash_runtime_set)" + hamlib_sha256="$(sha256sum "$ARMHF_SYSROOT/usr/lib/libhamlib.a" | awk '{print $1}')" + package_sha256="$(hash_package_set)" + identity="$recipe_sha256:$compiler_target:$compiler_sha256:$sysroot_package_sha256:$runtime_sha256:$hamlib_sha256" + identity_sha256="$(printf '%s' "$identity" | sha256sum | awk '{print $1}')" + toolchain_id="gcc${compiler_version}-${arch}-${identity_sha256:0:20}" + { + printf 'schema=%s\n' "$ARMHF_CI_IMAGE_SCHEMA" + printf 'role=%s\n' "$role" + printf 'architecture=%s\n' "$arch" + printf 'generation=%s\n' "$generation" + printf 'recipe_sha256=%s\n' "$recipe_sha256" + printf 'compiler_version=%s\n' "$compiler_version" + printf 'compiler_target=%s\n' "$compiler_target" + printf 'compiler_sha256=%s\n' "$compiler_sha256" + printf 'compiler_signature_sha256=%s\n' "$compiler_signature_sha256" + printf 'ccache_compatibility_id=%s\n' "$ccache_compatibility_id" + printf 'toolchain_id=%s\n' "$toolchain_id" + printf 'host_dpkg_arch=%s\n' "$(dpkg --print-architecture)" + printf 'package_sha256=%s\n' "$package_sha256" + printf 'sysroot_package_sha256=%s\n' "$sysroot_package_sha256" + printf 'runtime_sha256=%s\n' "$runtime_sha256" + printf 'hamlib_ref=%s\n' "$LINUX_HAMLIB_REF" + printf 'hamlib_commit=%s\n' "$LINUX_HAMLIB_COMMIT" + printf 'hamlib_sha256=%s\n' "$hamlib_sha256" + printf 'glibc_version=%s\n' "$ARMHF_GLIBC_VERSION" + printf 'binutils_version=%s\n' "$ARMHF_BINUTILS_VERSION" + printf 'linux_headers_version=%s\n' "$ARMHF_LINUX_HEADERS_VERSION" + printf 'minimum_kernel_version=%s\n' "$ARMHF_MIN_KERNEL_VERSION" + printf 'quadmath_runtime=%s\n' unavailable-on-arm + } > "$manifest_dir/image.env" + ;; + runtime) + cross_manifest="$config_dir/cross-builder.env" + if [ ! -f "$cross_manifest" ]; then + echo "Cross-builder manifest is missing: $cross_manifest" >&2 + exit 1 + fi + # shellcheck disable=SC1090 + . "$cross_manifest" + cross_generation=$generation + cross_recipe_sha256=$recipe_sha256 + cross_toolchain_id=$toolchain_id + cross_runtime_sha256=$runtime_sha256 + cross_hamlib_ref=$hamlib_ref + cross_hamlib_commit=$hamlib_commit + runtime_package_sha256="$(hash_package_set)" + runtime_sha256="$(hash_runtime_set)" + if [ "$runtime_sha256" != "$cross_runtime_sha256" ]; then + echo "Runtime GCC library set differs from the cross-builder" >&2 + exit 1 + fi + { + printf 'schema=%s\n' "$ARMHF_CI_IMAGE_SCHEMA" + printf 'role=%s\n' "$requested_role" + printf 'architecture=%s\n' "$requested_arch" + printf 'generation=%s\n' "$requested_generation" + printf 'recipe_sha256=%s\n' "$requested_recipe_sha256" + printf 'cross_generation=%s\n' "$cross_generation" + printf 'cross_recipe_sha256=%s\n' "$cross_recipe_sha256" + printf 'cross_toolchain_id=%s\n' "$cross_toolchain_id" + printf 'runtime_sha256=%s\n' "$runtime_sha256" + printf 'package_sha256=%s\n' "$runtime_package_sha256" + printf 'hamlib_ref=%s\n' "$cross_hamlib_ref" + printf 'hamlib_commit=%s\n' "$cross_hamlib_commit" + printf 'glibc_version=%s\n' "$ARMHF_GLIBC_VERSION" + printf 'quadmath_runtime=%s\n' unavailable-on-arm + } > "$manifest_dir/image.env" + ;; + *) + echo "Unsupported ARMHF image role: $role" >&2 + exit 2 + ;; +esac diff --git a/.github/workflows/build-linux-sanitizers.yml b/.github/workflows/build-linux-sanitizers.yml new file mode 100644 index 00000000..1db5293e --- /dev/null +++ b/.github/workflows/build-linux-sanitizers.yml @@ -0,0 +1,93 @@ +name: Build Linux Sanitizers + +on: + workflow_call: + inputs: + hamlib_branch: + description: "Hamlib version baked into the CI image" + required: false + type: string + default: "4.7.2" + sanitizer: + description: "Sanitizer mode: asan-ubsan or tsan" + required: true + type: string + image_tag: + description: "Immutable GHCR image tag; empty resolves the current validated generation" + required: false + type: string + default: "" + recache: + description: "Force ccache to recompile" + required: false + type: boolean + default: false + save_ccache: + description: "Save compiled objects for trusted builds" + required: false + type: boolean + default: false + advisory: + description: "Allow sanitizer failures without failing the caller" + required: false + type: boolean + default: false + allow_stale_image: + description: "Allow a previously promoted image when a dependency refresh changed the recipe" + required: false + type: boolean + default: false + +permissions: + contents: read + packages: read + +jobs: + resolve-image: + runs-on: ubuntu-24.04 + timeout-minutes: 10 + outputs: + image_tag: ${{ steps.resolve.outputs.image_tag }} + steps: + - uses: actions/checkout@v7 + - id: resolve + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REQUESTED_TAG: ${{ inputs.image_tag }} + RESOLVE_TSAN: ${{ inputs.sanitizer == 'tsan' }} + shell: bash + run: | + if [ -n "$REQUESTED_TAG" ]; then + IMAGE_TAG="$REQUESTED_TAG" .github/scripts/validate-ci-inputs.sh + echo "image_tag=$REQUESTED_TAG" >> "$GITHUB_OUTPUT" + elif [ "$RESOLVE_TSAN" = true ]; then + RESOLVE_TSAN=true .github/scripts/resolve-linux-ci-image-tag.py + else + .github/scripts/resolve-linux-ci-image-tag.py + fi + + build: + needs: resolve-image + name: ${{ inputs.sanitizer == 'tsan' && 'Linux x86_64 TSan' || 'Linux x86_64 ASan + UBSan' }} + runs-on: ubuntu-24.04 + timeout-minutes: ${{ inputs.sanitizer == 'tsan' && 180 || 40 }} + continue-on-error: ${{ inputs.advisory }} + container: + image: ${{ inputs.sanitizer == 'tsan' && format('ghcr.io/wsjtx/wsjtx-internal/linux-tsan-noble:{0}', needs.resolve-image.outputs.image_tag) || format('ghcr.io/wsjtx/wsjtx-internal/linux-noble:{0}', needs.resolve-image.outputs.image_tag) }} + credentials: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v7 + - name: Validate workflow inputs + env: + HAMLIB_BRANCH: ${{ inputs.hamlib_branch }} + IMAGE_TAG: ${{ needs.resolve-image.outputs.image_tag }} + run: .github/scripts/validate-ci-inputs.sh + - uses: ./.github/actions/build-linux-sanitizers + with: + hamlib_branch: ${{ inputs.hamlib_branch }} + sanitizer: ${{ inputs.sanitizer }} + recache: ${{ inputs.recache }} + save_ccache: ${{ inputs.save_ccache }} + allow_stale_image: ${{ inputs.allow_stale_image }} diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 10c44630..8535f8b3 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -11,12 +11,57 @@ on: description: "Hamlib branch to build" required: false type: string - default: "4.7.0" + default: "4.7.2" arch: - description: "Linux target architecture: x86_64 or aarch64" + description: "Linux target architecture: x86_64, aarch64, or armhf" required: false type: string default: "x86_64" + recache: + description: "Force ccache to recompile and refresh cached objects" + required: false + type: boolean + default: false + image_tag: + description: "Immutable GHCR image tag; empty resolves the current validated generation" + required: false + type: string + default: "" + image_source: + description: "Builder image source: internal or public-release" + required: false + type: string + default: "internal" + image_digest: + description: "Required sha256 digest for a public-release builder image" + required: false + type: string + default: "" + armhf_cross_image_digest: + description: "Required sha256 digest for the public-release ARMHF cross-builder" + required: false + type: string + default: "" + allow_stale_image: + description: "Allow a previously promoted image when a dependency refresh changed the recipe" + required: false + type: boolean + default: false + save_ccache: + description: "Save compiled objects for trusted builds" + required: false + type: boolean + default: false + validate_fortran_fallback: + description: "Build the x86_64 non-OpenMP common-library sentinel graph" + required: false + type: boolean + default: false + build_packages: + description: "Build, validate, and upload Linux packages and executable artifacts" + required: false + type: boolean + default: true release_channel: description: "Build release channel: DEVEL, RC, or GA" required: false @@ -27,289 +72,525 @@ on: required: false type: string default: "" + # Also runnable on its own ("Run workflow" / gh workflow run) to build a single + # Linux arch without dispatching the full ci.yml matrix. GitHub only exposes + # workflow_dispatch when the trigger is on the default branch (develop), so this + # must be merged before it can be dispatched. This entry point supports focused + # single-architecture diagnosis and candidate-image validation; ARMHF also joins + # ci.yml's opt-in full-ci matrix. Inputs mirror workflow_call with standalone + # defaults: hamlib_branch matches what ci.yml / release.yml pass (4.7.2), and + # version is overridable via `-f version=...`. + workflow_dispatch: + inputs: + version: + description: "WSJT-X version string (artifact + package names)" + required: false + type: string + default: "3.2.0-devel" + hamlib_branch: + description: "Hamlib branch to build" + required: false + type: string + default: "4.7.2" + arch: + description: "Linux target architecture" + required: false + type: choice + options: + - x86_64 + - aarch64 + - armhf + default: "x86_64" + recache: + description: "Force ccache to recompile and refresh cached objects" + required: false + type: boolean + default: false + image_tag: + description: "Immutable GHCR image tag; empty resolves the current validated generation" + required: false + type: string + default: "" + image_source: + description: "Builder image source" + required: false + type: choice + options: + - internal + - public-release + default: internal + image_digest: + description: "sha256 digest required with public-release image source" + required: false + type: string + default: "" + armhf_cross_image_digest: + description: "sha256 digest required for the public-release ARMHF cross-builder" + required: false + type: string + default: "" + allow_stale_image: + description: "Allow a previously promoted image when a dependency refresh changed the recipe" + required: false + type: boolean + default: false + save_ccache: + description: "Save compiled objects" + required: false + type: boolean + default: false + validate_fortran_fallback: + description: "Build the x86_64 non-OpenMP common-library sentinel graph" + required: false + type: boolean + default: false + build_packages: + description: "Build, validate, and upload Linux packages and executable artifacts" + required: false + type: boolean + default: true + release_channel: + description: "Build release channel" + required: false + type: choice + options: + - DEVEL + - RC + - GA + default: "DEVEL" + rc_number: + description: "Release candidate number when release_channel is RC" + required: false + type: string + default: "" + +# Architecture jobs are gated on `inputs.arch`. Each call from ci.yml / +# release.yml passes a single target, so exactly one build job runs per call. +# Splitting on arch +# keeps the per-arch runtime profile explicit at the job level: +# +# x86_64 — validated Noble container on ubuntu-24.04. +# aarch64 — validated GCC 13.4 Bookworm container on ubuntu-24.04-arm. This keeps the +# Bookworm glibc 2.36 + pre-t64 library baseline while using GCC 13 +# (issue #49). +# armhf — native x86_64-to-ARMHF GCC 13.4 cross-build followed by target +# tests and packaging in a Bookworm arm/v7 container under QEMU +# (issue #51). DigiPi / Pi Zero 2W class. +# +# The native jobs use the build-linux-payload composite action. ARMHF needs +# separate host-build and target-runtime phases, but shares their artifact +# validators and external artifact contracts. + +permissions: + contents: read + packages: read jobs: - build: - runs-on: ${{ inputs.arch == 'aarch64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }} + resolve-image: + runs-on: ubuntu-24.04 + timeout-minutes: 10 + outputs: + image_tag: ${{ steps.resolve.outputs.image_tag }} + image_reference: ${{ steps.resolve.outputs.image_reference }} + cross_image_reference: ${{ steps.resolve.outputs.cross_image_reference }} steps: - - uses: actions/checkout@v6 - - - name: Install dependencies + - uses: actions/checkout@v7 + - id: resolve + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REQUESTED_TAG: ${{ inputs.image_tag }} + ARMHF_BUILD: ${{ inputs.arch == 'armhf' }} + ARCH: ${{ inputs.arch }} + IMAGE_SOURCE: ${{ inputs.image_source }} + IMAGE_DIGEST: ${{ inputs.image_digest }} + ARMHF_CROSS_IMAGE_DIGEST: ${{ inputs.armhf_cross_image_digest }} + REQUEST_REPOSITORY: ${{ github.repository }} + shell: bash 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 portaudio19-dev \ - autoconf automake libtool pkg-config \ - texinfo \ - dpkg-dev fakeroot \ - asciidoctor \ - rpm + case "$ARCH" in + x86_64) package=linux-noble; cross_package= ;; + aarch64) package=linux-arm64-bookworm; cross_package= ;; + armhf) package=linux-armv7-bookworm; cross_package=linux-armhf-cross-bookworm ;; + *) + echo "::error::Unsupported Linux architecture: $ARCH" + exit 2 + ;; + esac - - 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') }} + case "$IMAGE_SOURCE" in + internal) + if [ -n "$IMAGE_DIGEST" ] || [ -n "$ARMHF_CROSS_IMAGE_DIGEST" ]; then + echo "::error::image digests are valid only for public-release images" + exit 2 + fi + package_root=ghcr.io/wsjtx/wsjtx-internal + ;; + public-release) + if [ "$REQUEST_REPOSITORY" != WSJTX/wsjtx ]; then + echo "::error::Public release images may only be used by WSJTX/wsjtx" + exit 2 + fi + if [[ ! "$IMAGE_DIGEST" =~ ^sha256:[0-9a-f]{64}$ ]]; then + echo "::error::public-release images require an immutable sha256 digest" + exit 2 + fi + if [ "$ARCH" = armhf ]; then + if [[ ! "$ARMHF_CROSS_IMAGE_DIGEST" =~ ^sha256:[0-9a-f]{64}$ ]]; then + echo "::error::public-release ARMHF builds require an immutable cross-builder sha256 digest" + exit 2 + fi + elif [ -n "$ARMHF_CROSS_IMAGE_DIGEST" ]; then + echo "::error::armhf_cross_image_digest is valid only for ARMHF builds" + exit 2 + fi + if [ -z "$REQUESTED_TAG" ]; then + echo "::error::public-release images require their release-specific image_tag" + exit 2 + fi + package_root=ghcr.io/wsjtx/wsjtx + ;; + *) + echo "::error::Unsupported image_source: $IMAGE_SOURCE" + exit 2 + ;; + esac - - 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 + if [ -n "$REQUESTED_TAG" ]; then + IMAGE_TAG="$REQUESTED_TAG" .github/scripts/validate-ci-inputs.sh + echo "image_tag=$REQUESTED_TAG" >> "$GITHUB_OUTPUT" + elif [ "$ARMHF_BUILD" = true ]; then + RESOLVE_ARMHF=true .github/scripts/resolve-linux-ci-image-tag.py + else + .github/scripts/resolve-linux-ci-image-tag.py + fi - - 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 + if [ "$IMAGE_SOURCE" = public-release ]; then + echo "image_reference=${package_root}/${package}@${IMAGE_DIGEST}" >> "$GITHUB_OUTPUT" + if [ "$ARCH" = armhf ]; then + echo "cross_image_reference=${package_root}/${cross_package}@${ARMHF_CROSS_IMAGE_DIGEST}" >> "$GITHUB_OUTPUT" + fi + else + image_tag="$(awk -F= '$1 == "image_tag" { print $2 }' "$GITHUB_OUTPUT" | tail -n 1)" + echo "image_reference=${package_root}/${package}:${image_tag}" >> "$GITHUB_OUTPUT" + if [ "$ARCH" = armhf ]; then + echo "cross_image_reference=${package_root}/${cross_package}:${image_tag}" >> "$GITHUB_OUTPUT" + fi 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 + build-x86_64: + needs: resolve-image + if: inputs.arch == 'x86_64' + runs-on: ubuntu-24.04 + timeout-minutes: 65 + container: + image: ${{ needs.resolve-image.outputs.image_reference }} + credentials: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v7 + - name: Validate workflow inputs + env: + WSJTX_VERSION: ${{ inputs.version }} + HAMLIB_BRANCH: ${{ inputs.hamlib_branch }} + WSJT_RELEASE_CHANNEL: ${{ inputs.release_channel }} + WSJT_RC_NUMBER: ${{ inputs.rc_number }} + ARCH: ${{ inputs.arch }} + IMAGE_TAG: ${{ needs.resolve-image.outputs.image_tag }} + VALIDATE_FORTRAN_FALLBACK: ${{ inputs.validate_fortran_fallback }} + run: .github/scripts/validate-ci-inputs.sh + - uses: ./.github/actions/build-linux-payload with: - path: hamlib-prefix - key: hamlib-linux-${{ inputs.arch }}-${{ inputs.hamlib_branch }}-${{ hashFiles('.github/workflows/build-linux.yml') }} + arch: x86_64 + version: ${{ inputs.version }} + hamlib_branch: ${{ inputs.hamlib_branch }} + runtime_base: host + recache: ${{ inputs.recache }} + save_ccache: ${{ inputs.save_ccache }} + validate_fortran_fallback: ${{ inputs.validate_fortran_fallback }} + build_packages: ${{ inputs.build_packages }} + release_channel: ${{ inputs.release_channel }} + rc_number: ${{ inputs.rc_number }} + allow_stale_image: ${{ inputs.allow_stale_image }} - - 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 + build-aarch64: + needs: resolve-image + if: inputs.arch == 'aarch64' + runs-on: ubuntu-24.04-arm + timeout-minutes: 45 + # The official GCC image adds GCC 13.4 without moving off the Bookworm + # glibc 2.36 and pre-t64 runtime baseline (issue #49). + container: + image: ${{ needs.resolve-image.outputs.image_reference }} + credentials: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v7 + - name: Validate workflow inputs + env: + WSJTX_VERSION: ${{ inputs.version }} + HAMLIB_BRANCH: ${{ inputs.hamlib_branch }} + WSJT_RELEASE_CHANNEL: ${{ inputs.release_channel }} + WSJT_RC_NUMBER: ${{ inputs.rc_number }} + ARCH: ${{ inputs.arch }} + IMAGE_TAG: ${{ needs.resolve-image.outputs.image_tag }} + VALIDATE_FORTRAN_FALLBACK: ${{ inputs.validate_fortran_fallback }} + run: .github/scripts/validate-ci-inputs.sh + - uses: ./.github/actions/build-linux-payload + with: + arch: aarch64 + version: ${{ inputs.version }} + hamlib_branch: ${{ inputs.hamlib_branch }} + runtime_base: bookworm-gcc13.4 + recache: ${{ inputs.recache }} + save_ccache: ${{ inputs.save_ccache }} + validate_fortran_fallback: ${{ inputs.validate_fortran_fallback }} + build_packages: ${{ inputs.build_packages }} + release_channel: ${{ inputs.release_channel }} + rc_number: ${{ inputs.rc_number }} + allow_stale_image: ${{ inputs.allow_stale_image }} - - 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 \ - -DWSJT_RELEASE_CHANNEL="${{ inputs.release_channel }}" \ - -DWSJT_RC_NUMBER="${{ inputs.rc_number }}" \ - -DPFUNIT_DIR="${{ steps.pfunit.outputs.dir }}" \ - -Wno-dev + build-armhf: + needs: resolve-image + if: inputs.arch == 'armhf' + runs-on: ubuntu-24.04 + timeout-minutes: 160 + # Compile natively on x86_64 with a pinned GCC 13.4 cross-toolchain, then + # execute target tests and packaging in a clean Bookworm ARMv7 runtime. + # + # Keep JavaScript actions on the host: the runner's x86_64 Node runtime + # cannot execute in the ARMv7 container. Both explicit containers mount + # the checkout at /work so CTest paths remain stable across phases. + env: + VERSION: ${{ inputs.version }} + HAMLIB_BRANCH: ${{ inputs.hamlib_branch }} + WSJT_RELEASE_CHANNEL: ${{ inputs.release_channel }} + WSJT_RC_NUMBER: ${{ inputs.rc_number }} + steps: + # setup-qemu-action runs on the host (job has no `container:`), + # mutating the host kernel's binfmt_misc table. With arm/v7 + # registered, subsequent `docker run --platform linux/arm/v7` + # invocations execute the container's arm/v7 init + binaries via + # qemu-arm-static. + - uses: docker/setup-qemu-action@v4 + with: + image: tonistiigi/binfmt:qemu-v10.2.3-68@sha256:400a4873b838d1b89194d982c45e5fb3cda4593fbfd7e08a02e76b03b21166f0 + platforms: linux/arm/v7 + - uses: actions/checkout@v7 + - name: Validate workflow inputs + env: + WSJTX_VERSION: ${{ inputs.version }} + HAMLIB_BRANCH: ${{ inputs.hamlib_branch }} + WSJT_RELEASE_CHANNEL: ${{ inputs.release_channel }} + WSJT_RC_NUMBER: ${{ inputs.rc_number }} + ARCH: armhf + IMAGE_TAG: ${{ needs.resolve-image.outputs.image_tag }} + VALIDATE_FORTRAN_FALLBACK: ${{ inputs.validate_fortran_fallback }} + run: .github/scripts/validate-ci-inputs.sh - - name: Build - run: cmake --build wsjtx-build -j$(nproc) + - uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - - name: Run tests - id: ctest - run: ctest --output-on-failure --output-junit ctest-results.xml - working-directory: wsjtx-build + - name: Inspect ARMHF image pair + id: image env: - QT_QPA_PLATFORM: offscreen + CROSS_BUILDER_IMAGE: ${{ needs.resolve-image.outputs.cross_image_reference }} + RUNTIME_IMAGE: ${{ needs.resolve-image.outputs.image_reference }} + ALLOW_STALE_IMAGE: ${{ inputs.allow_stale_image }} + HAMLIB_BRANCH: ${{ inputs.hamlib_branch }} + run: | + docker pull --platform linux/amd64 "$CROSS_BUILDER_IMAGE" + docker pull --platform linux/arm/v7 "$RUNTIME_IMAGE" + output_file=.armhf-image-verification-output + trap 'rm -f "$output_file"' EXIT + docker run --rm --platform linux/amd64 \ + -v "${GITHUB_WORKSPACE}:/work" \ + -w /work \ + -e GITHUB_OUTPUT=/work/$output_file \ + -e WSJTX_CI_OUTPUT_PREFIX=cross_ \ + -e WSJTX_CI_IMAGE_ALLOW_RECIPE_MISMATCH="$ALLOW_STALE_IMAGE" \ + "$CROSS_BUILDER_IMAGE" \ + bash .github/scripts/verify-armhf-ci-image.sh cross-builder armhf "$HAMLIB_BRANCH" + docker run --rm --platform linux/arm/v7 \ + -v "${GITHUB_WORKSPACE}:/work" \ + -w /work \ + -e GITHUB_OUTPUT=/work/$output_file \ + -e WSJTX_CI_OUTPUT_PREFIX=runtime_ \ + -e WSJTX_CI_IMAGE_ALLOW_RECIPE_MISMATCH="$ALLOW_STALE_IMAGE" \ + "$RUNTIME_IMAGE" \ + bash .github/scripts/verify-armhf-ci-image.sh runtime armhf "$HAMLIB_BRANCH" - - 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" + cross_generation=$(awk -F= '$1 == "cross_generation" { print $2 }' "$output_file") + runtime_generation=$(awk -F= '$1 == "runtime_generation" { print $2 }' "$output_file") + cross_toolchain_id=$(awk -F= '$1 == "cross_toolchain_id" { print $2 }' "$output_file") + runtime_toolchain_id=$(awk -F= '$1 == "runtime_toolchain_id" { print $2 }' "$output_file") + if [ "$cross_generation" != "$runtime_generation" ]; then + echo "ARMHF image generation mismatch: $cross_generation != $runtime_generation" >&2 + exit 1 + fi + if [ "$cross_toolchain_id" != "$runtime_toolchain_id" ]; then + echo "ARMHF toolchain identity mismatch: $cross_toolchain_id != $runtime_toolchain_id" >&2 + exit 1 + fi + cross_recipe_match=$(awk -F= '$1 == "cross_recipe_match" { print $2 }' "$output_file") + runtime_recipe_match=$(awk -F= '$1 == "runtime_recipe_match" { print $2 }' "$output_file") + recipe_match=false + if [ "$cross_recipe_match" = true ] && [ "$runtime_recipe_match" = true ]; then + recipe_match=true + fi + ccache_compatibility_id=$(awk -F= '$1 == "cross_ccache_compatibility_id" { print $2 }' "$output_file") + ccache_compiler_check=$(awk -F= '$1 == "cross_ccache_compiler_check" { print $2 }' "$output_file") + # Empty manifest values could coalesce caches from incompatible + # toolchains, so reject them before constructing any cache key. + if [ -z "$ccache_compatibility_id" ] || [ -z "$ccache_compiler_check" ]; then + echo "ARMHF image verification returned incomplete ccache identity" >&2 + exit 1 + fi + { + echo "generation=$cross_generation" + echo "recipe_match=$recipe_match" + echo "ccache_compatibility_id=$ccache_compatibility_id" + echo "ccache_compiler_check=$ccache_compiler_check" + } >> "$GITHUB_OUTPUT" - - name: Upload test results - if: always() && steps.ctest.conclusion != 'skipped' - uses: actions/upload-artifact@v7 + - name: Select armhf ccache key + id: ccache-key + env: + RECACHE: ${{ inputs.recache }} + run: .github/scripts/select-ccache-key-suffix.sh + + - name: Restore armhf ccache + id: ccache + uses: actions/cache/restore@v6 with: - name: ctest-results-linux-${{ inputs.arch }} - path: wsjtx-build/ctest-results.xml - if-no-files-found: ignore + path: .ccache-armhf + key: ccache-linux-armhf-${{ steps.image.outputs.ccache_compatibility_id }}-${{ steps.image.outputs.generation }}-${{ github.sha }}${{ steps.ccache-key.outputs.suffix }} + restore-keys: | + ccache-linux-armhf-${{ steps.image.outputs.ccache_compatibility_id }}-${{ steps.image.outputs.generation }}- + ccache-linux-armhf-${{ steps.image.outputs.ccache_compatibility_id }}- - - name: Verify binary + - name: Cross-build ARMHF binaries + env: + ARCH: armhf + CROSS_BUILDER_IMAGE: ${{ needs.resolve-image.outputs.cross_image_reference }} + RECACHE: ${{ inputs.recache }} + CCACHE_COMPILERCHECK: ${{ steps.image.outputs.ccache_compiler_check }} + WSJTX_CI_IMAGE_ALLOW_RECIPE_MISMATCH: ${{ inputs.allow_stale_image }} run: | - file wsjtx-build/jt9 - file wsjtx-build/jt9 | grep -q "ELF 64-bit" + ccache_args=() + if [ "$RECACHE" = true ]; then + ccache_args=(-e CCACHE_RECACHE=1) + fi + docker run --rm --platform linux/amd64 \ + -v "${GITHUB_WORKSPACE}:/work" \ + -w /work \ + -e VERSION \ + -e HAMLIB_BRANCH \ + -e ARCH \ + -e WSJT_RELEASE_CHANNEL \ + -e WSJT_RC_NUMBER \ + -e CCACHE_DIR=/work/.ccache-armhf \ + -e CCACHE_COMPILERCHECK \ + -e WSJTX_CI_IMAGE_ALLOW_RECIPE_MISMATCH \ + "${ccache_args[@]}" \ + "$CROSS_BUILDER_IMAGE" \ + bash .github/scripts/build-linux-armhf-cross.sh - # 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 + - name: Test and package under ARMv7 QEMU + id: armhf-runtime env: - VERSION: ${{ inputs.version }} - ARCH: ${{ inputs.arch }} + ARCH: armhf + RUNTIME_IMAGE: ${{ needs.resolve-image.outputs.image_reference }} + WSJTX_CI_IMAGE_ALLOW_RECIPE_MISMATCH: ${{ inputs.allow_stale_image }} + ARMHF_RUNTIME_PHASE: ${{ inputs.build_packages && 'all' || 'test' }} 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 - dpkg-deb -c "$DEB" | grep -qE '/usr/bin/map65$' - dpkg-deb -f "$DEB" Depends | grep -Eq 'libportaudio|portaudio' + GITHUB_TOKEN="${{ github.token }}" docker run --rm --platform linux/arm/v7 \ + -v "${GITHUB_WORKSPACE}:/work" \ + -w /work \ + -e VERSION \ + -e HAMLIB_BRANCH \ + -e ARCH \ + -e WSJT_RELEASE_CHANNEL \ + -e WSJT_RC_NUMBER \ + -e GITHUB_TOKEN \ + -e ARMHF_RUNTIME_PHASE \ + -e WSJTX_CI_IMAGE_ALLOW_RECIPE_MISMATCH \ + "$RUNTIME_IMAGE" \ + bash .github/scripts/validate-linux-armhf-runtime.sh + - name: Publish armhf test summary + if: always() + run: >- + python3 .github/scripts/publish-ctest-summary.py + "Linux armhf" wsjtx-build/ctest-results.xml + >> "$GITHUB_STEP_SUMMARY" + + - name: Upload armhf AppImage startup diagnostics + if: inputs.build_packages && failure() && steps.armhf-runtime.outcome == 'failure' + uses: actions/upload-artifact@v7 + with: + name: wsjtx-startup-smoke-linux-armhf + path: wsjtx-build/appimage-startup-smoke.log + if-no-files-found: ignore + retention-days: 7 + + # Artifacts produced inside the container land in $GITHUB_WORKSPACE + # via the bind-mount. Upload from the host where actions/upload- + # artifact runs natively. Same artifact names as the composite + # action's uploads so release.yml's all-platforms-ready gate + # pattern works unchanged. - name: Upload .deb + if: inputs.build_packages uses: actions/upload-artifact@v7 with: - name: wsjtx-${{ inputs.version }}-linux-${{ inputs.arch }}-deb - path: wsjtx-build/wsjtx-${{ inputs.version }}-linux-${{ inputs.arch }}.deb + name: wsjtx-${{ inputs.version }}-linux-armhf-deb + path: wsjtx-build/wsjtx-${{ inputs.version }}-linux-armhf.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$' - rpm -qpl "$RPM" | grep -qE '/bin/map65$' - rpm -qpR "$RPM" | grep -Eq 'libportaudio|portaudio' - + compression-level: 0 - name: Upload RPM + if: inputs.build_packages uses: actions/upload-artifact@v7 with: - name: wsjtx-${{ inputs.version }}-linux-${{ inputs.arch }}-rpm + name: wsjtx-${{ inputs.version }}-linux-armhf-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/map65 - 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/map65 - 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 - + compression-level: 0 - name: Upload AppImage + if: inputs.build_packages uses: actions/upload-artifact@v7 with: - name: wsjtx-${{ inputs.version }}-linux-${{ inputs.arch }}-AppImage - path: wsjtx-${{ inputs.version }}-linux-${{ inputs.arch }}.AppImage + name: wsjtx-${{ inputs.version }}-linux-armhf-AppImage + path: wsjtx-${{ inputs.version }}-linux-armhf.AppImage if-no-files-found: error - + compression-level: 0 - name: Upload build artifacts + if: inputs.build_packages uses: actions/upload-artifact@v7 with: - name: wsjtx-${{ inputs.version }}-linux-${{ inputs.arch }} + name: wsjtx-${{ inputs.version }}-linux-armhf path: | wsjtx-build/jt9 wsjtx-build/wsprd wsjtx-build/wsjtx + - name: Upload test results + if: always() + uses: actions/upload-artifact@v7 + with: + name: ctest-results-linux-armhf + path: wsjtx-build/ctest-results.xml + if-no-files-found: ignore + + - name: Report suppressed armhf ccache save + if: inputs.save_ccache && steps.image.outputs.recipe_match != 'true' + run: echo "::notice::Not saving armhf ccache because this build used a stale Linux CI image recipe" + + - name: Save armhf ccache + if: inputs.save_ccache && steps.image.outputs.recipe_match == 'true' && steps.ccache.outputs.cache-hit != 'true' + uses: actions/cache/save@v6 + with: + path: .ccache-armhf + key: ${{ steps.ccache.outputs.cache-primary-key }} diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 295ab743..274270d3 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -1,5 +1,8 @@ name: Build macOS +permissions: + contents: read + on: workflow_call: inputs: @@ -11,7 +14,7 @@ on: description: "Hamlib branch to build" required: false type: string - default: "4.7.1" + default: "4.7.2" arch: description: "Target architecture (arm64 or x86_64)" required: true @@ -24,6 +27,16 @@ on: description: "macOS deployment target version" required: true type: string + recache: + description: "Force ccache to recompile and refresh cached objects" + required: false + type: boolean + default: false + save_ccache: + description: "Persist compiler objects from a trusted develop build" + required: false + type: boolean + default: false release_channel: description: "Build release channel: DEVEL, RC, or GA" required: false @@ -34,74 +47,239 @@ on: required: false type: string default: "" + signing_mode: + description: "Package signing policy: validation or distribution" + required: false + type: string + default: "validation" + apple_team_id: + description: "Expected Apple Developer Team ID for distribution signing" + required: false + type: string + default: "" + application_certificate_sha1: + description: "Expected Developer ID Application certificate SHA-1" + required: false + type: string + default: "" + installer_certificate_sha1: + description: "Expected Developer ID Installer certificate SHA-1" + required: false + type: string + default: "" + secrets: + DEVELOPER_ID_CERTIFICATE_P12: + description: "Base64-encoded Developer ID Application PKCS#12" + required: false + DEVELOPER_ID_CERTIFICATE_PASSWORD: + description: "Password for the Application PKCS#12" + required: false + DEVELOPER_ID_INSTALLER_P12: + description: "Base64-encoded Developer ID Installer PKCS#12" + required: false + DEVELOPER_ID_INSTALLER_PASSWORD: + description: "Password for the Installer PKCS#12" + required: false + APP_STORE_CONNECT_KEY_ID: + description: "App Store Connect API key ID" + required: false + APP_STORE_CONNECT_ISSUER_ID: + description: "App Store Connect API issuer ID" + required: false + APP_STORE_CONNECT_PRIVATE_KEY_P8_BASE64: + description: "Base64-encoded App Store Connect API private key" + required: false + # Standalone dispatch builds one architecture. Derive its runner and deployment + # target from that architecture so unsupported tuples cannot be selected. + workflow_dispatch: + inputs: + version: + description: "WSJT-X version string (artifact + package names)" + required: false + type: string + default: "3.2.0-devel" + hamlib_branch: + description: "Hamlib branch to build" + required: false + type: string + default: "4.7.2" + arch: + description: "Target architecture" + required: false + type: choice + options: + - arm64 + - x86_64 + default: "arm64" + recache: + description: "Force ccache to recompile and refresh cached objects" + required: false + type: boolean + default: false + save_ccache: + description: "Persist compiler objects when dispatching on develop" + required: false + type: boolean + default: true + release_channel: + description: "Build release channel" + required: false + type: choice + options: + - DEVEL + - RC + - GA + default: "DEVEL" + rc_number: + description: "Release candidate number when release_channel is RC" + required: false + type: string + default: "" + signing_mode: + description: "Package signing policy" + required: false + type: choice + options: + - validation + - distribution + default: validation + apple_team_id: + description: "Expected Apple Developer Team ID (distribution only)" + required: false + type: string + default: "" + application_certificate_sha1: + description: "Expected Developer ID Application certificate SHA-1" + required: false + type: string + default: "" + installer_certificate_sha1: + description: "Expected Developer ID Installer certificate SHA-1" + required: false + type: string + default: "" jobs: build: - runs-on: ${{ inputs.runner }} + # runs-on cannot reference job-level env, so keep this expression and RUNNER + # aligned. RUNNER also keeps cache keys consistent across both triggers. + runs-on: ${{ inputs.runner || (inputs.arch == 'x86_64' && 'macos-15-intel' || 'macos-15') }} + timeout-minutes: 45 + env: + RUNNER: ${{ inputs.runner || (inputs.arch == 'x86_64' && 'macos-15-intel' || 'macos-15') }} + DEPLOYMENT_TARGET: ${{ inputs.deployment_target || (inputs.arch == 'x86_64' && '10.13' || '11.0') }} + VERSION: ${{ inputs.version }} + HAMLIB_BRANCH: ${{ inputs.hamlib_branch }} + WSJT_RELEASE_CHANNEL: ${{ inputs.release_channel }} + WSJT_RC_NUMBER: ${{ inputs.rc_number }} + SIGNING_MODE: ${{ inputs.signing_mode }} + ARCH: ${{ inputs.arch }} + BOOST_VERSION: 1.85.0 + BOOST_SOURCE_SHA256: 7009fe1faa1697476bdc7027703a2badb84e849b7b0baad5086b087b971f8617 steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - - name: Resolve source revision - id: source_revision - run: | - source_revision="${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || '' }}" - if [ -z "$source_revision" ]; then - source_revision="$(git rev-parse HEAD)" - fi - echo "sha=${source_revision}" >> "$GITHUB_OUTPUT" + - name: Validate workflow inputs + env: + WSJTX_VERSION: ${{ inputs.version }} + run: .github/scripts/validate-ci-inputs.sh - name: Verify macOS build tuple run: | - case "${{ inputs.arch }}:${{ inputs.runner }}:${{ inputs.deployment_target }}" in + case "${ARCH}:${RUNNER}:${DEPLOYMENT_TARGET}" in arm64:macos-15:11.0|x86_64:macos-15-intel:10.13) - echo "Using supported macOS build tuple: ${{ inputs.arch }} on ${{ inputs.runner }} targeting ${{ inputs.deployment_target }}" + echo "Using supported macOS build tuple: ${ARCH} on ${RUNNER} targeting ${DEPLOYMENT_TARGET}" ;; *) - echo "::error::Unsupported macOS build tuple: arch=${{ inputs.arch }}, runner=${{ inputs.runner }}, deployment_target=${{ inputs.deployment_target }}" - echo "::error::Use arm64:macos-15:11.0 or x86_64:macos-15-intel:10.13. Do not use macos-latest for release artifacts." + echo "::error::Unsupported macOS build tuple: arch=${ARCH}, runner=${RUNNER}, deployment_target=${DEPLOYMENT_TARGET}" + echo "::error::Use arm64:macos-15:11.0 or x86_64:macos-15-intel:10.13 for deployable macOS artifacts." exit 1 ;; esac - - name: Check signing secrets - id: check_secrets - env: - APP_P12: ${{ secrets.DEVELOPER_ID_CERTIFICATE_P12 }} + - name: Validate signing policy run: | - if [ -n "$APP_P12" ]; then - echo "signing_enabled=true" >> "$GITHUB_OUTPUT" - else - echo "signing_enabled=false" >> "$GITHUB_OUTPUT" - echo "::notice::macOS signing skipped — secrets unavailable (Dependabot or fork PR context). Compile + tests + dylib bundling still validated." - fi + case "$SIGNING_MODE" in + validation) + echo "macOS signing mode: validation (ad-hoc app signature and explicitly unsigned package)" + ;; + distribution) + echo "macOS signing mode: distribution (build job remains secretless; a fresh job performs signing)" + ;; + *) + echo "::error::signing_mode must be validation or distribution, got: ${SIGNING_MODE}" + exit 1 + ;; + esac - name: Set Homebrew prefix run: echo "HOMEBREW_PREFIX=$(brew --prefix)" >> "$GITHUB_ENV" - name: Install dependencies - run: brew install cmake autoconf automake libtool asciidoctor + run: brew install cmake autoconf automake libtool asciidoctor ccache pkg-config + + - name: Select ccache key + id: ccache-key + env: + RECACHE: ${{ inputs.recache }} + run: .github/scripts/select-ccache-key-suffix.sh + + - name: Restore ccache + id: ccache + uses: actions/cache/restore@v6 + with: + path: .ccache + key: ccache-macos-${{ inputs.arch }}-appleclang-${{ github.sha }}${{ steps.ccache-key.outputs.suffix }} + restore-keys: | + ccache-macos-${{ inputs.arch }}-appleclang- + + - name: Configure ccache + run: | + echo "CCACHE_DIR=${GITHUB_WORKSPACE}/.ccache" >> "$GITHUB_ENV" + echo "ccache recache: ${{ inputs.recache }}" + if [ "${{ inputs.recache }}" = "true" ]; then + echo "CCACHE_RECACHE=1" >> "$GITHUB_ENV" + echo "Forcing ccache recache for this run" + fi + mkdir -p "${GITHUB_WORKSPACE}/.ccache" + ccache --version + ccache --zero-stats - name: Compute Qt cache key id: qt-key run: | .github/scripts/macos-qt-cache-key.sh \ --arch "${{ inputs.arch }}" \ - --runner "${{ inputs.runner }}" \ - --deployment-target "${{ inputs.deployment_target }}" \ + --runner "${{ env.RUNNER }}" \ + --deployment-target "${{ env.DEPLOYMENT_TARGET }}" \ --github-output - name: Restore Qt cache id: qt-cache - uses: actions/cache/restore@v5 + uses: actions/cache/restore@v6 with: path: qt-prefix key: ${{ steps.qt-key.outputs.key }} - fail-on-cache-miss: true - - name: Verify cached Qt deployment target + - name: Build Qt + if: steps.qt-cache.outputs.cache-hit != 'true' + run: | + .github/scripts/build-qt-macos.sh \ + --arch "${{ inputs.arch }}" \ + --deployment-target "${{ env.DEPLOYMENT_TARGET }}" \ + --prefix "${GITHUB_WORKSPACE}/qt-prefix" + + - name: Save Qt cache + if: steps.qt-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v6 + with: + path: qt-prefix + key: ${{ steps.qt-cache.outputs.cache-primary-key }} + + - name: Verify Qt prefix run: | .github/scripts/verify-macos-artifacts.sh \ - --target "${{ inputs.deployment_target }}" \ + --target "${{ env.DEPLOYMENT_TARGET }}" \ --arch "${{ inputs.arch }}" \ --allow-prefix "${GITHUB_WORKSPACE}/qt-prefix" \ "${GITHUB_WORKSPACE}/qt-prefix" @@ -111,7 +289,7 @@ jobs: if: inputs.arch == 'arm64' run: | .github/scripts/install-r-macos-gfortran.sh \ - --target "${{ inputs.deployment_target }}" \ + --target "${{ env.DEPLOYMENT_TARGET }}" \ --arch "${{ inputs.arch }}" \ --work-dir "${RUNNER_TEMP}/r-macos-gfortran" \ --prefix "${GITHUB_WORKSPACE}/gfortran-prefix" \ @@ -122,7 +300,7 @@ jobs: if: inputs.arch == 'x86_64' run: | .github/scripts/install-xpack-gfortran-macos.sh \ - --target "${{ inputs.deployment_target }}" \ + --target "${{ env.DEPLOYMENT_TARGET }}" \ --arch "${{ inputs.arch }}" \ --work-dir "${RUNNER_TEMP}/xpack-gfortran" \ --prefix "${GITHUB_WORKSPACE}/gfortran-prefix" \ @@ -162,206 +340,263 @@ jobs: echo "cache_key=${{ steps.controlled-arm-fc.outputs.cache_key }}" } >> "$GITHUB_OUTPUT" - - name: Verify static Fortran runtime deployment targets + - name: Verify static Fortran runtime run: | .github/scripts/verify-macos-static-archives.sh \ - --target "${{ inputs.deployment_target }}" \ + --target "${{ env.DEPLOYMENT_TARGET }}" \ --arch "${{ inputs.arch }}" \ --mode error \ ${{ steps.fc.outputs.runtime_archives }} - - name: Cache libusb + - name: Restore libusb cache id: libusb-cache - uses: actions/cache/restore@v5 + uses: actions/cache/restore@v6 with: path: libusb-prefix - key: libusb-macos-${{ inputs.arch }}-${{ inputs.runner }}-1.0.27-min${{ inputs.deployment_target }}-${{ hashFiles('.github/scripts/build-libusb-macos.sh') }} + key: libusb-macos-${{ inputs.arch }}-${{ env.RUNNER }}-1.0.27-min${{ env.DEPLOYMENT_TARGET }}-epoch1-${{ hashFiles('.github/scripts/build-libusb-macos.sh') }} - name: Build libusb if: steps.libusb-cache.outputs.cache-hit != 'true' run: | .github/scripts/build-libusb-macos.sh \ 1.0.27 \ - "${{ inputs.deployment_target }}" \ + "${{ env.DEPLOYMENT_TARGET }}" \ "${GITHUB_WORKSPACE}/libusb-prefix" - name: Save libusb cache if: steps.libusb-cache.outputs.cache-hit != 'true' - continue-on-error: true - uses: actions/cache/save@v5 + uses: actions/cache/save@v6 with: path: libusb-prefix - key: libusb-macos-${{ inputs.arch }}-${{ inputs.runner }}-1.0.27-min${{ inputs.deployment_target }}-${{ hashFiles('.github/scripts/build-libusb-macos.sh') }} - - - name: Cache Hamlib - id: hamlib-cache - uses: actions/cache/restore@v5 - with: - path: hamlib-prefix - key: hamlib-macos-${{ inputs.arch }}-${{ inputs.runner }}-${{ inputs.hamlib_branch }}-min${{ inputs.deployment_target }}-${{ hashFiles('.github/scripts/build-hamlib-macos.sh') }} + key: ${{ steps.libusb-cache.outputs.cache-primary-key }} - - name: Build Hamlib - if: steps.hamlib-cache.outputs.cache-hit != 'true' - env: - PKG_CONFIG_PATH: ${{ github.workspace }}/libusb-prefix/lib/pkgconfig - run: | - .github/scripts/build-hamlib-macos.sh \ - "${{ inputs.hamlib_branch }}" \ - "${{ inputs.deployment_target }}" \ - "${GITHUB_WORKSPACE}/hamlib-prefix" - - - name: Save Hamlib cache - if: steps.hamlib-cache.outputs.cache-hit != 'true' - continue-on-error: true - uses: actions/cache/save@v5 - with: - path: hamlib-prefix - key: hamlib-macos-${{ inputs.arch }}-${{ inputs.runner }}-${{ inputs.hamlib_branch }}-min${{ inputs.deployment_target }}-${{ hashFiles('.github/scripts/build-hamlib-macos.sh') }} - - - name: Cache PortAudio + - name: Restore PortAudio cache id: portaudio-cache - uses: actions/cache/restore@v5 + uses: actions/cache/restore@v6 with: path: portaudio-prefix - key: portaudio-macos-${{ inputs.arch }}-${{ inputs.runner }}-19.7.0-min${{ inputs.deployment_target }}-${{ hashFiles('.github/scripts/build-portaudio-macos.sh') }} + key: portaudio-macos-${{ inputs.arch }}-${{ env.RUNNER }}-19.7.0-min${{ env.DEPLOYMENT_TARGET }}-epoch1-${{ hashFiles('.github/scripts/build-portaudio-macos.sh') }} - name: Build PortAudio if: steps.portaudio-cache.outputs.cache-hit != 'true' run: | .github/scripts/build-portaudio-macos.sh \ 19.7.0 \ - "${{ inputs.deployment_target }}" \ + "${{ env.DEPLOYMENT_TARGET }}" \ "${GITHUB_WORKSPACE}/portaudio-prefix" - name: Save PortAudio cache if: steps.portaudio-cache.outputs.cache-hit != 'true' - continue-on-error: true - uses: actions/cache/save@v5 + uses: actions/cache/save@v6 with: path: portaudio-prefix - key: portaudio-macos-${{ inputs.arch }}-${{ inputs.runner }}-19.7.0-min${{ inputs.deployment_target }}-${{ hashFiles('.github/scripts/build-portaudio-macos.sh') }} + key: ${{ steps.portaudio-cache.outputs.cache-primary-key }} - - name: Cache FFTW + - name: Restore FFTW cache id: fftw-cache - uses: actions/cache/restore@v5 + uses: actions/cache/restore@v6 with: path: fftw-prefix - key: fftw-macos-${{ inputs.arch }}-${{ inputs.runner }}-3.3.10-min${{ inputs.deployment_target }}-${{ hashFiles('.github/scripts/build-fftw-macos.sh') }} + key: fftw-macos-${{ inputs.arch }}-${{ env.RUNNER }}-3.3.10-min${{ env.DEPLOYMENT_TARGET }}-epoch1-${{ hashFiles('.github/scripts/build-fftw-macos.sh') }} - name: Build FFTW if: steps.fftw-cache.outputs.cache-hit != 'true' run: | .github/scripts/build-fftw-macos.sh \ 3.3.10 \ - "${{ inputs.deployment_target }}" \ + "${{ env.DEPLOYMENT_TARGET }}" \ "${GITHUB_WORKSPACE}/fftw-prefix" - name: Save FFTW cache if: steps.fftw-cache.outputs.cache-hit != 'true' - continue-on-error: true - uses: actions/cache/save@v5 + uses: actions/cache/save@v6 with: path: fftw-prefix - key: fftw-macos-${{ inputs.arch }}-${{ inputs.runner }}-3.3.10-min${{ inputs.deployment_target }}-${{ hashFiles('.github/scripts/build-fftw-macos.sh') }} + key: ${{ steps.fftw-cache.outputs.cache-primary-key }} - - name: Cache Boost + - name: Restore Boost cache id: boost-cache - uses: actions/cache/restore@v5 + uses: actions/cache/restore@v6 with: path: boost-prefix - key: boost-macos-${{ inputs.arch }}-${{ inputs.runner }}-1.85.0-min${{ inputs.deployment_target }}-${{ hashFiles('.github/scripts/build-boost-macos.sh') }} + key: boost-macos-${{ inputs.arch }}-${{ env.RUNNER }}-${{ env.BOOST_VERSION }}-${{ env.BOOST_SOURCE_SHA256 }}-min${{ env.DEPLOYMENT_TARGET }}-epoch1-${{ hashFiles('.github/scripts/build-boost-macos.sh') }} - name: Build Boost if: steps.boost-cache.outputs.cache-hit != 'true' run: | .github/scripts/build-boost-macos.sh \ - 1.85.0 \ + "${BOOST_VERSION}" \ + "${BOOST_SOURCE_SHA256}" \ "${{ inputs.arch }}" \ - "${{ inputs.deployment_target }}" \ + "${{ env.DEPLOYMENT_TARGET }}" \ "${GITHUB_WORKSPACE}/boost-prefix" - name: Save Boost cache if: steps.boost-cache.outputs.cache-hit != 'true' - continue-on-error: true - uses: actions/cache/save@v5 + uses: actions/cache/save@v6 with: path: boost-prefix - key: boost-macos-${{ inputs.arch }}-${{ inputs.runner }}-1.85.0-min${{ inputs.deployment_target }}-${{ hashFiles('.github/scripts/build-boost-macos.sh') }} - - - name: Configure - env: - PKG_CONFIG_PATH: ${{ github.workspace }}/qt-prefix/lib/pkgconfig:${{ github.workspace }}/boost-prefix/lib/pkgconfig:${{ github.workspace }}/fftw-prefix/lib/pkgconfig:${{ github.workspace }}/libusb-prefix/lib/pkgconfig:${{ github.workspace }}/portaudio-prefix/lib/pkgconfig:${{ github.workspace }}/hamlib-prefix/lib/pkgconfig - run: | - cmake -S . -B wsjtx-build \ - -DCMAKE_PREFIX_PATH="${GITHUB_WORKSPACE}/qt-prefix;${GITHUB_WORKSPACE}/boost-prefix;${GITHUB_WORKSPACE}/fftw-prefix;${GITHUB_WORKSPACE}/libusb-prefix;${GITHUB_WORKSPACE}/portaudio-prefix;${GITHUB_WORKSPACE}/hamlib-prefix" \ - -DCMAKE_Fortran_COMPILER="${{ steps.fc.outputs.path }}" \ - -DCMAKE_Fortran_FLAGS="${{ steps.fc.outputs.fortran_runtime_flags }}" \ - -DCMAKE_OSX_DEPLOYMENT_TARGET=${{ inputs.deployment_target }} \ - -DCMAKE_EXE_LINKER_FLAGS="-Wl,-headerpad_max_install_names ${{ steps.fc.outputs.runtime_link_flags }}" \ - -DWSJT_MACOS_LIBGOMP_LIBRARY="${{ steps.fc.outputs.libgomp }}" \ - -DWSJT_SOURCE_REVISION="${{ steps.source_revision.outputs.sha }}" \ - -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ - -DWSJT_SKIP_MANPAGES=ON \ - -DWSJT_SKIP_BUNDLE_FIXUP=ON \ - -DWSJT_BUILD_TESTS=ON \ - -DWSJT_RELEASE_CHANNEL="${{ inputs.release_channel }}" \ - -DWSJT_RC_NUMBER="${{ inputs.rc_number }}" \ - -Wno-dev + key: ${{ steps.boost-cache.outputs.cache-primary-key }} - - name: Verify resolved dependency prefixes - run: | - CACHE=wsjtx-build/CMakeCache.txt - BAD=$(awk -F= ' - /^(Boost_DIR|Boost_INCLUDE_DIR|Boost_LOG_LIBRARY_RELEASE|Boost_LOG_SETUP_LIBRARY_RELEASE|FFTW3F_LIBRARY|FFTW3F_THREADS_LIBRARY|FFTW3_INCLUDE_DIR|Hamlib_INCLUDE_DIR|Hamlib_LIBRARY|Portaudio_INCLUDE_DIR|Portaudio_LIBRARY|Usb_INCLUDE_DIR|Usb_LIBRARY|Qt5[^:]*_DIR|Qt5[^:]*_EXECUTABLE):/ && $2 ~ /^(\/opt\/homebrew|\/usr\/local\/Cellar|\/usr\/local\/opt|\/opt\/local)/ { - print - } - ' "$CACHE") - if [ -n "$BAD" ]; then - echo "::error::Deployable macOS build resolved bundled dependencies from a package-manager prefix:" - echo "$BAD" - exit 1 - fi - - QT_BAD=$(awk -F= -v prefix="${GITHUB_WORKSPACE}/qt-prefix" ' - /^Qt5[^:]*_(DIR|EXECUTABLE):/ && index($2, prefix) != 1 { - print - } - ' "$CACHE") - if [ -n "$QT_BAD" ]; then - echo "::error::Deployable macOS build did not resolve Qt from the cached qt-prefix:" - echo "$QT_BAD" - exit 1 - fi - - - name: Verify built dependency deployment targets + - name: Verify pinned runtime prefixes run: | .github/scripts/verify-macos-artifacts.sh \ - --target "${{ inputs.deployment_target }}" \ + --target "${{ env.DEPLOYMENT_TARGET }}" \ --arch "${{ inputs.arch }}" \ - --allow-prefix "${GITHUB_WORKSPACE}/boost-prefix" \ - --allow-prefix "${GITHUB_WORKSPACE}/fftw-prefix" \ --allow-prefix "${GITHUB_WORKSPACE}/libusb-prefix" \ --allow-prefix "${GITHUB_WORKSPACE}/portaudio-prefix" \ - "${GITHUB_WORKSPACE}/boost-prefix" \ - "${GITHUB_WORKSPACE}/fftw-prefix" \ + --allow-prefix "${GITHUB_WORKSPACE}/fftw-prefix" \ + --allow-prefix "${GITHUB_WORKSPACE}/boost-prefix" \ "${GITHUB_WORKSPACE}/libusb-prefix" \ - "${GITHUB_WORKSPACE}/portaudio-prefix" + "${GITHUB_WORKSPACE}/portaudio-prefix" \ + "${GITHUB_WORKSPACE}/fftw-prefix" \ + "${GITHUB_WORKSPACE}/boost-prefix" - - name: Verify Hamlib static archive deployment targets + - name: Restore Hamlib cache + id: hamlib-cache + uses: actions/cache/restore@v6 + with: + path: hamlib-prefix + key: hamlib-macos-${{ inputs.arch }}-${{ env.RUNNER }}-${{ inputs.hamlib_branch }}-libusb1.0.27-min${{ env.DEPLOYMENT_TARGET }}-epoch1-${{ hashFiles('.github/scripts/build-hamlib-macos.sh', '.github/scripts/build-libusb-macos.sh') }} + + - name: Build Hamlib + if: steps.hamlib-cache.outputs.cache-hit != 'true' + run: | + .github/scripts/build-hamlib-macos.sh \ + "${HAMLIB_BRANCH}" \ + "${DEPLOYMENT_TARGET}" \ + "${GITHUB_WORKSPACE}/hamlib-prefix" \ + "${GITHUB_WORKSPACE}/libusb-prefix" + + - name: Verify Hamlib prefix run: | - hamlib_archives=( "${GITHUB_WORKSPACE}/hamlib-prefix/lib/"*.a ) + test -f "${GITHUB_WORKSPACE}/hamlib-prefix/lib/libhamlib.a" .github/scripts/verify-macos-static-archives.sh \ - --target "${{ inputs.deployment_target }}" \ + --target "${{ env.DEPLOYMENT_TARGET }}" \ --arch "${{ inputs.arch }}" \ --mode error \ - "${hamlib_archives[@]}" + "${GITHUB_WORKSPACE}/hamlib-prefix/lib/libhamlib.a" + + - name: Save Hamlib cache + if: steps.hamlib-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v6 + with: + path: hamlib-prefix + key: ${{ steps.hamlib-cache.outputs.cache-primary-key }} + + - name: Restore pFUnit cache + id: pfunit-cache + uses: actions/cache/restore@v6 + with: + path: pfunit-prefix + key: pfunit-macos-${{ inputs.arch }}-${{ env.RUNNER }}-v4.14.0-${{ steps.fc.outputs.cache_key }}-min${{ env.DEPLOYMENT_TARGET }}-epoch3-${{ hashFiles('.github/scripts/build-pfunit-macos.sh') }} + + - name: Build pFUnit + if: steps.pfunit-cache.outputs.cache-hit != 'true' + env: + # pFUnit configure uses try_run probes; expose only the controlled + # compiler runtime for those probes, not for the final test binaries. + DYLD_LIBRARY_PATH: ${{ steps.fc.outputs.runtime_lib_dir }} + run: | + .github/scripts/build-pfunit-macos.sh \ + v4.14.0 \ + "${{ steps.fc.outputs.path }}" \ + "${{ env.DEPLOYMENT_TARGET }}" \ + "${GITHUB_WORKSPACE}/pfunit-prefix" + + - name: Locate pFUnit config + id: pfunit + run: | + CONFIG=$(find "${GITHUB_WORKSPACE}/pfunit-prefix" -name PFUNITConfig.cmake -print -quit) + 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: Save pFUnit cache + if: steps.pfunit-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v6 + with: + path: pfunit-prefix + key: ${{ steps.pfunit-cache.outputs.cache-primary-key }} - - name: Build + - name: Configure build and tests + env: + PKG_CONFIG_PATH: ${{ github.workspace }}/qt-prefix/lib/pkgconfig:${{ github.workspace }}/boost-prefix/lib/pkgconfig:${{ github.workspace }}/fftw-prefix/lib/pkgconfig:${{ github.workspace }}/libusb-prefix/lib/pkgconfig:${{ github.workspace }}/portaudio-prefix/lib/pkgconfig:${{ github.workspace }}/hamlib-prefix/lib/pkgconfig:${{ github.workspace }}/pfunit-prefix/lib/pkgconfig + run: | + cmake -S . -B wsjtx-build \ + -DCMAKE_PREFIX_PATH="${GITHUB_WORKSPACE}/qt-prefix;${GITHUB_WORKSPACE}/boost-prefix;${GITHUB_WORKSPACE}/fftw-prefix;${GITHUB_WORKSPACE}/libusb-prefix;${GITHUB_WORKSPACE}/portaudio-prefix;${GITHUB_WORKSPACE}/hamlib-prefix;${GITHUB_WORKSPACE}/pfunit-prefix" \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DCMAKE_Fortran_COMPILER="${{ steps.fc.outputs.path }}" \ + -DCMAKE_Fortran_FLAGS="${{ steps.fc.outputs.fortran_runtime_flags }}" \ + -DCMAKE_EXE_LINKER_FLAGS="${{ steps.fc.outputs.runtime_link_flags }}" \ + -DCMAKE_INSTALL_RPATH="${GITHUB_WORKSPACE}/qt-prefix/lib;${GITHUB_WORKSPACE}/boost-prefix/lib;${GITHUB_WORKSPACE}/fftw-prefix/lib;${GITHUB_WORKSPACE}/libusb-prefix/lib;${GITHUB_WORKSPACE}/portaudio-prefix/lib;${GITHUB_WORKSPACE}/hamlib-prefix/lib" \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=${{ env.DEPLOYMENT_TARGET }} \ + -DWSJT_SKIP_MANPAGES=ON \ + -DWSJT_ENABLE_TESTS=ON \ + -DWSJT_ENABLE_GUI_SMOKE_TESTS=ON \ + -DWSJT_MACOS_LIBGOMP_LIBRARY="${{ steps.fc.outputs.libgomp }}" \ + -DPFUNIT_DIR="${{ steps.pfunit.outputs.dir }}" \ + -DWSJT_SOURCE_REVISION="${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || '' }}" \ + -DWSJT_RELEASE_CHANNEL="${WSJT_RELEASE_CHANNEL}" \ + -DWSJT_RC_NUMBER="${WSJT_RC_NUMBER}" \ + -Wno-dev + + - name: Build and test targets run: cmake --build wsjtx-build -j"$(sysctl -n hw.ncpu)" + - name: Report suppressed ccache save + if: ${{ (inputs.save_ccache || inputs.recache) && github.ref != 'refs/heads/develop' }} + run: echo "::notice::Not saving ccache because shared compiler caches are published only from develop" + + - name: Save ccache + if: ${{ success() && (inputs.save_ccache || inputs.recache) && github.ref == 'refs/heads/develop' && steps.ccache.outputs.cache-hit != 'true' }} + uses: actions/cache/save@v6 + with: + path: .ccache + key: ${{ steps.ccache.outputs.cache-primary-key }} + + - name: Apply WSJT-X shared memory limits + run: | + python3 - <<'PY' + import plistlib + import subprocess + + expected_arguments = [ + "/usr/sbin/sysctl", + "kern.sysv.shmmax=52428800", + "kern.sysv.shmall=25600", + ] + + with open("Darwin/com.wsjtx.sysctl.plist", "rb") as source: + configuration = plistlib.load(source) + + if ( + configuration.get("Program") != expected_arguments[0] + or configuration.get("ProgramArguments") != expected_arguments + ): + raise SystemExit("shared memory plist does not match CI expectations") + + subprocess.run(["/usr/bin/sudo", *expected_arguments], check=True) + subprocess.run( + [expected_arguments[0], "kern.sysv.shmmax", "kern.sysv.shmall"], check=True + ) + PY + + - name: Raise shared memory total for parallel GUI tests + run: | + # Three decoder segments require 35,359 pages; leave headroom for other IPC. + sudo /usr/sbin/sysctl kern.sysv.shmall=40960 + /usr/sbin/sysctl kern.sysv.shmmax kern.sysv.shmall + - name: Run tests id: ctest - run: ctest --output-on-failure --output-junit ctest-results.xml + run: ctest --parallel 3 --output-on-failure --output-junit ctest-results.xml working-directory: wsjtx-build - name: Publish test summary @@ -371,23 +606,42 @@ jobs: - name: Upload test results if: always() && steps.ctest.conclusion != 'skipped' - continue-on-error: true uses: actions/upload-artifact@v7 with: name: ctest-results-macos-${{ inputs.arch }} path: wsjtx-build/ctest-results.xml if-no-files-found: ignore + - name: Upload WSJT-X startup diagnostics + if: failure() && steps.ctest.outcome == 'failure' + uses: actions/upload-artifact@v7 + with: + name: wsjtx-startup-smoke-macos-${{ inputs.arch }} + path: wsjtx-build/startup-smoke-diagnostics + if-no-files-found: ignore + retention-days: 7 + + - name: Show ccache stats + if: always() + run: ccache --show-stats + - name: Verify architecture run: | file wsjtx-build/jt9 - lipo -archs wsjtx-build/jt9 | grep -q ${{ inputs.arch }} + ARCHS=$(lipo -archs wsjtx-build/jt9) + case " ${ARCHS} " in + *" ${{ inputs.arch }} "*) ;; + *) + echo "::error::Expected ${{ inputs.arch }} in jt9 architectures, found: ${ARCHS}" + exit 1 + ;; + esac - name: Install app bundle and collect CLI assets id: collect run: | BUILD=wsjtx-build - STAGE=stage/wsjtx-${{ inputs.version }}-${{ inputs.arch }} + STAGE="stage/wsjtx-${VERSION}-${ARCH}" ASSETS=assets mkdir -p "${ASSETS}" @@ -398,10 +652,13 @@ jobs: echo "::error::CMake install did not create ${APP}" exit 1 fi - if [ ! -x "${APP}/Contents/MacOS/map65" ]; then - echo "::error::CMake install did not create executable MAP65 companion app binary at ${APP}/Contents/MacOS/map65" - exit 1 - fi + + for bin in qmap map65; do + if [ ! -x "${APP}/Contents/MacOS/${bin}" ]; then + echo "::error::Expected app companion binary is missing after install: ${APP}/Contents/MacOS/${bin}" + exit 1 + fi + done for bin in jt9 wsprd wsprcode jt65code jt4code ft8code q65code encode77 fcal hash22calc; do [ -f "${BUILD}/${bin}" ] && cp "${BUILD}/${bin}" "${ASSETS}/" @@ -440,10 +697,6 @@ jobs: echo "::error::Expected CMake-installed alert sound is missing: ${SOUNDDIR}/Wanted.wav" exit 1 fi - if [ ! -x "${APP}/Contents/MacOS/map65" ]; then - echo "::error::Expected CMake-installed MAP65 binary is missing: ${APP}/Contents/MacOS/map65" - exit 1 - fi if [ -e "${APP}/Contents/MacOS/sounds" ]; then echo "::error::Alert sounds must not be installed under Contents/MacOS; codesign treats them as unsigned code." @@ -455,547 +708,114 @@ jobs: printf ' %s\n' "$@" echo "Verified CMake-installed alert sounds in ${SOUNDDIR}" - - name: Bundle dylibs into app - run: | - set -Eeuo pipefail - STAGE="${{ steps.collect.outputs.stage_dir }}" - APP="${STAGE}/wsjtx.app" - FRAMEWORKS="${APP}/Contents/Frameworks" - FORTRAN_PREFIX="${{ steps.fc.outputs.prefix }}" - FORTRAN_ORIGINAL_PREFIX="${{ steps.fc.outputs.original_prefix }}" - GCC_LIB="${{ steps.fc.outputs.runtime_lib_dir }}" - mkdir -p "${FRAMEWORKS}" - - dump_bundle_context() { - local status="$1" - local line="$2" - local command="$3" - echo "::error::Bundle dylibs into app failed at line ${line} with status ${status}: ${command}" - echo "APP=${APP}" - echo "FRAMEWORKS=${FRAMEWORKS}" - echo "FORTRAN_PREFIX=${FORTRAN_PREFIX}" - echo "FORTRAN_ORIGINAL_PREFIX=${FORTRAN_ORIGINAL_PREFIX}" - echo "GCC_LIB=${GCC_LIB}" - echo "HOMEBREW_PREFIX=${HOMEBREW_PREFIX}" - echo "App executable contents:" - ls -la "${APP}/Contents/MacOS" || true - echo "Framework contents:" - ls -la "${FRAMEWORKS}" || true - echo "External references in app executables:" - find "${APP}/Contents/MacOS" -type f -perm +111 -print -exec otool -L {} \; 2>/dev/null || true - if [ -f macdeployqt.log ]; then - echo "macdeployqt.log:" - cat macdeployqt.log - fi - } - trap 'status=$?; dump_bundle_context "$status" "$LINENO" "$BASH_COMMAND"; exit "$status"' ERR - - run_logged() { - echo "+ $*" - "$@" - } - - echo "Running macdeployqt..." - set +e - "${GITHUB_WORKSPACE}/qt-prefix/bin/macdeployqt" "${APP}" -verbose=2 > macdeployqt.log 2>&1 - status=$? - set -e - if [ "$status" -ne 0 ]; then - echo "::error::macdeployqt failed with status ${status}" - dump_bundle_context "$status" "$LINENO" "macdeployqt" - exit "$status" - fi - cat macdeployqt.log - - resolve_lib() { - local lib="$1" - if [ -n "$FORTRAN_ORIGINAL_PREFIX" ] && [[ "$lib" == "$FORTRAN_ORIGINAL_PREFIX"/* ]]; then - local original_prefix="${FORTRAN_ORIGINAL_PREFIX}/" - local relocated="${FORTRAN_PREFIX}/${lib:${#original_prefix}}" - [ -f "$relocated" ] && echo "$relocated" && return 0 - fi - if [[ "$lib" == $HOMEBREW_PREFIX/* ]]; then - echo "$lib" - return 0 - elif [[ "$lib" == $GITHUB_WORKSPACE/* ]]; then - echo "$lib" - return 0 - elif [[ "$lib" == @rpath/* ]]; then - local name="${lib#@rpath/}" - for dir in \ - "$FRAMEWORKS" \ - "$GITHUB_WORKSPACE/boost-prefix/lib" \ - "$GITHUB_WORKSPACE/fftw-prefix/lib" \ - "$GITHUB_WORKSPACE/libusb-prefix/lib" \ - "$GITHUB_WORKSPACE/portaudio-prefix/lib" \ - "$FORTRAN_PREFIX/lib" \ - "$GCC_LIB" \ - "$HOMEBREW_PREFIX/lib" - do - [ -f "$dir/$name" ] && echo "$dir/$name" && return - done - fi - return 0 - } - - should_bundle_ref() { - local ref="$1" - case "$ref" in - *Qt*.framework/*) - return 1 - ;; - "$FORTRAN_ORIGINAL_PREFIX"/*|"$HOMEBREW_PREFIX"/*|"$GITHUB_WORKSPACE"/*|@rpath/*) - return 0 - ;; - *) - return 1 - ;; - esac - } - - bundle_dylib() { - local binary="$1" - local lib - while IFS= read -r lib; do - should_bundle_ref "$lib" || continue - local resolved - resolved=$(resolve_lib "$lib") - if [ -z "$resolved" ]; then - echo "::error::Could not resolve ${lib} required by ${binary}" - exit 1 - fi - local libname - libname=$(basename "$resolved") - case "$libname" in - libgomp*.dylib) - echo "::error::Refusing to bundle ${resolved}; libgomp must be linked statically for deployable macOS artifacts." - exit 1 - ;; - esac - if [ ! -f "${FRAMEWORKS}/${libname}" ]; then - echo " Bundling: $resolved -> ${FRAMEWORKS}/${libname}" - run_logged cp "$resolved" "${FRAMEWORKS}/${libname}" - run_logged chmod 644 "${FRAMEWORKS}/${libname}" - run_logged install_name_tool -id "@rpath/${libname}" "${FRAMEWORKS}/${libname}" - bundle_dylib "${FRAMEWORKS}/${libname}" - fi - if [ "$lib" != "@rpath/${libname}" ]; then - run_logged install_name_tool -change "$lib" "@rpath/${libname}" "$binary" - fi - done < <(otool -L "$binary" | awk 'NR > 1 {print $1}' || true) - } - - ensure_app_rpath() { - local binary="$1" - local rpath - - while IFS= read -r rpath; do - [ -n "$rpath" ] || continue - case "$rpath" in - "$GITHUB_WORKSPACE"/*|"$HOMEBREW_PREFIX"/*) - run_logged install_name_tool -delete_rpath "$rpath" "$binary" - ;; - esac - done < <(otool -l "$binary" | awk '/LC_RPATH/{getline; getline; print $2}' || true) - - if ! otool -l "$binary" | awk '/LC_RPATH/{getline; getline; print $2}' | grep -Fxq "@executable_path/../Frameworks"; then - run_logged install_name_tool -add_rpath "@executable_path/../Frameworks" "$binary" - fi - } - - for exe in "${APP}/Contents/MacOS/"*; do - [ -f "$exe" ] && [ -x "$exe" ] && { - ensure_app_rpath "$exe" - bundle_dylib "$exe" - for fw in $(otool -L "$exe" | awk '{print $1}' | grep '\.framework/' || true); do - fwname=$(basename "$fw") - bundled=$(find "${FRAMEWORKS}" -name "${fwname}" -path "*.framework/*" 2>/dev/null | head -1) - if [ -n "$bundled" ]; then - app_contents="${APP}/Contents/" - fwrel="${bundled:${#app_contents}}" - if [ "$fw" != "@executable_path/../${fwrel}" ]; then - run_logged install_name_tool -change "$fw" "@executable_path/../${fwrel}" "$exe" - fi - fi - done - } - done - - for fw in "${FRAMEWORKS}"/*.dylib; do - [ -f "$fw" ] && bundle_dylib "$fw" - done - - for exe in "${APP}/Contents/MacOS/"*; do - [ -f "$exe" ] && [ -x "$exe" ] && bundle_dylib "$exe" - done - - echo "Checking for remaining external references..." - remaining_refs="${RUNNER_TEMP:-/tmp}/wsjtx-app-remaining-refs.txt" - : > "$remaining_refs" - while IFS= read -r binary; do - while IFS= read -r ref; do - case "$ref" in - "$FORTRAN_ORIGINAL_PREFIX"/*|"$HOMEBREW_PREFIX"/*|"$GITHUB_WORKSPACE"/*) - echo "${binary}: ${ref}" >> "$remaining_refs" - ;; - esac - done < <(otool -L "$binary" | awk 'NR > 1 {print $1}' || true) - done < <(find "${APP}/Contents/MacOS" -type f -perm +111 -print 2>/dev/null) - if [ -s "$remaining_refs" ]; then - echo "::error::External build-time paths still present:" - cat "$remaining_refs" - exit 1 - else - echo "All dylibs bundled successfully" - fi - - - name: Bundle dylibs into CLI tools + - name: Deploy macOS app dependencies run: | - set -Eeuo pipefail - ASSETS="${{ steps.collect.outputs.assets_dir }}" - STAGE="${{ steps.collect.outputs.stage_dir }}" - LIBDIR="${ASSETS}/lib" - FORTRAN_PREFIX="${{ steps.fc.outputs.prefix }}" - FORTRAN_ORIGINAL_PREFIX="${{ steps.fc.outputs.original_prefix }}" - GCC_LIB="${{ steps.fc.outputs.runtime_lib_dir }}" - mkdir -p "${LIBDIR}" - - dump_cli_context() { - local status="$1" - local line="$2" - local command="$3" - echo "::error::Bundle dylibs into CLI tools failed at line ${line} with status ${status}: ${command}" - echo "ASSETS=${ASSETS}" - echo "LIBDIR=${LIBDIR}" - echo "FORTRAN_PREFIX=${FORTRAN_PREFIX}" - echo "FORTRAN_ORIGINAL_PREFIX=${FORTRAN_ORIGINAL_PREFIX}" - echo "GCC_LIB=${GCC_LIB}" - echo "HOMEBREW_PREFIX=${HOMEBREW_PREFIX}" - echo "Asset contents:" - ls -la "${ASSETS}" || true - echo "Library contents:" - ls -la "${LIBDIR}" || true - echo "External references in CLI assets:" - for bin in "${ASSETS}"/*; do - [ -f "$bin" ] && [ -x "$bin" ] && [ "$(basename "$bin")" != "lib" ] || continue - echo "== $bin ==" - otool -L "$bin" || true - done - } - trap 'status=$?; dump_cli_context "$status" "$LINENO" "$BASH_COMMAND"; exit "$status"' ERR - - run_logged() { - echo "+ $*" - "$@" - } - - resolve_cli_ref() { - local ref="$1" - local name="" suffix="" - - if [ -n "$FORTRAN_ORIGINAL_PREFIX" ] && [[ "$ref" == "$FORTRAN_ORIGINAL_PREFIX"/* ]]; then - local original_prefix="${FORTRAN_ORIGINAL_PREFIX}/" - local relocated="${FORTRAN_PREFIX}/${ref:${#original_prefix}}" - [ -f "$relocated" ] && echo "$relocated" - return 0 - fi - - case "$ref" in - /usr/lib/*|/System/Library/*) - return 0 - ;; - @loader_path/lib/*) - name="${ref#@loader_path/lib/}" - [ -f "${LIBDIR}/${name}" ] && echo "${LIBDIR}/${name}" - return 0 - ;; - @loader_path/*) - name="${ref#@loader_path/}" - [ -f "${LIBDIR}/${name}" ] && echo "${LIBDIR}/${name}" - return 0 - ;; - "$GITHUB_WORKSPACE"/*|"$HOMEBREW_PREFIX"/*) - echo "$ref" - return 0 - ;; - esac - - if [[ "$ref" == @rpath/* ]]; then - suffix="${ref#@rpath/}" - if [[ "$suffix" == *.framework/* ]]; then - for dir in \ - "${STAGE}/wsjtx.app/Contents/Frameworks" \ - "${GITHUB_WORKSPACE}/qt-prefix/lib" - do - [ -f "${dir}/${suffix}" ] && echo "${dir}/${suffix}" && return 0 - done - else - name="${suffix}" - for dir in \ - "${LIBDIR}" \ - "${STAGE}/wsjtx.app/Contents/Frameworks" \ - "${GITHUB_WORKSPACE}/boost-prefix/lib" \ - "${GITHUB_WORKSPACE}/fftw-prefix/lib" \ - "${GITHUB_WORKSPACE}/libusb-prefix/lib" \ - "${GITHUB_WORKSPACE}/portaudio-prefix/lib" \ - "${FORTRAN_PREFIX}/lib" \ - "${GCC_LIB}" \ - "${HOMEBREW_PREFIX}/lib" - do - [ -f "${dir}/${name}" ] && echo "${dir}/${name}" && return 0 - done - fi - fi + .github/scripts/deploy-macos-app.sh \ + --app "${{ steps.collect.outputs.stage_dir }}/wsjtx.app" \ + --workspace-prefix "${GITHUB_WORKSPACE}" \ + --qt-prefix "${GITHUB_WORKSPACE}/qt-prefix" \ + --boost-prefix "${GITHUB_WORKSPACE}/boost-prefix" \ + --fftw-prefix "${GITHUB_WORKSPACE}/fftw-prefix" \ + --libusb-prefix "${GITHUB_WORKSPACE}/libusb-prefix" \ + --portaudio-prefix "${GITHUB_WORKSPACE}/portaudio-prefix" \ + --fortran-prefix "${{ steps.fc.outputs.prefix }}" \ + --fortran-original-prefix "${{ steps.fc.outputs.original_prefix }}" \ + --gcc-lib "${{ steps.fc.outputs.runtime_lib_dir }}" \ + --homebrew-prefix "${HOMEBREW_PREFIX}" - return 0 - } - - bundle_cli_deps() { - local binary="$1" - local change_prefix="$2" - local ref resolved out name target - - while IFS= read -r ref; do - resolved=$(resolve_cli_ref "$ref") - if [ -z "$resolved" ]; then - case "$ref" in - @rpath/*|@loader_path/*|"$GITHUB_WORKSPACE"/*|"$HOMEBREW_PREFIX"/*) - echo "::error::Could not resolve ${ref} required by ${binary}" - exit 1 - ;; - *) - continue - ;; - esac - fi - - name="$(basename "$resolved")" - case "$name" in - libgomp*.dylib) - echo "::error::Refusing to bundle ${resolved}; libgomp must be linked statically for deployable macOS artifacts." - exit 1 - ;; - esac - - out="${LIBDIR}/${name}" - if [ ! -f "$out" ]; then - echo " Bundling: ${resolved} -> ${out}" - run_logged cp "$resolved" "$out" - run_logged chmod 644 "$out" - run_logged install_name_tool -id "@rpath/${name}" "$out" - bundle_cli_deps "$out" "@rpath" - fi - - target="${change_prefix}/${name}" - if [ "$ref" != "$target" ]; then - run_logged install_name_tool -change "$ref" "$target" "$binary" - fi - done < <(otool -L "$binary" | awk 'NR > 1 {print $1}' | grep -E "($HOMEBREW_PREFIX|$GITHUB_WORKSPACE|@rpath|@loader_path)" || true) - } - - ensure_cli_rpath() { - local binary="$1" - local rpath - local bad_rpaths=() - local unique_bad_rpaths=() - - while IFS= read -r rpath; do - [ -n "$rpath" ] || continue - case "$rpath" in - "$GITHUB_WORKSPACE"/*|"$HOMEBREW_PREFIX"/*) - bad_rpaths+=("$rpath") - ;; - esac - done < <(otool -l "$binary" | awk '/LC_RPATH/{getline; getline; print $2}' || true) - - # Deduplicate bad rpaths (compatible with macOS Bash 3.2) - if [ "${#bad_rpaths[@]}" -gt 0 ]; then - for rpath in "${bad_rpaths[@]}"; do - local found=0 - local u - if [ "${#unique_bad_rpaths[@]}" -gt 0 ]; then - for u in "${unique_bad_rpaths[@]}"; do - [ "$u" = "$rpath" ] && found=1 && break - done - fi - [ "$found" -eq 0 ] && unique_bad_rpaths+=("$rpath") - done - fi - - if [ "${#unique_bad_rpaths[@]}" -gt 0 ]; then - for rpath in "${unique_bad_rpaths[@]}"; do - run_logged install_name_tool -delete_rpath "$rpath" "$binary" - done - fi - - if ! otool -l "$binary" | awk '/LC_RPATH/{getline; getline; print $2}' | grep -Fxq "@loader_path/lib"; then - run_logged install_name_tool -add_rpath "@loader_path/lib" "$binary" + APP="${{ steps.collect.outputs.stage_dir }}/wsjtx.app" + for file in \ + "${APP}/Contents/PlugIns/platforms/libqcocoa.dylib" \ + "${APP}/Contents/Resources/qt.conf" + do + if [ ! -f "$file" ]; then + echo "::error::Expected macOS app deployment file is missing: ${file}" + exit 1 fi - } - - for bin in "${ASSETS}"/*; do - [ -f "$bin" ] && [ -x "$bin" ] && [ "$(basename "$bin")" != "lib" ] || continue - ensure_cli_rpath "$bin" - bundle_cli_deps "$bin" "@rpath" - run_logged codesign --force --sign - "$bin" - done - - for lib in "${LIBDIR}"/*; do - [ -f "$lib" ] || continue - bundle_cli_deps "$lib" "@rpath" - run_logged codesign --force --sign - "$lib" done - echo "Verifying CLI tools..." - for bin in "${ASSETS}"/*; do - [ -f "$bin" ] && [ -x "$bin" ] && [ "$(basename "$bin")" != "lib" ] && { - BAD=$(otool -L "$bin" | grep "$HOMEBREW_PREFIX" || true) - if [ -n "$BAD" ]; then - echo "ERROR: $(basename "$bin") still has Homebrew refs:" - echo "$BAD" - exit 1 - fi - } - done - echo "All CLI tools are self-contained" - - cp -R "${LIBDIR}" "${STAGE}/lib" - for bin in "${ASSETS}"/*; do - [ -f "$bin" ] && [ -x "$bin" ] && [ "$(basename "$bin")" != "lib" ] && { - cp "$bin" "${STAGE}/$(basename "$bin")" - } - done + - name: Deploy macOS CLI tool dependencies + run: | + .github/scripts/deploy-macos-cli-tools.sh \ + --assets "${{ steps.collect.outputs.assets_dir }}" \ + --stage "${{ steps.collect.outputs.stage_dir }}" \ + --workspace-prefix "${GITHUB_WORKSPACE}" \ + --boost-prefix "${GITHUB_WORKSPACE}/boost-prefix" \ + --fftw-prefix "${GITHUB_WORKSPACE}/fftw-prefix" \ + --libusb-prefix "${GITHUB_WORKSPACE}/libusb-prefix" \ + --portaudio-prefix "${GITHUB_WORKSPACE}/portaudio-prefix" \ + --fortran-prefix "${{ steps.fc.outputs.prefix }}" \ + --fortran-original-prefix "${{ steps.fc.outputs.original_prefix }}" \ + --gcc-lib "${{ steps.fc.outputs.runtime_lib_dir }}" \ + --homebrew-prefix "${HOMEBREW_PREFIX}" - name: Verify bundled macOS deployment targets run: | STAGE="${{ steps.collect.outputs.stage_dir }}" .github/scripts/verify-macos-artifacts.sh \ - --target "${{ inputs.deployment_target }}" \ + --target "${{ env.DEPLOYMENT_TARGET }}" \ --arch "${{ inputs.arch }}" \ "$STAGE" - - name: Import signing certificates - if: steps.check_secrets.outputs.signing_enabled == 'true' - env: - APP_P12: ${{ secrets.DEVELOPER_ID_CERTIFICATE_P12 }} - APP_P12_PW: ${{ secrets.DEVELOPER_ID_CERTIFICATE_PASSWORD }} - INST_P12: ${{ secrets.DEVELOPER_ID_INSTALLER_P12 }} - INST_P12_PW: ${{ secrets.DEVELOPER_ID_INSTALLER_PASSWORD }} - run: | - KEYCHAIN_PATH="$RUNNER_TEMP/signing.keychain-db" - KEYCHAIN_PASSWORD="$(openssl rand -hex 16)" - - security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" - security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH" - security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" - - echo "$APP_P12" | base64 --decode > "$RUNNER_TEMP/app.p12" - security import "$RUNNER_TEMP/app.p12" -P "$APP_P12_PW" -A -t cert -f pkcs12 -k "$KEYCHAIN_PATH" - - echo "$INST_P12" | base64 --decode > "$RUNNER_TEMP/installer.p12" - security import "$RUNNER_TEMP/installer.p12" -P "$INST_P12_PW" -A -t cert -f pkcs12 -k "$KEYCHAIN_PATH" - - security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" - security list-keychains -d user -s "$KEYCHAIN_PATH" login.keychain-db - - APP_IDENTITY=$(security find-identity -v -p codesigning "$KEYCHAIN_PATH" | grep "Developer ID Application" | head -1 | awk -F'"' '{print $2}') - INST_IDENTITY=$(security find-identity -v "$KEYCHAIN_PATH" | grep "Developer ID Installer" | head -1 | awk -F'"' '{print $2}') - echo "App identity: $APP_IDENTITY" - echo "Installer identity: $INST_IDENTITY" - echo "identity=$APP_IDENTITY" >> "$GITHUB_OUTPUT" - echo "installer_identity=$INST_IDENTITY" >> "$GITHUB_OUTPUT" - id: keychain - - # ALWAYS runs. Real Developer ID when secrets are present, ad-hoc - # signing (-) otherwise. Mirrors the Windows self-signed-sandbox - # pattern in build-windows.yml: prove the signing step is wired, - # rely on a real cert in production. Ad-hoc signing produces a - # structurally-valid signature with no Apple trust chain — pkg - # will not pass Gatekeeper without right-click→Open, but is - # well-formed and the all-platforms-ready gate in release.yml - # finds the artifact at the expected path. - - name: Code sign binaries + - name: Ad-hoc sign binaries for build validation run: | STAGE="${{ steps.collect.outputs.stage_dir }}" ASSETS="${{ steps.collect.outputs.assets_dir }}" APP="${STAGE}/wsjtx.app" ENTITLEMENTS="${GITHUB_WORKSPACE}/entitlements.plist" - if [ "${{ steps.check_secrets.outputs.signing_enabled }}" = "true" ]; then - IDENTITY="${{ steps.keychain.outputs.identity }}" - TS="--timestamp" - echo "Code signing mode: Developer ID (real)" - else - IDENTITY="-" - TS="" - echo "Code signing mode: ad-hoc (no Apple trust chain; pkg will be unsigned)" - fi + IDENTITY="-" + echo "Code signing mode: ad-hoc (no Apple trust chain; pkg will be unsigned)" - # entitlements.plist declares com.apple.security.cs.disable- - # library-validation, which is required for any app bundling - # its own non-system frameworks (Qt, etc.) under hardened - # runtime — otherwise dyld refuses to load them. Applied on - # both signing paths: the real-cert path needs it for - # notarization-friendly distribution; the ad-hoc path needs - # it because each ad-hoc signature has its own pseudo-Team-ID - # so the main binary and bundled frameworks never match. - # (The plist is non-empty, so macos-15-intel's codesign now - # parses it cleanly — no need for the conditional that PR #23 - # introduced as a workaround for the empty-plist parser bug.) + # Sign nested code before the containing bundle. Executable + # entitlements are defined in the repository-root plist. find "${APP}/Contents/Frameworks" -type f \( -name "*.dylib" -o -perm +111 \) \ - -exec codesign --force --options runtime $TS --sign "$IDENTITY" {} \; + -exec codesign --force --options runtime --sign "$IDENTITY" {} \; find "${APP}/Contents/Frameworks" -name "*.framework" -type d | while read -r fw; do - codesign --force --options runtime $TS --sign "$IDENTITY" "$fw" + codesign --force --options runtime --sign "$IDENTITY" "$fw" done - if [ -d "${APP}/Contents/PlugIns" ]; then - find "${APP}/Contents/PlugIns" -type f -name "*.dylib" \ - -exec codesign --force --options runtime $TS --sign "$IDENTITY" {} \; - fi + find "${APP}/Contents/PlugIns" -type f -name "*.dylib" \ + -exec codesign --force --options runtime --sign "$IDENTITY" {} \; 2>/dev/null || true find "${APP}/Contents/MacOS" -type f -perm +111 \ - -exec codesign --force --options runtime --entitlements "$ENTITLEMENTS" $TS --sign "$IDENTITY" {} \; - # Bundle-level codesign re-signs the main executable. --force - # without --entitlements would WIPE the entitlements applied - # in the previous step (PR #27 missed this — rc1 shipped with - # an unentitled wsjtx binary, so disable-library-validation - # never took effect and the dyld load of QtSerialPort still - # failed with mismatched Team IDs). - codesign --force --options runtime --entitlements "$ENTITLEMENTS" $TS --sign "$IDENTITY" "${APP}" + -exec codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$IDENTITY" {} \; + # Bundle signing re-signs the main executable, so it must receive the + # entitlement file again. + codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$IDENTITY" "${APP}" codesign --verify --deep --strict --verbose=2 "${APP}" - # Defensive: confirm the entitlement actually made it onto - # the main binary. `codesign --verify` doesn't check - # entitlement presence — it only validates the signature - # itself — so a re-sign that wipes entitlements would still - # pass verify (that's how rc1 shipped broken). + # codesign --verify validates the signature, not required entitlement + # presence. MAIN_BIN="${APP}/Contents/MacOS/wsjtx" - if ! codesign -d --entitlements - "$MAIN_BIN" 2>/dev/null | grep -q "disable-library-validation"; then + ENTITLEMENTS_OUT=$(codesign -d --entitlements - "$MAIN_BIN" 2>/dev/null) + if [[ "$ENTITLEMENTS_OUT" != *"disable-library-validation"* ]]; then echo "::error::wsjtx binary is missing com.apple.security.cs.disable-library-validation entitlement." echo "::error::Bundled Qt frameworks will fail to load under hardened runtime." codesign -d --entitlements - "$MAIN_BIN" || true exit 1 fi echo "Confirmed disable-library-validation entitlement on $MAIN_BIN" + if [[ "$ENTITLEMENTS_OUT" == *"allow-unsigned-executable-memory"* ]]; then + echo "::error::${MAIN_BIN} must not grant unsigned executable memory." + exit 1 + fi + echo "Confirmed no unsigned executable memory entitlement on $MAIN_BIN" for dir in "${STAGE}" "${ASSETS}"; do find "${dir}" -maxdepth 1 -type f -perm +111 \ - -exec codesign --force --options runtime --entitlements "$ENTITLEMENTS" $TS --sign "$IDENTITY" {} \; + -exec codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$IDENTITY" {} \; done for dir in "${STAGE}/lib" "${ASSETS}/lib"; do [ -d "$dir" ] && find "$dir" -type f \ - -exec codesign --force --options runtime $TS --sign "$IDENTITY" {} \; + -exec codesign --force --options runtime --sign "$IDENTITY" {} \; done - # ALWAYS runs. productbuild signs with the Developer ID Installer - # cert when secrets are present; produces an unsigned .pkg - # otherwise. Either way the artifact is named identically and - # satisfies the all-platforms-ready gate in release.yml. - - name: Build and verify installer pkg + - name: Prepare installer package run: | STAGE="${{ steps.collect.outputs.stage_dir }}" - PKG_ID="org.k1jt.wsjtx.${{ inputs.arch }}" - PKG_VERSION="${{ inputs.version }}" + PKG_ID="org.k1jt.wsjtx.${ARCH}" + PKG_VERSION="${VERSION}" PAYLOAD="$RUNNER_TEMP/pkg-payload" SCRIPTS="$RUNNER_TEMP/pkg-scripts" @@ -1036,134 +856,103 @@ jobs: --install-location / \ "$RUNNER_TEMP/wsjtx-component.pkg" - PKG_OUT="wsjtx-${{ inputs.version }}-${{ inputs.arch }}-macOS.pkg" - if [ "${{ steps.check_secrets.outputs.signing_enabled }}" = "true" ]; then - INST_IDENTITY="${{ steps.keychain.outputs.installer_identity }}" - productbuild \ - --package "$RUNNER_TEMP/wsjtx-component.pkg" \ - --sign "$INST_IDENTITY" \ - "$PKG_OUT" - else - productbuild \ - --package "$RUNNER_TEMP/wsjtx-component.pkg" \ - "$PKG_OUT" - fi - + - name: Build unsigned validation package + if: inputs.signing_mode == 'validation' + id: package + run: | + PKG_OUT="wsjtx-${VERSION}-${ARCH}-macOS.pkg" + productbuild \ + --package "$RUNNER_TEMP/wsjtx-component.pkg" \ + "$PKG_OUT" + echo "path=$PKG_OUT" >> "$GITHUB_OUTPUT" + echo "artifact_name=wsjtx-${VERSION}-${ARCH}-macOS-unsigned.pkg" >> "$GITHUB_OUTPUT" + + - name: Verify unsigned validation package + if: inputs.signing_mode == 'validation' + run: | + PKG_OUT="${{ steps.package.outputs.path }}" CHECK_PAYLOAD="$RUNNER_TEMP/pkg-check" - rm -rf "$CHECK_PAYLOAD" pkgutil --expand-full "$PKG_OUT" "$CHECK_PAYLOAD" [ "$(/usr/libexec/PlistBuddy -c "Print :0:BundleIsRelocatable" "$RUNNER_TEMP/components.plist")" = "false" ] [ "$(/usr/libexec/PlistBuddy -c "Print :0:BundleIsVersionChecked" "$RUNNER_TEMP/components.plist")" = "false" ] [ "$(/usr/libexec/PlistBuddy -c "Print :0:BundleOverwriteAction" "$RUNNER_TEMP/components.plist")" = "upgrade" ] - + test -x "$CHECK_PAYLOAD/wsjtx-component.pkg/Payload/Applications/wsjtx.app/Contents/MacOS/qmap" + test -x "$CHECK_PAYLOAD/wsjtx-component.pkg/Payload/Applications/wsjtx.app/Contents/MacOS/map65" APP_PAYLOAD="$CHECK_PAYLOAD/wsjtx-component.pkg/Payload/Applications/wsjtx.app" - DATADIR="${APP_PAYLOAD}/Contents/Resources/wsjtx" - DOCDIR="${APP_PAYLOAD}/Contents/Resources/doc/wsjtx" SOUNDDIR="${APP_PAYLOAD}/Contents/Resources/sounds" - - for file in cty.dat cty.dat_copyright.txt grid.dat sat.dat eclipse.txt ALLCALL7.TXT JPLEPH; do - if [ ! -f "${DATADIR}/${file}" ]; then - echo "::error::Expected packaged data file is missing: ${DATADIR}/${file}" - exit 1 - fi - done - - set -- "${DOCDIR}/wsjtx-main"*.html + set -- "${APP_PAYLOAD}/Contents/Resources/doc/wsjtx/wsjtx-main"*.html if [ "$#" -lt 1 ] || [ ! -f "$1" ]; then echo "::error::Expected at least one local user guide in the packaged app bundle." printf 'Matched paths:\n' printf ' %s\n' "$@" exit 1 fi - if [ ! -f "${SOUNDDIR}/Wanted.wav" ]; then echo "::error::Expected packaged alert sound is missing: ${SOUNDDIR}/Wanted.wav" exit 1 fi - if [ ! -x "${APP_PAYLOAD}/Contents/MacOS/map65" ]; then - echo "::error::Expected packaged MAP65 binary is missing: ${APP_PAYLOAD}/Contents/MacOS/map65" - exit 1 - fi - if [ -e "${APP_PAYLOAD}/Contents/MacOS/sounds" ]; then echo "::error::Packaged alert sounds must not be under Contents/MacOS." exit 1 fi - - echo "Verified packaged local user guides:" - printf ' %s\n' "$@" echo "Verified packaged alert sounds in ${SOUNDDIR}" + .github/scripts/verify-macos-artifacts.sh \ + --target "${{ env.DEPLOYMENT_TARGET }}" \ + --arch "${{ inputs.arch }}" \ + "$CHECK_PAYLOAD/wsjtx-component.pkg/Payload" - - name: Notarize pkg - if: steps.check_secrets.outputs.signing_enabled == 'true' - env: - APPLE_ID: ${{ secrets.APPLE_ID }} - APPLE_ID_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} - APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} + - name: Stage distribution signing input + if: inputs.signing_mode == 'distribution' run: | - notarize_and_staple() { - local file="$1" - echo "Notarizing: $file" - xcrun notarytool submit "$file" \ - --apple-id "$APPLE_ID" \ - --password "$APPLE_ID_PASSWORD" \ - --team-id "$APPLE_TEAM_ID" \ - --wait 2>&1 | tee notarize.log - - if grep -q "status: Invalid" notarize.log; then - SUBMISSION_ID=$(grep "id:" notarize.log | head -1 | awk '{print $2}') - xcrun notarytool log "$SUBMISSION_ID" \ - --apple-id "$APPLE_ID" \ - --password "$APPLE_ID_PASSWORD" \ - --team-id "$APPLE_TEAM_ID" || true - exit 1 - fi - - xcrun stapler staple "$file" - } + mkdir -p distribution-signing-input + cp "${{ runner.temp }}/wsjtx-component.pkg" distribution-signing-input/ + cp "${{ runner.temp }}/components.plist" distribution-signing-input/ + cp entitlements.plist distribution-signing-input/ - notarize_and_staple "wsjtx-${{ inputs.version }}-${{ inputs.arch }}-macOS.pkg" + - name: Upload distribution signing input + if: inputs.signing_mode == 'distribution' + uses: actions/upload-artifact@v7 + with: + name: macos-signing-input-${{ inputs.version }}-${{ inputs.arch }} + path: distribution-signing-input + retention-days: 1 - - name: Notarize CLI tools - if: steps.check_secrets.outputs.signing_enabled == 'true' - env: - APPLE_ID: ${{ secrets.APPLE_ID }} - APPLE_ID_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} - APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} + - name: Write validation signing report + if: inputs.signing_mode == 'validation' run: | - ASSETS="${{ steps.collect.outputs.assets_dir }}" - zip -r cli-tools.zip "${ASSETS}"/ - xcrun notarytool submit cli-tools.zip \ - --apple-id "$APPLE_ID" \ - --password "$APPLE_ID_PASSWORD" \ - --team-id "$APPLE_TEAM_ID" \ - --wait 2>&1 | tee notarize-cli.log - - if grep -q "status: Invalid" notarize-cli.log; then - SUBMISSION_ID=$(grep "id:" notarize-cli.log | head -1 | awk '{print $2}') - xcrun notarytool log "$SUBMISSION_ID" \ - --apple-id "$APPLE_ID" \ - --password "$APPLE_ID_PASSWORD" \ - --team-id "$APPLE_TEAM_ID" || true + PKG_OUT="${{ steps.package.outputs.path }}" + PKG_SIGNATURE=$(pkgutil --check-signature "$PKG_OUT" 2>&1 || true) + printf '%s\n' "$PKG_SIGNATURE" + if [[ "$PKG_SIGNATURE" != *"Status: no signature"* ]]; then + echo "::error::Validation package did not report the expected unsigned status." exit 1 fi - rm cli-tools.zip - - - name: Clean up keychain - if: always() && steps.check_secrets.outputs.signing_enabled == 'true' - run: security delete-keychain "$RUNNER_TEMP/signing.keychain-db" 2>/dev/null || true + SHA256=$(shasum -a 256 "$PKG_OUT" | awk '{print $1}') + jq -n \ + --arg mode validation \ + --arg artifact "$PKG_OUT" \ + --arg sha256 "$SHA256" \ + --arg git_sha "$GITHUB_SHA" \ + '{schema_version: 1, mode: $mode, artifact: $artifact, sha256: $sha256, git_sha: $git_sha, signed: false, notarized: false, publishable: false}' \ + > macos-signing-report.json - name: Upload pkg + if: inputs.signing_mode == 'validation' + uses: actions/upload-artifact@v7 + with: + name: ${{ steps.package.outputs.artifact_name }} + path: ${{ steps.package.outputs.path }} + + - name: Upload signing report + if: inputs.signing_mode == 'validation' uses: actions/upload-artifact@v7 with: - name: wsjtx-${{ inputs.version }}-${{ inputs.arch }}-macOS.pkg - path: wsjtx-${{ inputs.version }}-${{ inputs.arch }}-macOS.pkg + name: macos-signing-report-${{ inputs.version }}-${{ inputs.arch }} + path: macos-signing-report.json - name: Package individual binaries run: | - # Tarball and inner-dir names include the arch suffix so arm64 - # and x86_64 per-binary artifacts can coexist in a single - # GitHub Release without ReleaseAsset.name collisions (#24). + # Architecture-qualified names prevent release-asset collisions. ASSETS="${{ steps.collect.outputs.assets_dir }}" ARCH="${{ inputs.arch }}" PKGS=packages @@ -1185,3 +974,260 @@ jobs: with: name: individual-binaries-macos-${{ inputs.arch }} path: packages/*.tar.gz + + # Keep repository-built code after signing, notarization, cleanup, and + # artifact publication so a detached child cannot reach later secrets. + - name: Smoke-launch deployed WSJT-X app + id: deployed_wsjtx_smoke + timeout-minutes: 1 + run: | + APP="${GITHUB_WORKSPACE}/${{ steps.collect.outputs.stage_dir }}/wsjtx.app" + DIAGNOSTICS="${GITHUB_WORKSPACE}/wsjtx-build/deployed-startup-smoke-diagnostics" + + unset DYLD_LIBRARY_PATH + unset DYLD_FRAMEWORK_PATH + unset DYLD_INSERT_LIBRARIES + unset DYLD_ROOT_PATH + unset DYLD_IMAGE_SUFFIX + unset QT_PLUGIN_PATH + unset QT_QPA_PLATFORM_PLUGIN_PATH + unset QML_IMPORT_PATH + unset QML2_IMPORT_PATH + + export DYLD_FALLBACK_LIBRARY_PATH="/usr/lib" + export DYLD_FALLBACK_FRAMEWORK_PATH="/System/Library/Frameworks" + export QT_QPA_PLATFORM="cocoa" + export PATH="/usr/bin:/bin:/usr/sbin:/sbin" + + cd "$RUNNER_TEMP" + /bin/bash "${GITHUB_WORKSPACE}/test/run-wsjtx-startup-macos.sh" \ + "$DIAGNOSTICS" \ + "${APP}/Contents/MacOS/wsjtx" \ + --startup-smoke-test \ + --rig-name CI-DEPLOYED-STARTUP + + - name: Upload deployed WSJT-X startup diagnostics + if: failure() && steps.deployed_wsjtx_smoke.outcome == 'failure' + uses: actions/upload-artifact@v7 + with: + name: wsjtx-deployed-startup-smoke-macos-${{ inputs.arch }} + path: wsjtx-build/deployed-startup-smoke-diagnostics + if-no-files-found: ignore + retention-days: 7 + + sign_distribution: + if: inputs.signing_mode == 'distribution' + needs: build + runs-on: ${{ inputs.runner || (inputs.arch == 'x86_64' && 'macos-15-intel' || 'macos-15') }} + timeout-minutes: 30 + environment: apple-release-signing + env: + VERSION: ${{ inputs.version }} + ARCH: ${{ inputs.arch }} + APPLE_TEAM_ID: ${{ inputs.apple_team_id || vars.APPLE_TEAM_ID }} + APP_CERT_SHA1: ${{ inputs.application_certificate_sha1 || vars.APPLE_APPLICATION_CERTIFICATE_SHA1 }} + INST_CERT_SHA1: ${{ inputs.installer_certificate_sha1 || vars.APPLE_INSTALLER_CERTIFICATE_SHA1 }} + steps: + - name: Validate distribution credentials + env: + APP_P12: ${{ secrets.DEVELOPER_ID_CERTIFICATE_P12 }} + APP_P12_PW: ${{ secrets.DEVELOPER_ID_CERTIFICATE_PASSWORD }} + INST_P12: ${{ secrets.DEVELOPER_ID_INSTALLER_P12 }} + INST_P12_PW: ${{ secrets.DEVELOPER_ID_INSTALLER_PASSWORD }} + ASC_KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }} + ASC_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }} + ASC_PRIVATE_KEY_P8_BASE64: ${{ secrets.APP_STORE_CONNECT_PRIVATE_KEY_P8_BASE64 }} + run: | + missing=() + for name in APP_P12 APP_P12_PW INST_P12 INST_P12_PW ASC_KEY_ID ASC_ISSUER_ID ASC_PRIVATE_KEY_P8_BASE64 APPLE_TEAM_ID APP_CERT_SHA1 INST_CERT_SHA1; do + [ -n "${!name}" ] || missing+=("$name") + done + if [ "${#missing[@]}" -ne 0 ]; then + printf '::error::Distribution signing is missing required credentials or identity configuration: %s\n' "${missing[*]}" + exit 1 + fi + + - name: Download unsigned component package + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 + with: + name: macos-signing-input-${{ inputs.version }}-${{ inputs.arch }} + path: signing-input + + - name: Expand signing input without executing it + run: | + pkgutil --expand-full signing-input/wsjtx-component.pkg "$RUNNER_TEMP/expanded-component" + test -d "$RUNNER_TEMP/expanded-component/Payload/Applications/wsjtx.app" + test -d "$RUNNER_TEMP/expanded-component/Payload/usr/local/wsjtx" + + - name: Import and verify Developer ID identities + id: identities + env: + APP_P12: ${{ secrets.DEVELOPER_ID_CERTIFICATE_P12 }} + APP_P12_PW: ${{ secrets.DEVELOPER_ID_CERTIFICATE_PASSWORD }} + INST_P12: ${{ secrets.DEVELOPER_ID_INSTALLER_P12 }} + INST_P12_PW: ${{ secrets.DEVELOPER_ID_INSTALLER_PASSWORD }} + run: | + KEYCHAIN_PATH="$RUNNER_TEMP/release-signing.keychain-db" + KEYCHAIN_PASSWORD="$(openssl rand -hex 16)" + security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" + security set-keychain-settings -lut 1800 "$KEYCHAIN_PATH" + security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" + printf '%s' "$APP_P12" | base64 --decode > "$RUNNER_TEMP/app.p12" + printf '%s' "$INST_P12" | base64 --decode > "$RUNNER_TEMP/installer.p12" + security import "$RUNNER_TEMP/app.p12" -P "$APP_P12_PW" -A -t cert -f pkcs12 -k "$KEYCHAIN_PATH" + security import "$RUNNER_TEMP/installer.p12" -P "$INST_P12_PW" -A -t cert -f pkcs12 -k "$KEYCHAIN_PATH" + rm -f "$RUNNER_TEMP/app.p12" "$RUNNER_TEMP/installer.p12" + security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" + security list-keychains -d user -s "$KEYCHAIN_PATH" login.keychain-db + + APP_IDENTITY=$(security find-identity -v -p codesigning "$KEYCHAIN_PATH" | awk -F'"' '/Developer ID Application/ {print $2; exit}') + INST_IDENTITY=$(security find-identity -v "$KEYCHAIN_PATH" | awk -F'"' '/Developer ID Installer/ {print $2; exit}') + [ -n "$APP_IDENTITY" ] || { echo "::error::No Developer ID Application identity was imported."; exit 1; } + [ -n "$INST_IDENTITY" ] || { echo "::error::No Developer ID Installer identity was imported."; exit 1; } + [[ "$APP_IDENTITY" == *"(${APPLE_TEAM_ID})"* ]] || { echo "::error::Application identity is not owned by the expected team."; exit 1; } + [[ "$INST_IDENTITY" == *"(${APPLE_TEAM_ID})"* ]] || { echo "::error::Installer identity is not owned by the expected team."; exit 1; } + + app_actual=$(security find-certificate -c "$APP_IDENTITY" -Z "$KEYCHAIN_PATH" | awk '/SHA-1 hash:/ {print toupper($3); exit}') + inst_actual=$(security find-certificate -c "$INST_IDENTITY" -Z "$KEYCHAIN_PATH" | awk '/SHA-1 hash:/ {print toupper($3); exit}') + app_expected=$(printf '%s' "$APP_CERT_SHA1" | tr -d ': ' | tr '[:lower:]' '[:upper:]') + inst_expected=$(printf '%s' "$INST_CERT_SHA1" | tr -d ': ' | tr '[:lower:]' '[:upper:]') + [ "$app_actual" = "$app_expected" ] || { echo "::error::Application certificate fingerprint mismatch."; exit 1; } + [ "$inst_actual" = "$inst_expected" ] || { echo "::error::Installer certificate fingerprint mismatch."; exit 1; } + echo "application=$APP_IDENTITY" >> "$GITHUB_OUTPUT" + echo "installer=$INST_IDENTITY" >> "$GITHUB_OUTPUT" + + - name: Sign staged application and command-line tools + env: + APP_IDENTITY: ${{ steps.identities.outputs.application }} + run: | + PAYLOAD="$RUNNER_TEMP/expanded-component/Payload" + APP="$PAYLOAD/Applications/wsjtx.app" + ENTITLEMENTS="$GITHUB_WORKSPACE/signing-input/entitlements.plist" + test -f "$ENTITLEMENTS" + + find "$APP/Contents/Frameworks" -type f \( -name "*.dylib" -o -perm +111 \) \ + -exec codesign --force --options runtime --timestamp --sign "$APP_IDENTITY" {} \; + find "$APP/Contents/Frameworks" -name "*.framework" -type d | while read -r framework; do + codesign --force --options runtime --timestamp --sign "$APP_IDENTITY" "$framework" + done + find "$APP/Contents/PlugIns" -type f -name "*.dylib" \ + -exec codesign --force --options runtime --timestamp --sign "$APP_IDENTITY" {} \; + find "$APP/Contents/MacOS" -type f -perm +111 \ + -exec codesign --force --options runtime --entitlements "$ENTITLEMENTS" --timestamp --sign "$APP_IDENTITY" {} \; + codesign --force --options runtime --entitlements "$ENTITLEMENTS" --timestamp --sign "$APP_IDENTITY" "$APP" + + find "$PAYLOAD/usr/local/wsjtx" -maxdepth 1 -type f -perm +111 \ + -exec codesign --force --options runtime --entitlements "$ENTITLEMENTS" --timestamp --sign "$APP_IDENTITY" {} \; + [ ! -d "$PAYLOAD/usr/local/wsjtx/lib" ] || find "$PAYLOAD/usr/local/wsjtx/lib" -type f \ + -exec codesign --force --options runtime --timestamp --sign "$APP_IDENTITY" {} \; + codesign --verify --deep --strict --verbose=2 "$APP" + + - name: Build signed distribution package + id: package + env: + INST_IDENTITY: ${{ steps.identities.outputs.installer }} + run: | + COMPONENT="$RUNNER_TEMP/wsjtx-signed-component.pkg" + pkgbuild \ + --root "$RUNNER_TEMP/expanded-component/Payload" \ + --scripts "$RUNNER_TEMP/expanded-component/Scripts" \ + --component-plist "$GITHUB_WORKSPACE/signing-input/components.plist" \ + --identifier "org.k1jt.wsjtx.${ARCH}" \ + --version "$VERSION" \ + --install-location / \ + "$COMPONENT" + pkgutil --payload-files "$COMPONENT" >/dev/null + PKG_OUT="wsjtx-${VERSION}-${ARCH}-macOS.pkg" + productbuild \ + --package "$COMPONENT" \ + --sign "$INST_IDENTITY" \ + "$PKG_OUT" + echo "path=$PKG_OUT" >> "$GITHUB_OUTPUT" + + - name: Verify rebuilt distribution package + run: | + PKG_OUT="${{ steps.package.outputs.path }}" + CHECK_PACKAGE="$RUNNER_TEMP/signed-package-check" + pkgutil --expand-full "$PKG_OUT" "$CHECK_PACKAGE" + COMPONENT="$CHECK_PACKAGE/wsjtx-signed-component.pkg" + PAYLOAD="$COMPONENT/Payload" + APP="$PAYLOAD/Applications/wsjtx.app" + test -x "$APP/Contents/MacOS/qmap" + test -x "$APP/Contents/MacOS/map65" + test -x "$COMPONENT/Scripts/postinstall" + test -d "$PAYLOAD/usr/local/wsjtx" + codesign --verify --deep --strict --verbose=2 "$APP" + + - name: Notarize and staple distribution package + id: notarize + env: + ASC_KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }} + ASC_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }} + ASC_PRIVATE_KEY_P8_BASE64: ${{ secrets.APP_STORE_CONNECT_PRIVATE_KEY_P8_BASE64 }} + run: | + KEY_PATH="$RUNNER_TEMP/AuthKey_${ASC_KEY_ID}.p8" + printf '%s' "$ASC_PRIVATE_KEY_P8_BASE64" | base64 --decode > "$KEY_PATH" + chmod 600 "$KEY_PATH" + xcrun notarytool submit "${{ steps.package.outputs.path }}" \ + --key "$KEY_PATH" \ + --key-id "$ASC_KEY_ID" \ + --issuer "$ASC_ISSUER_ID" \ + --wait --output-format json > notarization.json + SUBMISSION_ID=$(jq -r '.id // empty' notarization.json) + STATUS=$(jq -r '.status // empty' notarization.json) + if [ "$STATUS" != "Accepted" ] || [ -z "$SUBMISSION_ID" ]; then + echo "::error::Apple notarization did not return Accepted (status=${STATUS:-missing})." + [ -n "$SUBMISSION_ID" ] && xcrun notarytool log "$SUBMISSION_ID" \ + --key "$KEY_PATH" --key-id "$ASC_KEY_ID" --issuer "$ASC_ISSUER_ID" || true + exit 1 + fi + xcrun stapler staple "${{ steps.package.outputs.path }}" + xcrun stapler validate "${{ steps.package.outputs.path }}" + echo "submission_id=$SUBMISSION_ID" >> "$GITHUB_OUTPUT" + echo "status=$STATUS" >> "$GITHUB_OUTPUT" + rm -f "$KEY_PATH" + + - name: Verify distribution trust and write signing report + run: | + PKG_OUT="${{ steps.package.outputs.path }}" + COMPONENT="$RUNNER_TEMP/signed-package-check/wsjtx-signed-component.pkg" + APP="$COMPONENT/Payload/Applications/wsjtx.app" + codesign --verify --deep --strict --verbose=2 "$APP" + codesign -dv --verbose=4 "$APP" 2> codesign-details.txt + grep -F "TeamIdentifier=${APPLE_TEAM_ID}" codesign-details.txt + pkgutil --check-signature "$PKG_OUT" | tee pkg-signature.txt + grep -F "Developer ID Installer:" pkg-signature.txt + grep -F "(${APPLE_TEAM_ID})" pkg-signature.txt + xcrun stapler validate "$PKG_OUT" + spctl --assess --type install --verbose=4 "$PKG_OUT" + SHA256=$(shasum -a 256 "$PKG_OUT" | awk '{print $1}') + jq -n \ + --arg mode distribution \ + --arg artifact "$PKG_OUT" \ + --arg sha256 "$SHA256" \ + --arg git_sha "$GITHUB_SHA" \ + --arg team_id "$APPLE_TEAM_ID" \ + --arg app_certificate_sha1 "$(printf '%s' "$APP_CERT_SHA1" | tr -d ': ' | tr '[:lower:]' '[:upper:]')" \ + --arg installer_certificate_sha1 "$(printf '%s' "$INST_CERT_SHA1" | tr -d ': ' | tr '[:lower:]' '[:upper:]')" \ + --arg notarization_id "${{ steps.notarize.outputs.submission_id }}" \ + --arg notarization_status "${{ steps.notarize.outputs.status }}" \ + '{schema_version: 1, mode: $mode, artifact: $artifact, sha256: $sha256, git_sha: $git_sha, team_id: $team_id, application_certificate_sha1: $app_certificate_sha1, installer_certificate_sha1: $installer_certificate_sha1, notarization: {id: $notarization_id, status: $notarization_status}, stapled: true, gatekeeper_accepted: true, isolated_signing_job: true}' \ + > macos-signing-report.json + + - name: Remove signing credentials + if: always() + run: | + rm -f "$RUNNER_TEMP/app.p12" "$RUNNER_TEMP/installer.p12" "$RUNNER_TEMP"/AuthKey_*.p8 + security delete-keychain "$RUNNER_TEMP/release-signing.keychain-db" 2>/dev/null || true + + - name: Upload signed distribution package + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: ${{ steps.package.outputs.path }} + path: ${{ steps.package.outputs.path }} + + - name: Upload distribution signing report + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: macos-signing-report-${{ inputs.version }}-${{ inputs.arch }} + path: macos-signing-report.json diff --git a/.github/workflows/build-selected-artifacts.yml b/.github/workflows/build-selected-artifacts.yml new file mode 100644 index 00000000..71e33737 --- /dev/null +++ b/.github/workflows/build-selected-artifacts.yml @@ -0,0 +1,181 @@ +name: Build Selected Artifacts + +on: + workflow_dispatch: + inputs: + targets: + description: "Artifact set to build" + required: true + type: choice + options: + - macos-arm64 + - windows-x64 + - macos-arm64-windows-x64 + - linux-x64 + - linux-arm64 + - macos-x64 + - all + default: macos-arm64 + mode: + description: "Build selected artifacts immediately or gate them on Linux x64 first" + required: true + type: choice + options: + - artifact-now + - linux-smoke-first + default: artifact-now + recache: + description: "Force ccache to recompile and refresh cached objects" + required: false + type: boolean + default: false + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.targets }}-${{ inputs.mode }} + cancel-in-progress: false + +permissions: + contents: read + packages: read + +jobs: + prepare: + runs-on: ubuntu-latest + timeout-minutes: 10 + outputs: + version: ${{ steps.v.outputs.version }} + release_channel: ${{ steps.v.outputs.release_channel }} + rc_number: ${{ steps.v.outputs.rc_number }} + linux_image_tag: ${{ steps.linux-image.outputs.image_tag }} + steps: + - uses: actions/checkout@v7 + - id: v + run: | + STATE=$(python3 .github/scripts/release-policy.py read-state) + VERSION=$(jq -r .version <<<"$STATE") + CHANNEL=$(jq -r .channel <<<"$STATE") + RC_NUMBER=$(jq -r .rc <<<"$STATE") + echo "Derived version from release-state.txt: $VERSION" + { + echo "version=$VERSION" + echo "release_channel=$CHANNEL" + echo "rc_number=$RC_NUMBER" + } >> "$GITHUB_OUTPUT" + - id: linux-image + name: Resolve Linux CI image generation + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: .github/scripts/resolve-linux-ci-image-tag.py + + # In linux-smoke-first mode, this is both the cheap gate and a normal Linux + # x64 artifact build. Do not also run linux-x64 for the same dispatch. + linux-smoke-x64: + needs: [prepare] + if: inputs.mode == 'linux-smoke-first' + 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 }} + save_ccache: true + recache: ${{ inputs.recache }} + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} + + linux-x64: + needs: [prepare] + if: >- + inputs.mode != 'linux-smoke-first' && + (inputs.targets == 'linux-x64' || inputs.targets == 'all') + 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 }} + save_ccache: true + recache: ${{ inputs.recache }} + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} + + linux-arm64: + needs: [prepare, linux-smoke-x64] + if: >- + always() && + !cancelled() && + needs.prepare.result == 'success' && + (needs.linux-smoke-x64.result == 'success' || needs.linux-smoke-x64.result == 'skipped') && + (inputs.targets == 'linux-arm64' || inputs.targets == 'all') + 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 }} + save_ccache: true + recache: ${{ inputs.recache }} + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} + + macos-arm64: + needs: [prepare, linux-smoke-x64] + if: >- + always() && + !cancelled() && + needs.prepare.result == 'success' && + (needs.linux-smoke-x64.result == 'success' || needs.linux-smoke-x64.result == 'skipped') && + ( + inputs.targets == 'macos-arm64' || + inputs.targets == 'macos-arm64-windows-x64' || + inputs.targets == 'all' + ) + 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 }} + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} + + macos-x64: + needs: [prepare, linux-smoke-x64] + if: >- + always() && + !cancelled() && + needs.prepare.result == 'success' && + (needs.linux-smoke-x64.result == 'success' || needs.linux-smoke-x64.result == 'skipped') && + (inputs.targets == 'macos-x64' || inputs.targets == 'all') + 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 }} + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} + + windows-x64: + needs: [prepare, linux-smoke-x64] + if: >- + always() && + !cancelled() && + needs.prepare.result == 'success' && + (needs.linux-smoke-x64.result == 'success' || needs.linux-smoke-x64.result == 'skipped') && + ( + inputs.targets == 'windows-x64' || + inputs.targets == 'macos-arm64-windows-x64' || + inputs.targets == 'all' + ) + uses: ./.github/workflows/build-windows.yml + with: + version: ${{ needs.prepare.outputs.version }} + hamlib_branch: "4.7.2" + recache: ${{ inputs.recache }} + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index 1d6f8ec9..c2dca58d 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -11,7 +11,17 @@ on: description: "Hamlib branch to build" required: false type: string - default: "4.7.0" + default: "4.7.2" + recache: + description: "Force ccache to recompile and refresh cached objects" + required: false + type: boolean + default: false + save_ccache: + description: "Persist compiler objects from a trusted develop build" + required: false + type: boolean + default: false release_channel: description: "Build release channel: DEVEL, RC, or GA" required: false @@ -22,10 +32,69 @@ on: required: false type: string default: "" + outputs: + installer-artifact-id: + description: "Installer artifact id, for the SignPath submit step" + value: ${{ jobs.build.outputs.installer-artifact-id }} + # Also runnable on its own ("Run workflow" / gh workflow run) to build just + # the Windows installer, at ~1/6 the cost of the full ci.yml matrix. GitHub + # only exposes workflow_dispatch when the trigger is present on the default + # branch, so this must be merged to develop before it can be dispatched. + # Inputs mirror workflow_call with standalone defaults: hamlib_branch matches + # what ci.yml / release.yml actually pass (4.7.2, not the workflow_call legacy + # default), and version defaults to a clearly-marked devel string -- overridable + # via `-f version=...` -- so a manual build is never mistaken for a release. + workflow_dispatch: + inputs: + version: + description: "WSJT-X version string (installer filename + artifact names)" + required: false + type: string + default: "3.2.0-devel" + hamlib_branch: + description: "Hamlib branch to build" + required: false + type: string + default: "4.7.2" + recache: + description: "Force ccache to recompile and refresh cached objects" + required: false + type: boolean + default: false + save_ccache: + description: "Persist compiler objects when dispatching on develop" + required: false + type: boolean + default: true + release_channel: + description: "Build release channel" + required: false + type: choice + options: + - DEVEL + - RC + - GA + default: "DEVEL" + rc_number: + description: "Release candidate number when release_channel is RC" + required: false + type: string + default: "" jobs: build: runs-on: windows-latest + timeout-minutes: 100 + outputs: + installer-artifact-id: ${{ steps.upload_installer.outputs.artifact-id }} + env: + BOOST_VERSION: 1.91.0 + BOOST_SOURCE_SHA256: de5e6b0e4913395c6bdfa90537febd9028ea4c0735d2cdb0cd9b45d5f51264f5 + WSJT_WINDOWS_API_FLOOR: "0x0601" + VERSION: ${{ inputs.version }} + HAMLIB_BRANCH: ${{ inputs.hamlib_branch }} + WSJT_RELEASE_CHANNEL: ${{ inputs.release_channel }} + WSJT_RC_NUMBER: ${{ inputs.rc_number }} defaults: run: shell: msys2 {0} @@ -41,8 +110,16 @@ jobs: shell: pwsh run: git config --global core.autocrlf false - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 + - name: Validate workflow inputs + shell: bash + env: + WSJTX_VERSION: ${{ inputs.version }} + run: .github/scripts/validate-ci-inputs.sh + + # 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 @@ -52,6 +129,7 @@ jobs: git make tar mingw-w64-x86_64-gcc mingw-w64-x86_64-gcc-fortran + mingw-w64-x86_64-ccache mingw-w64-x86_64-cmake mingw-w64-x86_64-qt5-base mingw-w64-x86_64-qt5-multimedia @@ -61,12 +139,10 @@ jobs: mingw-w64-x86_64-qt5-websockets mingw-w64-x86_64-qt5-activeqt mingw-w64-x86_64-fftw - mingw-w64-x86_64-boost mingw-w64-x86_64-libusb mingw-w64-x86_64-portaudio mingw-w64-x86_64-pkg-config mingw-w64-x86_64-nsis - mingw-w64-x86_64-osslsigncode mingw-w64-x86_64-ruby autoconf automake libtool @@ -76,73 +152,44 @@ jobs: - name: Install asciidoctor (Ruby gem) run: gem install asciidoctor --no-document - - name: Cache pFUnit - id: pfunit-cache - uses: actions/cache@v5 - with: - path: pfunit-prefix - key: pfunit-windows-v4.9.0-${{ hashFiles('.github/workflows/build-windows.yml') }} + - name: Select ccache key + id: ccache-key + shell: bash + env: + RECACHE: ${{ inputs.recache }} + run: .github/scripts/select-ccache-key-suffix.sh - - name: Build pFUnit - if: steps.pfunit-cache.outputs.cache-hit != 'true' - run: | - WORKSPACE=$(cygpath "${GITHUB_WORKSPACE}") - git config --global core.longpaths true - 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 -G "MSYS Makefiles" \ - -DSKIP_MPI=YES \ - -DSKIP_OPENMP=YES \ - -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ - -DCMAKE_INSTALL_PREFIX="${WORKSPACE}/pfunit-prefix" - cmake --build pfunit-build -j$(nproc) - cmake --install pfunit-build + - name: Restore ccache + id: ccache + uses: actions/cache/restore@v6 + with: + path: .ccache + key: ccache-windows-x86_64-gcc-${{ github.sha }}${{ steps.ccache-key.outputs.suffix }} + restore-keys: | + ccache-windows-x86_64-gcc- - - name: Locate pFUnit config - id: pfunit + - name: Configure ccache run: | WORKSPACE=$(cygpath "${GITHUB_WORKSPACE}") - # Locate each sub-package's config directly — MSYS2 pkg-config - # interacts badly with multi-entry CMAKE_PREFIX_PATH, so we pass - # explicit <pkg>_DIR hints instead. - for pkg in PFUNIT GFTL GFTL_SHARED FARGPARSE; do - CONFIG=$(find "${WORKSPACE}/pfunit-prefix" -name ${pkg}Config.cmake | head -1) - if [ -z "$CONFIG" ]; then - echo "ERROR: ${pkg}Config.cmake not found under pfunit-prefix" - find "${WORKSPACE}/pfunit-prefix" -maxdepth 3 -type d - exit 1 - fi - DIR="$(dirname "$CONFIG")" - echo "Found ${pkg}Config.cmake at: $CONFIG" - echo "$(echo $pkg | tr '[:upper:]' '[:lower:]')_dir=${DIR}" >> "$GITHUB_OUTPUT" - done + echo "CCACHE_DIR=${WORKSPACE}/.ccache" >> "$GITHUB_ENV" + echo "ccache recache: ${{ inputs.recache }}" + if [ "${{ inputs.recache }}" = "true" ]; then + echo "CCACHE_RECACHE=1" >> "$GITHUB_ENV" + echo "Forcing ccache recache for this run" + fi + mkdir -p "${WORKSPACE}/.ccache" + ccache --version + ccache --zero-stats - - name: Cache Hamlib - id: hamlib-cache - uses: actions/cache@v5 + - name: Build Windows dependencies + id: windows-deps + uses: ./.github/actions/build-windows-deps with: - path: hamlib-prefix - key: hamlib-windows-${{ inputs.hamlib_branch }}-${{ hashFiles('.github/workflows/build-windows.yml') }} - - - name: Build Hamlib - if: steps.hamlib-cache.outputs.cache-hit != 'true' - env: - MSYS2_PATH_TYPE: inherit - run: | - WORKSPACE=$(cygpath "${GITHUB_WORKSPACE}") - git clone --depth 1 --branch "${{ inputs.hamlib_branch }}" \ - https://github.com/Hamlib/Hamlib.git hamlib-src - cd hamlib-src - ./bootstrap - ./configure \ - --prefix="${WORKSPACE}/hamlib-prefix" \ - --enable-shared --disable-static \ - --without-cxx-binding \ - --without-readline \ - CFLAGS="-DNDEBUG -g -O2 -fdata-sections -ffunction-sections" \ - LDFLAGS="-Wl,--gc-sections" - make -j$(nproc) - make install-strip + boost_version: ${{ env.BOOST_VERSION }} + boost_source_sha256: ${{ env.BOOST_SOURCE_SHA256 }} + windows_api_floor: ${{ env.WSJT_WINDOWS_API_FLOOR }} + hamlib_branch: ${{ inputs.hamlib_branch }} + save_caches: ${{ github.event_name != 'pull_request' }} - name: Install OmniRig shell: pwsh @@ -159,35 +206,71 @@ jobs: if (-not $omnirig) { throw "OmniRig install failed — OmniRig.exe not found" } echo "OMNIRIG_PATH=$($omnirig.FullName)" >> $env:GITHUB_ENV - - name: Fix dumpcpp name (MSYS2 ships dumpcpp-qt5, CMake expects dumpcpp) - run: | - ln -sf /mingw64/bin/dumpcpp-qt5.exe /mingw64/bin/dumpcpp.exe - - - name: Configure + - name: Configure build and tests run: | WORKSPACE=$(cygpath "${GITHUB_WORKSPACE}") OMNIRIG=$(cygpath "${OMNIRIG_PATH}") + BOOST_PREFIX="${{ steps.windows-deps.outputs.boost_prefix }}" + HAMLIB_PREFIX="${{ steps.windows-deps.outputs.hamlib_prefix }}" cmake -G "MSYS Makefiles" -S . -B wsjtx-build \ - -DCMAKE_PREFIX_PATH="${WORKSPACE}/hamlib-prefix" \ + -DCMAKE_PREFIX_PATH="${BOOST_PREFIX};${HAMLIB_PREFIX}" \ + -DBOOST_ROOT="${BOOST_PREFIX}" \ + -DBOOST_INCLUDEDIR="${BOOST_PREFIX}/include" \ + -DBOOST_LIBRARYDIR="${BOOST_PREFIX}/lib" \ + -DHamlib_INCLUDE_DIR="${HAMLIB_PREFIX}/include" \ + -DHamlib_LIBRARY="${HAMLIB_PREFIX}/lib/libhamlib.dll.a" \ + -DRIGCTL_EXE="${HAMLIB_PREFIX}/bin/rigctl.exe" \ + -DRIGCTLD_EXE="${HAMLIB_PREFIX}/bin/rigctld.exe" \ + -DRIGCTLCOM_EXE="${HAMLIB_PREFIX}/bin/rigctlcom.exe" \ + -DCMAKE_C_FLAGS="-D_WIN32_WINNT=${WSJT_WINDOWS_API_FLOOR} -DWINVER=${WSJT_WINDOWS_API_FLOOR}" \ + -DCMAKE_CXX_FLAGS="-D_WIN32_WINNT=${WSJT_WINDOWS_API_FLOOR} -DWINVER=${WSJT_WINDOWS_API_FLOOR} -DBOOST_USE_WINAPI_VERSION=${WSJT_WINDOWS_API_FLOOR}" \ + -DBoost_NO_SYSTEM_PATHS=ON \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DOMNIRIG_TYPE_LIB="${OMNIRIG}" \ -DCMAKE_Fortran_FLAGS="-fallow-argument-mismatch -std=legacy" \ - -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ -DWSJT_SKIP_MANPAGES=ON \ - -DWSJT_BUILD_TESTS=ON \ - -DWSJT_RELEASE_CHANNEL="${{ inputs.release_channel }}" \ - -DWSJT_RC_NUMBER="${{ inputs.rc_number }}" \ - -DPFUNIT_DIR="${{ steps.pfunit.outputs.pfunit_dir }}" \ - -DGFTL_DIR="${{ steps.pfunit.outputs.gftl_dir }}" \ - -DGFTL_SHARED_DIR="${{ steps.pfunit.outputs.gftl_shared_dir }}" \ - -DFARGPARSE_DIR="${{ steps.pfunit.outputs.fargparse_dir }}" \ + -DWSJT_ENABLE_TESTS=ON \ + -DWSJT_FORTRAN_LIBRARY_VARIANTS=OPENMP_ONLY \ + -DWSJT_RELEASE_CHANNEL="${WSJT_RELEASE_CHANNEL}" \ + -DWSJT_RC_NUMBER="${WSJT_RC_NUMBER}" \ + -DPFUNIT_DIR="${{ steps.windows-deps.outputs.pfunit_dir }}" \ + -DGFTL_DIR="${{ steps.windows-deps.outputs.gftl_dir }}" \ + -DGFTL_SHARED_DIR="${{ steps.windows-deps.outputs.gftl_shared_dir }}" \ + -DFARGPARSE_DIR="${{ steps.windows-deps.outputs.fargparse_dir }}" \ -Wno-dev - - name: Build + - name: Build and test targets run: cmake --build wsjtx-build -j$(nproc) + - name: Show ccache stats + if: always() + run: ccache --show-stats + + - name: Report suppressed ccache save + if: ${{ (inputs.save_ccache || inputs.recache) && github.ref != 'refs/heads/develop' }} + run: echo "::notice::Not saving ccache because shared compiler caches are published only from develop" + + - name: Save ccache + if: ${{ success() && (inputs.save_ccache || inputs.recache) && github.ref == 'refs/heads/develop' && steps.ccache.outputs.cache-hit != 'true' }} + uses: actions/cache/save@v6 + with: + path: .ccache + key: ${{ steps.ccache.outputs.cache-primary-key }} + - name: Run tests id: ctest - run: ctest --output-on-failure --output-junit ctest-results.xml + run: | + # Tests that link wsjt_qt (e.g. test_jtty_txstream) pull in the + # rig-control code, so their exe imports libhamlib-4.dll. Hamlib is + # built --enable-shared into hamlib-prefix, so hamlib-prefix/bin must + # be on PATH for the test to load — the mingw runtime DLLs are already + # reachable via /mingw64/bin, but hamlib-prefix is not. Without this + # the test exits 0xc0000135 (STATUS_DLL_NOT_FOUND) at launch. The + # packaged installer is unaffected: cpack's bundle_fixup copies + # libhamlib-4.dll in. + export PATH="${{ steps.windows-deps.outputs.boost_prefix }}/lib:${{ steps.windows-deps.outputs.hamlib_prefix }}/bin:${PATH}" + ctest --output-on-failure --output-junit ctest-results.xml working-directory: wsjtx-build - name: Publish test summary @@ -203,12 +286,22 @@ jobs: path: wsjtx-build/ctest-results.xml if-no-files-found: ignore + # MAP65 builds by default again. Under OPENMP_ONLY, m65impl resolves + # wsjt_fort_common to wsjt_fort_omp, so this keeps the Windows Fortran + # linkage covered by CI. - name: Verify binary run: | file wsjtx-build/jt9.exe - test -x wsjtx-build/map65/map65.exe + file wsjtx-build/map65/map65.exe + test -f wsjtx-build/map65/map65.exe - - name: Stage install + # Install to a staging prefix so bundle_fixup runs: its install(CODE) + # step copies Qt and dependent runtime DLLs next to the installed + # executables, making bin/ self-contained. Build-tree binaries are NOT + # self-contained (they resolve Qt/libgfortran/libgomp via /mingw64/bin), + # so the launch check below must run against the staged install, not the + # build tree — otherwise it would fail for binaries that ship fine. + - name: Stage install (runs bundle_fixup) run: | WORKSPACE=$(cygpath "${GITHUB_WORKSPACE}") cmake --install wsjtx-build --prefix "${WORKSPACE}/stage-main" @@ -219,17 +312,35 @@ jobs: WORKSPACE=$(cygpath "${GITHUB_WORKSPACE}") test -f "${WORKSPACE}/stage-main/bin/map65.exe" test -f "${WORKSPACE}/stage-main/bin/qmap.exe" - test -f "${WORKSPACE}/stage-main/bin/wsjtx.exe" - test -f "${WORKSPACE}/stage-main/bin/jt9.exe" bash .github/scripts/audit-staged-dll-imports-windows.sh \ "${WORKSPACE}/stage-main/bin" \ - "${WORKSPACE}/stage-main/bin/map65.exe" \ - "${WORKSPACE}/stage-main/bin/qmap.exe" \ + "${WORKSPACE}"/stage-main/bin/*.exe \ + "${WORKSPACE}"/stage-main/bin/*.dll + + - name: Smoke-launch staged WSJT-X (clean PATH) + id: wsjtx_smoke + run: | + WORKSPACE=$(cygpath "${GITHUB_WORKSPACE}") + .github/scripts/smoke-launch-windows.sh \ "${WORKSPACE}/stage-main/bin/wsjtx.exe" \ - "${WORKSPACE}/stage-main/bin/jt9.exe" + --startup-smoke-test --rig-name CI-STARTUP - # Emit an NSIS installer containing the full CLI tool set - # (wsjtx.exe, jt9, wsprd, fmtave, fcal, fmeasure + WSJT_BUILD_UTILS + - name: Upload WSJT-X startup diagnostics + if: failure() && steps.wsjtx_smoke.outcome == 'failure' + uses: actions/upload-artifact@v7 + with: + name: wsjtx-startup-smoke-windows + path: launch.out + if-no-files-found: ignore + retention-days: 7 + + - name: Smoke-launch staged jt9 (clean PATH) + run: | + WORKSPACE=$(cygpath "${GITHUB_WORKSPACE}") + .github/scripts/smoke-launch-windows.sh "${WORKSPACE}/stage-main/bin/jt9.exe" --help + + # Emit an NSIS installer containing the full executable set + # (wsjtx.exe, map65.exe, jt9, wsprd, fmtave, fcal, fmeasure + WSJT_BUILD_UTILS # ft8code/jt65code/... + rigctl wrappers + Qt runtime via bundle_fixup). # CMakeLists.txt:1989-1990 sets CPACK_GENERATOR=NSIS on WIN32 and # CPACK_MONOLITHIC_INSTALL=1 packages every install() target. @@ -246,50 +357,28 @@ jobs: # wsjtx-<inputs.version>-win64.exe. release.yml's prepare job # enforces numeric-base parity; this override covers the # suffix gap. - cpack -G NSIS -V \ - -D CPACK_PACKAGE_VERSION="${{ inputs.version }}" \ - -D CPACK_PACKAGE_FILE_NAME="wsjtx-${{ inputs.version }}-win64" + cpack_args=( + -G NSIS + -D CPACK_PACKAGE_VERSION="${VERSION}" + -D CPACK_PACKAGE_FILE_NAME="wsjtx-${VERSION}-win64" + ) + if [ "${CPACK_VERBOSE:-0}" = "1" ]; then + cpack_args+=(-V) + fi + cpack "${cpack_args[@]}" ls -la *.exe - test -x map65/map65.exe - # Self-signed ephemeral signing — the signing step is wired into the - # pipeline, but the signature does NOT chain to a trusted root. This - # is intentional: Authenticode certification is a separate decision - # (CI/CD adoption decision #5). Generates an ephemeral cert per-run. - - name: Sign installer with self-signed ephemeral cert + - name: Verify installer has no Authenticode signature + shell: pwsh run: | - cd wsjtx-build - INSTALLER=$(ls wsjtx-${{ inputs.version }}-*.exe | head -1) - if [ -z "$INSTALLER" ]; then - echo "ERROR: no NSIS installer produced by cpack" - ls -la - exit 1 - fi - echo "Unsigned installer: $INSTALLER" - # MSYS2 auto-converts arguments starting with '/' into Windows paths - # (e.g., '/CN=...' becomes 'D:/a/_temp/msys64/CN=...'). - # MSYS2_ARG_CONV_EXCL="*" disables that conversion for this command. - MSYS2_ARG_CONV_EXCL="*" openssl req -x509 -newkey rsa:2048 \ - -keyout ephemeral-key.pem -out ephemeral-cert.pem \ - -days 365 -nodes \ - -subj "/CN=WSJT-X Ephemeral Dev Signing/O=WSJTX/C=US" - SIGNED="${INSTALLER%.exe}-signed.exe" - osslsigncode sign \ - -certs ephemeral-cert.pem -key ephemeral-key.pem \ - -n "WSJT-X Installer" \ - -i "https://github.com/WSJTX/wsjtx-internal" \ - -h sha256 \ - -in "$INSTALLER" -out "$SIGNED" - mv "$SIGNED" "$INSTALLER" - rm -f ephemeral-key.pem ephemeral-cert.pem - echo "Signed installer: $INSTALLER" - osslsigncode verify "$INSTALLER" || true - # Exit 0: osslsigncode verify returns non-zero on CA-untrust even - # when the signature itself is structurally valid. The ephemeral - # cert is self-signed by design; the "|| true" keeps CI green. - # Structural presence is proven by the sign step succeeding above. + $installer = Get-Item "wsjtx-build/wsjtx-${{ inputs.version }}-win64.exe" + $signature = Get-AuthenticodeSignature $installer.FullName + if ($signature.Status -ne 'NotSigned') { + throw "Installer Authenticode status is $($signature.Status), expected NotSigned" + } - name: Upload installer artifact + id: upload_installer uses: actions/upload-artifact@v7 with: name: wsjtx-${{ inputs.version }}-windows-x86_64-installer @@ -301,6 +390,5 @@ jobs: name: wsjtx-${{ inputs.version }}-windows-x86_64 path: | wsjtx-build/jt9.exe - wsjtx-build/map65/map65.exe wsjtx-build/wsprd.exe wsjtx-build/wsjtx.exe diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a1bf639a..70ce9fe4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,92 +2,262 @@ name: CI on: push: - branches: [develop] + branches: [develop, "release/**"] pull_request: - branches: [develop] + 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 - # CMakeLists.txt so CI and release.yml cannot disagree. Strip the + # 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: runs-on: ubuntu-latest + timeout-minutes: 10 outputs: version: ${{ steps.v.outputs.version }} + release_channel: ${{ steps.v.outputs.release_channel }} + rc_number: ${{ steps.v.outputs.rc_number }} + 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@v6 + - 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: | - VERSION=$(grep -E '^\s*VERSION\s+[0-9]' CMakeLists.txt | head -1 | awk '{print $2}' | cut -d. -f1-3) - if [ -z "$VERSION" ]; then - echo "::error::Could not derive VERSION from CMakeLists.txt" - exit 1 + STATE=$(python3 .github/scripts/release-policy.py read-state) + VERSION=$(jq -r .version <<<"$STATE") + CHANNEL=$(jq -r .channel <<<"$STATE") + RC_NUMBER=$(jq -r .rc <<<"$STATE") + echo "Derived version from release-state.txt: $VERSION" + { + echo "version=$VERSION" + echo "release_channel=$CHANNEL" + echo "rc_number=$RC_NUMBER" + } >> "$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 + - id: packaging-policy + name: Select Linux packaging policy + env: + EVENT_NAME: ${{ github.event_name }} + PR_BASE_SHA: ${{ github.event.pull_request.base.sha }} + CURRENT_SHA: ${{ github.sha }} + 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 - echo "Derived version from CMakeLists.txt: $VERSION" - echo "version=$VERSION" >> "$GITHUB_OUTPUT" - - macos-arm64-qt: - needs: prepare - uses: ./.github/workflows/prepare-macos-qt.yml - with: - arch: "arm64" - runner: "macos-15" - deployment_target: "11.0" - - macos-intel-qt: - needs: prepare - uses: ./.github/workflows/prepare-macos-qt.yml - with: - arch: "x86_64" - runner: "macos-15-intel" - deployment_target: "10.13" + # 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, macos-arm64-qt] + 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.1" + hamlib_branch: "4.7.2" arch: "arm64" runner: "macos-15" deployment_target: "11.0" - secrets: inherit + recache: ${{ inputs.recache || false }} + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} macos-intel: - needs: [prepare, macos-intel-qt] + 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.1" + hamlib_branch: "4.7.2" arch: "x86_64" runner: "macos-15-intel" deployment_target: "10.13" - secrets: inherit + recache: ${{ inputs.recache || false }} + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} linux: - needs: prepare + needs: [prepare] uses: ./.github/workflows/build-linux.yml with: version: ${{ needs.prepare.outputs.version }} - hamlib_branch: "4.7.1" + 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' }} + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} 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 + 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.1" + 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' }} + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} + secrets: inherit + + linux-armhf: + needs: [prepare, linux] + # Opt-in only -- target tests and runtime validation execute under QEMU. + 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' }} + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} secrets: inherit windows: - needs: prepare + 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.1" - secrets: inherit + hamlib_branch: "4.7.2" + recache: ${{ inputs.recache || false }} + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} diff --git a/.github/workflows/hamlib-upstream-check.yml b/.github/workflows/hamlib-upstream-check.yml index 01add999..121babd1 100644 --- a/.github/workflows/hamlib-upstream-check.yml +++ b/.github/workflows/hamlib-upstream-check.yml @@ -12,9 +12,12 @@ permissions: jobs: check: + # Mirrored to the public repo at GA; upstream watch runs internal-only. + if: github.repository == 'WSJTX/wsjtx-internal' runs-on: ubuntu-latest + timeout-minutes: 10 steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 with: persist-credentials: false @@ -90,10 +93,14 @@ jobs: Update \`hamlib_branch\` in: - - \`.github/workflows/ci.yml\` (five jobs) - - \`.github/workflows/release.yml\` (five jobs) + - \`.github/workflows/ci.yml\` (six target jobs) + - \`.github/workflows/release.yml\` (six target jobs) + - \`.github/scripts/linux-ci-image-config.sh\` + - \`.github/scripts/tsan-linux-deps-config.sh\` - Open a PR against \`develop\`, let CI run on all five platforms, then merge. + Update both exact commits, publish and validate a candidate Linux + image generation, update the remaining platform pins, then let CI run + on all six targets. ## Notes diff --git a/.github/workflows/prepare-macos-qt.yml b/.github/workflows/prepare-macos-qt.yml deleted file mode 100644 index de9f5fe5..00000000 --- a/.github/workflows/prepare-macos-qt.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: Prepare macOS Qt - -on: - workflow_call: - inputs: - arch: - description: "Target architecture (arm64 or x86_64)" - required: true - type: string - runner: - description: "GitHub Actions runner label" - required: true - type: string - deployment_target: - description: "macOS deployment target version" - required: true - type: string - -jobs: - qt-cache-key: - runs-on: ubuntu-latest - outputs: - key: ${{ steps.qt-key.outputs.key }} - steps: - - uses: actions/checkout@v6 - - - name: Compute Qt cache key - id: qt-key - run: | - .github/scripts/macos-qt-cache-key.sh \ - --arch "${{ inputs.arch }}" \ - --runner "${{ inputs.runner }}" \ - --deployment-target "${{ inputs.deployment_target }}" \ - --github-output - - prepare: - needs: qt-cache-key - runs-on: ${{ inputs.runner }} - concurrency: - group: ${{ needs.qt-cache-key.outputs.key }} - cancel-in-progress: false - steps: - - uses: actions/checkout@v6 - - - name: Restore Qt cache - id: qt-cache - uses: actions/cache/restore@v5 - with: - path: qt-prefix - key: ${{ needs.qt-cache-key.outputs.key }} - - - name: Build Qt - if: steps.qt-cache.outputs.cache-hit != 'true' - run: | - .github/scripts/build-qt-macos.sh \ - --arch "${{ inputs.arch }}" \ - --deployment-target "${{ inputs.deployment_target }}" \ - --prefix "${GITHUB_WORKSPACE}/qt-prefix" - - - name: Verify Qt prefix - run: | - .github/scripts/verify-macos-artifacts.sh \ - --target "${{ inputs.deployment_target }}" \ - --arch "${{ inputs.arch }}" \ - --allow-prefix "${GITHUB_WORKSPACE}/qt-prefix" \ - "${GITHUB_WORKSPACE}/qt-prefix" - - - name: Save Qt cache - if: steps.qt-cache.outputs.cache-hit != 'true' - uses: actions/cache/save@v5 - with: - path: qt-prefix - key: ${{ needs.qt-cache-key.outputs.key }} diff --git a/.github/workflows/promote-release.yml b/.github/workflows/promote-release.yml new file mode 100644 index 00000000..9a3ccf6d --- /dev/null +++ b/.github/workflows/promote-release.yml @@ -0,0 +1,190 @@ +name: Promote Release Source + +on: + workflow_dispatch: + inputs: + version: + description: "Version without v (X.Y.Z or X.Y.Z-rcN)" + required: true + type: string + candidate_run_id: + description: "Successful Prepare Release Candidate workflow run" + required: true + type: string + operation: + description: "Validate only, or copy the exact source tag to the public repository" + required: true + type: choice + options: [validate, promote] + default: validate + +permissions: + actions: read + contents: read + +jobs: + validate: + runs-on: ubuntu-latest + timeout-minutes: 20 + outputs: + sha: ${{ steps.candidate.outputs.sha }} + public_tag: ${{ steps.candidate.outputs.public_tag }} + channel: ${{ steps.candidate.outputs.channel }} + prior_master: ${{ steps.public.outputs.prior_master }} + tag_exists: ${{ steps.public.outputs.tag_exists }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + with: + fetch-depth: 0 + persist-credentials: false + - name: Validate candidate run and immutable tag + id: candidate + env: + GH_TOKEN: ${{ github.token }} + VERSION: ${{ inputs.version }} + RUN_ID: ${{ inputs.candidate_run_id }} + run: | + set -euo pipefail + if [[ ! "$RUN_ID" =~ ^[0-9]+$ ]]; then + echo "::error::candidate_run_id must be numeric" + exit 1 + fi + IDENTITY=$(python3 .github/scripts/release-policy.py classify "$VERSION") + BRANCH=$(jq -r .release_branch <<<"$IDENTITY") + CHANNEL=$(jq -r .channel <<<"$IDENTITY") + TAG="build/v$VERSION" + + RUN=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/$RUN_ID") + if [ "$(jq -r .path <<<"$RUN")" != ".github/workflows/release-tag-helper.yml" ] || \ + [ "$(jq -r .conclusion <<<"$RUN")" != success ]; then + echo "::error::Run $RUN_ID must be a successful release-tag-helper.yml run" + exit 1 + fi + RUN_SHA=$(jq -r .head_sha <<<"$RUN") + git fetch origin "+refs/tags/$TAG:refs/tags/$TAG" "+refs/heads/$BRANCH:refs/remotes/origin/$BRANCH" + TAG_SHA=$(git rev-parse "$TAG^{commit}") + if [ "$GITHUB_SHA" != "$TAG_SHA" ]; then + echo "::error::Run this workflow from $BRANCH at $TAG_SHA" + exit 1 + fi + if [ "$TAG_SHA" != "$RUN_SHA" ]; then + echo "::error::$TAG resolves to $TAG_SHA but run $RUN_ID built $RUN_SHA" + exit 1 + fi + BRANCH_SHA=$(git rev-parse "origin/$BRANCH^{commit}") + if [ "$TAG_SHA" != "$BRANCH_SHA" ]; then + echo "::error::$TAG is $TAG_SHA but the current $BRANCH tip is $BRANCH_SHA" + exit 1 + fi + git checkout --detach "$TAG_SHA" + python3 .github/scripts/release-policy.py validate-source "$VERSION" + + CANDIDATE_DIR="$RUNNER_TEMP/release-candidate" + gh run download "$RUN_ID" --name "release-candidate-$VERSION" --dir "$CANDIDATE_DIR" + PROVENANCE=$(find "$CANDIDATE_DIR" -name candidate-provenance.json -type f -print -quit) + if [ -z "$PROVENANCE" ]; then + echo "::error::Candidate provenance was not found in run $RUN_ID" + exit 1 + fi + test "$(jq -r .tag "$PROVENANCE")" = "$TAG" + test "$(jq -r .commit "$PROVENANCE")" = "$TAG_SHA" + test "$(jq -r .version "$PROVENANCE")" = "$VERSION" + { + echo "sha=$TAG_SHA" + echo "tag=$TAG" + echo "public_tag=v$VERSION" + echo "branch=$BRANCH" + echo "channel=$CHANNEL" + } >> "$GITHUB_OUTPUT" + + - name: Validate public ref state + id: public + env: + PUBLIC_TAG: ${{ steps.candidate.outputs.public_tag }} + SHA: ${{ steps.candidate.outputs.sha }} + run: | + set -euo pipefail + git remote add public https://github.com/WSJTX/wsjtx.git + PUBLIC_TAG_SHA=$(git ls-remote public "refs/tags/$PUBLIC_TAG^{}" | awk '{print $1}') + if [ -z "$PUBLIC_TAG_SHA" ]; then + PUBLIC_TAG_SHA=$(git ls-remote public "refs/tags/$PUBLIC_TAG" | awk '{print $1}') + fi + if [ -n "$PUBLIC_TAG_SHA" ] && [ "$PUBLIC_TAG_SHA" != "$SHA" ]; then + echo "::error::Public $PUBLIC_TAG already exists at $PUBLIC_TAG_SHA; tags are never moved" + exit 1 + fi + PRIOR_MASTER=$(git ls-remote public refs/heads/master | awk '{print $1}') + echo "tag_exists=$([ "$PUBLIC_TAG_SHA" = "$SHA" ] && echo true || echo false)" >> "$GITHUB_OUTPUT" + echo "prior_master=$PRIOR_MASTER" >> "$GITHUB_OUTPUT" + + - name: Summarize validation + env: + VERSION: ${{ inputs.version }} + RUN_ID: ${{ inputs.candidate_run_id }} + SHA: ${{ steps.candidate.outputs.sha }} + CHANNEL: ${{ steps.candidate.outputs.channel }} + PRIOR_MASTER: ${{ steps.public.outputs.prior_master }} + run: | + { + echo "## Public source validation" + echo + echo "- Version: \`$VERSION\` ($CHANNEL)" + echo "- Candidate run: [\`$RUN_ID\`]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$RUN_ID)" + echo "- Exact commit: \`$SHA\`" + echo "- Public tag: \`v$VERSION\`" + echo "- Prior public master: \`${PRIOR_MASTER:-<none>}\`" + } >> "$GITHUB_STEP_SUMMARY" + + promote: + if: inputs.operation == 'promote' + needs: validate + runs-on: ubuntu-latest + timeout-minutes: 10 + environment: source-promotion + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + with: + fetch-depth: 0 + ref: ${{ needs.validate.outputs.sha }} + persist-credentials: false + - name: Promote exact source commit + env: + TOKEN: ${{ secrets.CROSS_REPO_TOKEN }} + PUBLIC_TAG: ${{ needs.validate.outputs.public_tag }} + SHA: ${{ needs.validate.outputs.sha }} + CHANNEL: ${{ needs.validate.outputs.channel }} + PRIOR_MASTER: ${{ needs.validate.outputs.prior_master }} + TAG_EXISTS: ${{ needs.validate.outputs.tag_exists }} + run: | + set -euo pipefail + if [ -z "$TOKEN" ]; then + echo "::error::CROSS_REPO_TOKEN is required for source promotion" + exit 1 + fi + git remote add public "https://x-access-token:${TOKEN}@github.com/WSJTX/wsjtx.git" + CURRENT_TAG=$(git ls-remote public "refs/tags/$PUBLIC_TAG" | awk '{print $1}') + CURRENT_MASTER=$(git ls-remote public refs/heads/master | awk '{print $1}') + test "$CURRENT_MASTER" = "$PRIOR_MASTER" + if [ -n "$CURRENT_TAG" ] && [ "$CURRENT_TAG" != "$SHA" ]; then + echo "::error::$PUBLIC_TAG was created at a different commit after validation" + exit 1 + fi + if [ "$CHANNEL" = GA ] && [ -n "$PRIOR_MASTER" ]; then + git cat-file -e "$PRIOR_MASTER^{commit}" 2>/dev/null || git fetch public master + git merge-base --is-ancestor "$PRIOR_MASTER" "$SHA" || { + echo "::error::GA promotion must advance public master" + exit 1 + } + fi + if [ "$CHANNEL" = GA ] && [ -z "$CURRENT_TAG" ]; then + git push --atomic public \ + "$SHA:refs/heads/master" "$SHA:refs/tags/$PUBLIC_TAG" \ + --force-with-lease="refs/heads/master:$PRIOR_MASTER" + elif [ "$CHANNEL" = GA ]; then + git push public "$SHA:refs/heads/master" \ + --force-with-lease="refs/heads/master:$PRIOR_MASTER" + elif [ -z "$CURRENT_TAG" ]; then + git push public "$SHA:refs/tags/$PUBLIC_TAG" + else + echo "$PUBLIC_TAG already points to $SHA; promotion is idempotently satisfied." + fi diff --git a/.github/workflows/public-release.yml b/.github/workflows/public-release.yml new file mode 100644 index 00000000..14d4e611 --- /dev/null +++ b/.github/workflows/public-release.yml @@ -0,0 +1,389 @@ +name: Build and Publish Public Release + +on: + push: + tags: ["v*"] + +permissions: + contents: read + +concurrency: + group: public-release-${{ github.ref }} + cancel-in-progress: false + +jobs: + prepare: + if: github.repository == 'WSJTX/wsjtx' + runs-on: ubuntu-latest + timeout-minutes: 10 + outputs: + version: ${{ steps.identity.outputs.version }} + release_channel: ${{ steps.identity.outputs.channel }} + rc_number: ${{ steps.identity.outputs.rc_number }} + macos_sign_mode: ${{ steps.identity.outputs.macos_sign_mode }} + windows_signing: ${{ steps.identity.outputs.windows_signing }} + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + - name: Validate public release tag and source identity + id: identity + env: + MACOS_DISTRIBUTION_SIGNING_ENABLED: ${{ vars.MACOS_DISTRIBUTION_SIGNING_ENABLED }} + run: | + set -euo pipefail + if [[ ! "$GITHUB_REF_NAME" =~ ^v(.+)$ ]]; then + echo "::error::Expected vX.Y.Z or vX.Y.Z-rcN" + exit 1 + fi + VERSION="${GITHUB_REF_NAME#v}" + IDENTITY=$(python3 .github/scripts/release-policy.py validate-source "$VERSION") + { + echo "version=$(jq -r .version <<<"$IDENTITY")" + echo "channel=$(jq -r .channel <<<"$IDENTITY")" + echo "rc_number=$(jq -r .rc_number <<<"$IDENTITY")" + echo "windows_signing=$(jq -r .windows_signing <<<"$IDENTITY")" + } >> "$GITHUB_OUTPUT" + if [ "$MACOS_DISTRIBUTION_SIGNING_ENABLED" = true ]; then + echo "macos_sign_mode=distribution" >> "$GITHUB_OUTPUT" + else + echo "macos_sign_mode=validation" >> "$GITHUB_OUTPUT" + echo "::notice::macOS distribution signing is disabled. Validated packages will be published for manual replacement." + fi + + linux-images: + needs: prepare + uses: ./.github/workflows/publish-linux-ci-images.yml + permissions: + contents: read + packages: write + with: + publication_target: public-release + mode: refresh + promote: false + image_set: normal + include_armhf: true + + macos: + needs: prepare + uses: ./.github/workflows/build-macos.yml + permissions: + actions: read + contents: read + with: + version: ${{ needs.prepare.outputs.version }} + hamlib_branch: "4.7.2" + arch: arm64 + runner: macos-15 + deployment_target: "11.0" + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} + signing_mode: ${{ needs.prepare.outputs.macos_sign_mode }} + + macos-intel: + needs: prepare + uses: ./.github/workflows/build-macos.yml + permissions: + actions: read + contents: read + with: + version: ${{ needs.prepare.outputs.version }} + hamlib_branch: "4.7.2" + arch: x86_64 + runner: macos-15-intel + deployment_target: "10.13" + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} + signing_mode: ${{ needs.prepare.outputs.macos_sign_mode }} + + linux: + needs: [prepare, linux-images] + uses: ./.github/workflows/build-linux.yml + permissions: + actions: read + contents: read + packages: read + with: + version: ${{ needs.prepare.outputs.version }} + hamlib_branch: "4.7.2" + arch: x86_64 + image_source: public-release + image_tag: ${{ needs.linux-images.outputs.image_tag }} + image_digest: ${{ needs.linux-images.outputs.x86_64_digest }} + build_packages: true + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} + + linux-arm: + needs: [prepare, linux-images] + uses: ./.github/workflows/build-linux.yml + permissions: + actions: read + contents: read + packages: read + with: + version: ${{ needs.prepare.outputs.version }} + hamlib_branch: "4.7.2" + arch: aarch64 + image_source: public-release + image_tag: ${{ needs.linux-images.outputs.image_tag }} + image_digest: ${{ needs.linux-images.outputs.aarch64_digest }} + build_packages: true + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} + + linux-armhf: + needs: [prepare, linux-images] + uses: ./.github/workflows/build-linux.yml + permissions: + actions: read + contents: read + packages: read + with: + version: ${{ needs.prepare.outputs.version }} + hamlib_branch: "4.7.2" + arch: armhf + image_source: public-release + image_tag: ${{ needs.linux-images.outputs.image_tag }} + image_digest: ${{ needs.linux-images.outputs.armhf_digest }} + armhf_cross_image_digest: ${{ needs.linux-images.outputs.armhf_cross_digest }} + build_packages: true + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} + + windows: + needs: prepare + uses: ./.github/workflows/sign-windows-release.yml + permissions: + actions: read + contents: read + with: + version: ${{ needs.prepare.outputs.version }} + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} + windows_signing: ${{ needs.prepare.outputs.windows_signing }} + + assemble: + needs: [prepare, linux-images, macos, macos-intel, linux, linux-arm, linux-armhf, windows] + runs-on: ubuntu-latest + timeout-minutes: 30 + permissions: + actions: read + contents: read + packages: read + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + - uses: actions/download-artifact@v8 + with: + path: artifacts + - name: Build corresponding source archive + env: + VERSION: ${{ needs.prepare.outputs.version }} + run: | + set -euo pipefail + git archive --format=tar --prefix="wsjtx-$VERSION/" "$GITHUB_SHA" | + gzip -n > "artifacts/wsjtx-$VERSION-src.tar.gz" + test -s "artifacts/wsjtx-$VERSION-src.tar.gz" + python3 .github/scripts/release-policy.py validate-archive "$VERSION" \ + "artifacts/wsjtx-$VERSION-src.tar.gz" --commit "$GITHUB_SHA" + - name: Verify GitHub automatic source archives + env: + VERSION: ${{ needs.prepare.outputs.version }} + run: | + set -euo pipefail + curl --fail --location --retry 3 \ + "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/archive/refs/tags/$GITHUB_REF_NAME.tar.gz" \ + --output "$RUNNER_TEMP/github-source.tar.gz" + curl --fail --location --retry 3 \ + "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/archive/refs/tags/$GITHUB_REF_NAME.zip" \ + --output "$RUNNER_TEMP/github-source.zip" + python3 .github/scripts/release-policy.py validate-archive "$VERSION" \ + "$RUNNER_TEMP/github-source.tar.gz" --commit "$GITHUB_SHA" + python3 .github/scripts/release-policy.py validate-archive "$VERSION" \ + "$RUNNER_TEMP/github-source.zip" --commit "$GITHUB_SHA" + - name: Verify public artifacts and signing reports + env: + VERSION: ${{ needs.prepare.outputs.version }} + MACOS_MODE: ${{ needs.prepare.outputs.macos_sign_mode }} + WINDOWS_MODE: ${{ needs.prepare.outputs.windows_signing }} + run: | + set -euo pipefail + python3 .github/scripts/release-policy.py verify-assets "$VERSION" artifacts \ + --macos-mode "$MACOS_MODE" --windows-mode "$WINDOWS_MODE" + python3 .github/scripts/release-policy.py verify-signing-reports "$VERSION" artifacts \ + --commit "$GITHUB_SHA" --tag "$GITHUB_REF_NAME" \ + --macos-mode "$MACOS_MODE" --windows-mode "$WINDOWS_MODE" + - name: Generate checksums and release manifest + env: + VERSION: ${{ needs.prepare.outputs.version }} + MACOS_MODE: ${{ needs.prepare.outputs.macos_sign_mode }} + WINDOWS_MODE: ${{ needs.prepare.outputs.windows_signing }} + run: | + python3 .github/scripts/release-policy.py write-manifest "$VERSION" artifacts \ + --repository "$GITHUB_REPOSITORY" \ + --commit "$GITHUB_SHA" \ + --run-id "$GITHUB_RUN_ID" \ + --linux-x86-64-digest "${{ needs.linux-images.outputs.x86_64_digest }}" \ + --linux-aarch64-digest "${{ needs.linux-images.outputs.aarch64_digest }}" \ + --linux-armhf-cross-digest "${{ needs.linux-images.outputs.armhf_cross_digest }}" \ + --linux-armhf-digest "${{ needs.linux-images.outputs.armhf_digest }}" \ + --macos-mode "$MACOS_MODE" --windows-mode "$WINDOWS_MODE" + - name: Assemble publication bundle + env: + VERSION: ${{ needs.prepare.outputs.version }} + MACOS_MODE: ${{ needs.prepare.outputs.macos_sign_mode }} + WINDOWS_MODE: ${{ needs.prepare.outputs.windows_signing }} + run: | + set -euo pipefail + mkdir -p release-bundle/verification + while IFS= read -r file; do + cp "$file" release-bundle/ + done < <(python3 .github/scripts/release-policy.py release-files "$VERSION" artifacts \ + --macos-mode "$MACOS_MODE" --windows-mode "$WINDOWS_MODE") + cp artifacts/SHA256SUMS artifacts/release-manifest.json release-bundle/ + cp -R artifacts/macos-signing-report-* release-bundle/verification/ + if [ "$WINDOWS_MODE" = signpath ]; then + cp -R artifacts/wsjtx-*-windows-signing-request \ + artifacts/wsjtx-*-windows-signing-verification \ + release-bundle/verification/ + fi + - name: Upload publication bundle for approval + uses: actions/upload-artifact@v7 + with: + name: release-bundle-${{ needs.prepare.outputs.version }} + path: release-bundle + if-no-files-found: error + retention-days: 30 + + publish: + needs: [prepare, assemble] + runs-on: ubuntu-latest + timeout-minutes: 20 + environment: public-release + permissions: + actions: read + contents: write + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + - uses: actions/download-artifact@v8 + with: + name: release-bundle-${{ needs.prepare.outputs.version }} + path: release-bundle + - name: Recheck bundle and immutable public tag + env: + VERSION: ${{ needs.prepare.outputs.version }} + MACOS_MODE: ${{ needs.prepare.outputs.macos_sign_mode }} + WINDOWS_MODE: ${{ needs.prepare.outputs.windows_signing }} + run: | + set -euo pipefail + (cd release-bundle && sha256sum --check SHA256SUMS) + test "$(jq -r .repository release-bundle/release-manifest.json)" = "$GITHUB_REPOSITORY" + test "$(jq -r .tag release-bundle/release-manifest.json)" = "$GITHUB_REF_NAME" + test "$(jq -r .commit release-bundle/release-manifest.json)" = "$GITHUB_SHA" + test "$(jq -r '.assets | length' release-bundle/release-manifest.json)" -gt 0 + EXPECTED_MACOS_MODE=distribution + if [ "$MACOS_MODE" = validation ]; then + EXPECTED_MACOS_MODE=manual + fi + test "$(jq -r .macos_signing.mode release-bundle/release-manifest.json)" = "$EXPECTED_MACOS_MODE" + test "$(jq -r .windows_signing.mode release-bundle/release-manifest.json)" = "$WINDOWS_MODE" + python3 .github/scripts/release-policy.py classify "$VERSION" >/dev/null + TAG_SHA=$(git ls-remote origin "refs/tags/$GITHUB_REF_NAME" | awk '{print $1}') + if [ "$TAG_SHA" != "$GITHUB_SHA" ]; then + echo "::error::$GITHUB_REF_NAME now resolves to ${TAG_SHA:-missing}, expected $GITHUB_SHA" + exit 1 + fi + - name: Publish public GitHub Release + env: + GH_TOKEN: ${{ github.token }} + VERSION: ${{ needs.prepare.outputs.version }} + CHANNEL: ${{ needs.prepare.outputs.release_channel }} + MACOS_MODE: ${{ needs.prepare.outputs.macos_sign_mode }} + run: | + set -euo pipefail + mapfile -t FILES < <(find release-bundle -maxdepth 1 -type f -print | sort) + mapfile -t EXPECTED_NAMES < <(printf '%s\n' "${FILES[@]}" | xargs -n1 basename | sort) + CREATED=false + if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then + RELEASE=$(gh release view "$GITHUB_REF_NAME" --json isDraft,isPrerelease,assets) + if [ "$(jq -r .isDraft <<<"$RELEASE")" != false ]; then + echo "::error::Existing release $GITHUB_REF_NAME is unexpectedly a draft." + exit 1 + fi + EXPECTED_PRERELEASE=false + if [ "$CHANNEL" = RC ]; then + EXPECTED_PRERELEASE=true + fi + if [ "$(jq -r .isPrerelease <<<"$RELEASE")" != "$EXPECTED_PRERELEASE" ]; then + echo "::error::Existing release $GITHUB_REF_NAME has the wrong prerelease state." + exit 1 + fi + mapfile -t ACTUAL_NAMES < <(jq -r '.assets[].name' <<<"$RELEASE" | sort) + EXTRA=$(comm -13 \ + <(printf '%s\n' "${EXPECTED_NAMES[@]}") \ + <(printf '%s\n' "${ACTUAL_NAMES[@]}") || true) + if [ -n "$EXTRA" ]; then + echo "::error::Existing release contains assets outside the publication bundle:" + printf '%s\n' "$EXTRA" + exit 1 + fi + mkdir -p "$RUNNER_TEMP/existing-assets" + MISSING=() + for file in "${FILES[@]}"; do + name=$(basename "$file") + if [ "$MACOS_MODE" = validation ] && [[ "$name" == wsjtx-*-macOS.pkg ]]; then + if printf '%s\n' "${ACTUAL_NAMES[@]}" | grep -Fxq "$name"; then + echo "Preserving manually replaceable macOS asset: $name" + else + MISSING+=("$file") + fi + continue + fi + if gh release download "$GITHUB_REF_NAME" --pattern "$name" --dir "$RUNNER_TEMP/existing-assets"; then + cmp "$file" "$RUNNER_TEMP/existing-assets/$name" || { + echo "::error::Published asset $name differs; automatic replacement is forbidden." + exit 1 + } + else + MISSING+=("$file") + fi + done + if [ "${#MISSING[@]}" -gt 0 ]; then + gh release upload "$GITHUB_REF_NAME" "${MISSING[@]}" + fi + mapfile -t FINAL_NAMES < <(gh release view "$GITHUB_REF_NAME" --json assets --jq '.assets[].name' | sort) + if ! diff -u \ + <(printf '%s\n' "${EXPECTED_NAMES[@]}") \ + <(printf '%s\n' "${FINAL_NAMES[@]}"); then + echo "::error::Published asset set does not match the publication bundle." + exit 1 + fi + echo "Existing assets satisfy the publication bundle policy." + else + FLAGS=() + if [ "$CHANNEL" = RC ]; then + FLAGS+=(--prerelease) + fi + gh release create "$GITHUB_REF_NAME" \ + --verify-tag \ + --title "WSJT-X $VERSION" \ + --generate-notes \ + "${FLAGS[@]}" \ + "${FILES[@]}" + CREATED=true + fi + if [ "$CREATED" = true ]; then + QUICK_DOWNLOADS=$(python3 .github/scripts/generate-quick-downloads.py \ + "$GITHUB_REPOSITORY" "$GITHUB_REF_NAME" "${FILES[@]}" || true) + if [ -n "$QUICK_DOWNLOADS" ]; then + GENERATED_NOTES=$(gh release view "$GITHUB_REF_NAME" --json body --jq .body) + printf '%s\n\n---\n\n%s\n' "$QUICK_DOWNLOADS" "$GENERATED_NOTES" > "$RUNNER_TEMP/release-notes.md" + gh release edit "$GITHUB_REF_NAME" --notes-file "$RUNNER_TEMP/release-notes.md" + else + echo "::warning::Quick Downloads picker was empty; generated notes were left unchanged." + fi + fi diff --git a/.github/workflows/publish-linux-ci-images.yml b/.github/workflows/publish-linux-ci-images.yml new file mode 100644 index 00000000..e1bc4c30 --- /dev/null +++ b/.github/workflows/publish-linux-ci-images.yml @@ -0,0 +1,632 @@ +name: Publish Linux CI Images + +on: + workflow_call: + inputs: + publication_target: + description: "Image destination: internal or public-release" + required: false + type: string + default: "internal" + mode: + description: "Refresh or rollback" + required: false + type: string + default: "refresh" + promote: + description: "Promote candidates after every validation succeeds" + required: false + type: boolean + default: true + rollback_tag: + description: "Retained validated-build-* tag to promote when mode is rollback" + required: false + type: string + default: "" + include_armhf: + description: "Build and validate the ARMHF cross-builder/runtime pair" + required: false + type: boolean + default: false + image_set: + description: "Image cohort: normal, tsan, or normal-and-tsan" + required: false + type: string + default: "normal" + outputs: + image_tag: + description: "Immutable tag shared by the published image cohort" + value: ${{ jobs.metadata.outputs.build_tag }} + x86_64_digest: + description: "Digest of the linux-noble release image" + value: ${{ jobs.build-normal.outputs.digest }} + aarch64_digest: + description: "Digest of the linux-arm64-bookworm release image" + value: ${{ jobs.build-arm64.outputs.digest }} + armhf_digest: + description: "Digest of the linux-armv7-bookworm release image" + value: ${{ jobs.build-armhf-runtime.outputs.digest }} + armhf_cross_digest: + description: "Digest of the linux-armhf-cross-bookworm release image" + value: ${{ jobs.build-armhf-cross.outputs.digest }} + workflow_dispatch: + inputs: + mode: + description: "Build a new generation or roll stable back to a retained tag" + required: true + type: choice + options: + - refresh + - rollback + default: refresh + promote: + description: "Promote candidates after every validation succeeds" + required: false + type: boolean + default: true + rollback_tag: + description: "Retained validated-build-* tag to promote when mode is rollback" + required: false + type: string + default: "" + include_armhf: + description: "Build and validate the ARMHF cross-builder/runtime pair" + required: false + type: boolean + default: false + image_set: + description: "Images to publish or roll back" + required: true + type: choice + options: + - normal + - tsan + - normal-and-tsan + default: normal + publication_target: + description: "Image destination" + required: true + type: choice + options: + - internal + - public-release + default: internal + +permissions: + contents: read + packages: write + +concurrency: + group: linux-ci-image-publishing + cancel-in-progress: false + +jobs: + validate-inputs: + runs-on: ubuntu-24.04 + timeout-minutes: 10 + steps: + - name: Validate publication request + env: + MODE: ${{ inputs.mode }} + ROLLBACK_TAG: ${{ inputs.rollback_tag }} + IMAGE_SET: ${{ inputs.image_set }} + INCLUDE_ARMHF: ${{ inputs.include_armhf }} + PROMOTE: ${{ inputs.promote }} + REQUEST_REF: ${{ github.ref }} + REQUEST_REPOSITORY: ${{ github.repository }} + PUBLICATION_TARGET: ${{ inputs.publication_target }} + shell: bash + run: | + case "$MODE" in + refresh) + if [ -n "$ROLLBACK_TAG" ]; then + echo "::error::rollback_tag must be empty in refresh mode" + exit 2 + fi + ;; + rollback) + if [[ ! "$ROLLBACK_TAG" =~ ^validated-build-[0-9]{8}-[0-9]+-[0-9]+$ ]]; then + echo "::error::rollback_tag must identify a validated retained generation" + exit 2 + fi + ;; + *) + echo "::error::Unsupported publication mode: $MODE" + exit 2 + ;; + esac + + case "$IMAGE_SET" in + normal|tsan|normal-and-tsan) ;; + *) + echo "::error::Unsupported image_set: $IMAGE_SET" + exit 2 + ;; + esac + + case "$PUBLICATION_TARGET" in + internal) ;; + public-release) + if [ "$REQUEST_REPOSITORY" != WSJTX/wsjtx ]; then + echo "::error::Public release images may only be published by WSJTX/wsjtx" + exit 2 + fi + if [[ ! "$REQUEST_REF" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+(-rc[1-9][0-9]*)?$ ]]; then + echo "::error::Public release images require an exact vX.Y.Z or vX.Y.Z-rcN tag" + exit 2 + fi + if [ "$MODE" != refresh ] || [ "$PROMOTE" != false ] || \ + [ "$IMAGE_SET" != normal ] || [ "$INCLUDE_ARMHF" != true ]; then + echo "::error::Public release images require refresh, promote=false, image_set=normal, and include_armhf=true" + exit 2 + fi + ;; + *) + echo "::error::Unsupported publication_target: $PUBLICATION_TARGET" + exit 2 + ;; + esac + + if [ "$IMAGE_SET" = tsan ] && [ "$INCLUDE_ARMHF" = true ]; then + echo "::error::include_armhf is valid only when normal images are selected" + exit 2 + fi + + if { [ "$MODE" = rollback ] || [ "$PROMOTE" = true ]; } && \ + [ "$REQUEST_REF" != refs/heads/develop ]; then + echo "::error::Promotion and rollback must run from refs/heads/develop" + exit 2 + fi + + metadata: + if: inputs.mode != 'rollback' + needs: validate-inputs + runs-on: ubuntu-24.04 + timeout-minutes: 10 + outputs: + build_tag: ${{ steps.metadata.outputs.build_tag }} + candidate_tag: ${{ steps.metadata.outputs.candidate_tag }} + created: ${{ steps.metadata.outputs.created }} + version: ${{ steps.metadata.outputs.version }} + normal_hamlib_ref: ${{ steps.metadata.outputs.normal_hamlib_ref }} + tsan_hamlib_ref: ${{ steps.metadata.outputs.tsan_hamlib_ref }} + normal_noble_recipe: ${{ steps.metadata.outputs.normal_noble_recipe }} + normal_bookworm_recipe: ${{ steps.metadata.outputs.normal_bookworm_recipe }} + armhf_cross_recipe: ${{ steps.metadata.outputs.armhf_cross_recipe }} + armhf_runtime_recipe: ${{ steps.metadata.outputs.armhf_runtime_recipe }} + tsan_noble_recipe: ${{ steps.metadata.outputs.tsan_noble_recipe }} + refresh_epoch: ${{ steps.metadata.outputs.refresh_epoch }} + package_root: ${{ steps.metadata.outputs.package_root }} + normal_cache_from: ${{ steps.metadata.outputs.normal_cache_from }} + arm64_cache_from: ${{ steps.metadata.outputs.arm64_cache_from }} + armhf_cross_cache_from: ${{ steps.metadata.outputs.armhf_cross_cache_from }} + armhf_cache_from: ${{ steps.metadata.outputs.armhf_cache_from }} + steps: + - uses: actions/checkout@v7 + - id: metadata + env: + IMAGE_SET: ${{ inputs.image_set }} + PUBLICATION_TARGET: ${{ inputs.publication_target }} + shell: bash + run: | + created="$(date -u +%Y-%m-%dT%H:%M:%SZ)" + date_tag="$(date -u +%Y%m%d)" + 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 a numeric version from release-state.txt" + exit 1 + fi + { + if [ "$PUBLICATION_TARGET" = public-release ]; then + release_tag="release-${GITHUB_REF_NAME}-${GITHUB_SHA}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" + echo "build_tag=$release_tag" + echo "candidate_tag=candidate-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" + echo "package_root=ghcr.io/wsjtx/wsjtx" + echo "normal_cache_from=type=gha,scope=public-release-linux-noble" + echo "arm64_cache_from=type=gha,scope=public-release-linux-arm64-bookworm" + echo "armhf_cross_cache_from=type=gha,scope=public-release-linux-armhf-cross-bookworm" + echo "armhf_cache_from=type=gha,scope=public-release-linux-armv7-bookworm" + else + echo "build_tag=build-${date_tag}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" + echo "candidate_tag=candidate-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" + echo "package_root=ghcr.io/wsjtx/wsjtx-internal" + echo "normal_cache_from=type=registry,ref=ghcr.io/wsjtx/wsjtx-internal/linux-noble:stable" + echo "arm64_cache_from=type=registry,ref=ghcr.io/wsjtx/wsjtx-internal/linux-arm64-bookworm:stable" + echo "armhf_cross_cache_from=type=registry,ref=ghcr.io/wsjtx/wsjtx-internal/linux-armhf-cross-bookworm:stable" + echo "armhf_cache_from=type=registry,ref=ghcr.io/wsjtx/wsjtx-internal/linux-armv7-bookworm:stable" + fi + echo "created=$created" + echo "version=$version" + echo "refresh_epoch=$(date -u +%Y-%m)" + if [ "$IMAGE_SET" != tsan ]; then + . .github/scripts/linux-ci-image-config.sh + echo "normal_hamlib_ref=$LINUX_HAMLIB_REF" + echo "normal_noble_recipe=$(.github/scripts/linux-ci-image-fingerprint.sh normal-noble)" + echo "normal_bookworm_recipe=$(.github/scripts/linux-ci-image-fingerprint.sh normal-bookworm)" + echo "armhf_cross_recipe=$(.github/scripts/linux-ci-image-fingerprint.sh armhf-cross-bookworm)" + echo "armhf_runtime_recipe=$(.github/scripts/linux-ci-image-fingerprint.sh armhf-runtime-bookworm)" + fi + if [ "$IMAGE_SET" != normal ]; then + . .github/scripts/tsan-linux-deps-config.sh + echo "tsan_hamlib_ref=$TSAN_HAMLIB_REF" + echo "tsan_noble_recipe=$(.github/scripts/linux-ci-image-fingerprint.sh tsan-noble)" + fi + } >> "$GITHUB_OUTPUT" + + build-normal: + if: inputs.image_set == 'normal' || inputs.image_set == 'normal-and-tsan' + needs: metadata + runs-on: ubuntu-24.04 + timeout-minutes: 120 + outputs: + digest: ${{ steps.build.outputs.digest }} + steps: + - uses: actions/checkout@v7 + - uses: docker/setup-buildx-action@v4 + - uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - id: build + uses: docker/build-push-action@v7 + with: + context: . + file: .github/images/linux-ci/Dockerfile.noble + target: normal + platforms: linux/amd64 + push: true + provenance: false + sbom: false + labels: ${{ inputs.publication_target == 'public-release' && 'org.opencontainers.image.source=https://github.com/WSJTX/wsjtx' || '' }} + tags: | + ${{ needs.metadata.outputs.package_root }}/linux-noble:${{ needs.metadata.outputs.candidate_tag }} + ${{ needs.metadata.outputs.package_root }}/linux-noble:${{ needs.metadata.outputs.build_tag }} + build-args: | + IMAGE_CREATED=${{ needs.metadata.outputs.created }} + IMAGE_GENERATION=${{ needs.metadata.outputs.build_tag }} + IMAGE_REVISION=${{ github.sha }} + IMAGE_RECIPE_SHA256=${{ needs.metadata.outputs.normal_noble_recipe }} + IMAGE_REFRESH_EPOCH=${{ needs.metadata.outputs.refresh_epoch }} + cache-from: ${{ needs.metadata.outputs.normal_cache_from }} + cache-to: type=inline + + build-tsan: + if: inputs.image_set == 'tsan' || inputs.image_set == 'normal-and-tsan' + needs: metadata + runs-on: ubuntu-24.04 + timeout-minutes: 240 + outputs: + digest: ${{ steps.build.outputs.digest }} + steps: + - uses: actions/checkout@v7 + - uses: docker/setup-buildx-action@v4 + - uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - id: build + uses: docker/build-push-action@v7 + with: + context: . + file: .github/images/linux-ci/Dockerfile.noble + target: tsan + platforms: linux/amd64 + push: true + provenance: false + sbom: false + labels: ${{ inputs.publication_target == 'public-release' && 'org.opencontainers.image.source=https://github.com/WSJTX/wsjtx' || '' }} + tags: | + ghcr.io/wsjtx/wsjtx-internal/linux-tsan-noble:${{ needs.metadata.outputs.candidate_tag }} + ghcr.io/wsjtx/wsjtx-internal/linux-tsan-noble:${{ needs.metadata.outputs.build_tag }} + build-args: | + IMAGE_CREATED=${{ needs.metadata.outputs.created }} + IMAGE_GENERATION=${{ needs.metadata.outputs.build_tag }} + IMAGE_REVISION=${{ github.sha }} + IMAGE_RECIPE_SHA256=${{ needs.metadata.outputs.tsan_noble_recipe }} + IMAGE_REFRESH_EPOCH=${{ needs.metadata.outputs.refresh_epoch }} + cache-from: type=registry,ref=ghcr.io/wsjtx/wsjtx-internal/linux-tsan-noble:stable + cache-to: type=inline + + build-arm64: + if: inputs.image_set == 'normal' || inputs.image_set == 'normal-and-tsan' + needs: metadata + runs-on: ubuntu-24.04-arm + timeout-minutes: 120 + outputs: + digest: ${{ steps.build.outputs.digest }} + steps: + - uses: actions/checkout@v7 + - uses: docker/setup-buildx-action@v4 + - uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - id: build + uses: docker/build-push-action@v7 + with: + context: . + file: .github/images/linux-ci/Dockerfile.bookworm + platforms: linux/arm64 + push: true + provenance: false + sbom: false + labels: ${{ inputs.publication_target == 'public-release' && 'org.opencontainers.image.source=https://github.com/WSJTX/wsjtx' || '' }} + tags: | + ${{ needs.metadata.outputs.package_root }}/linux-arm64-bookworm:${{ needs.metadata.outputs.candidate_tag }} + ${{ needs.metadata.outputs.package_root }}/linux-arm64-bookworm:${{ needs.metadata.outputs.build_tag }} + build-args: | + IMAGE_ARCH=aarch64 + IMAGE_CREATED=${{ needs.metadata.outputs.created }} + IMAGE_GENERATION=${{ needs.metadata.outputs.build_tag }} + IMAGE_REVISION=${{ github.sha }} + IMAGE_RECIPE_SHA256=${{ needs.metadata.outputs.normal_bookworm_recipe }} + IMAGE_REFRESH_EPOCH=${{ needs.metadata.outputs.refresh_epoch }} + cache-from: ${{ needs.metadata.outputs.arm64_cache_from }} + cache-to: type=inline + + build-armhf-cross: + if: >- + inputs.include_armhf && + (inputs.image_set == 'normal' || inputs.image_set == 'normal-and-tsan') + needs: metadata + runs-on: ubuntu-24.04 + timeout-minutes: 180 + outputs: + digest: ${{ steps.build.outputs.digest }} + steps: + - uses: actions/checkout@v7 + - name: Reclaim disk for the ARMHF cross-toolchain + run: | + # crosstool-NG needs about 8 GiB of transient build storage. Remove + # unused hosted-runner SDKs so the Actions worker retains log space. + df -h / + sudo rm -rf -- /usr/local/lib/android /usr/share/dotnet /opt/ghc + df -h / + - uses: docker/setup-buildx-action@v4 + - uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - id: build + uses: docker/build-push-action@v7 + with: + context: . + file: .github/images/linux-ci/Dockerfile.armhf-cross + platforms: linux/amd64 + push: true + provenance: false + sbom: false + labels: ${{ inputs.publication_target == 'public-release' && 'org.opencontainers.image.source=https://github.com/WSJTX/wsjtx' || '' }} + tags: | + ${{ needs.metadata.outputs.package_root }}/linux-armhf-cross-bookworm:${{ needs.metadata.outputs.candidate_tag }} + ${{ needs.metadata.outputs.package_root }}/linux-armhf-cross-bookworm:${{ needs.metadata.outputs.build_tag }} + build-args: | + IMAGE_CREATED=${{ needs.metadata.outputs.created }} + IMAGE_GENERATION=${{ needs.metadata.outputs.build_tag }} + IMAGE_REVISION=${{ github.sha }} + IMAGE_RECIPE_SHA256=${{ needs.metadata.outputs.armhf_cross_recipe }} + IMAGE_REFRESH_EPOCH=${{ needs.metadata.outputs.refresh_epoch }} + cache-from: ${{ needs.metadata.outputs.armhf_cross_cache_from }} + cache-to: type=inline + + build-armhf-runtime: + if: >- + inputs.include_armhf && + (inputs.image_set == 'normal' || inputs.image_set == 'normal-and-tsan') + needs: + - metadata + - build-armhf-cross + runs-on: ubuntu-24.04-arm + timeout-minutes: 180 + outputs: + digest: ${{ steps.build.outputs.digest }} + steps: + - uses: actions/checkout@v7 + - uses: docker/setup-qemu-action@v4 + with: + image: tonistiigi/binfmt:qemu-v10.2.3-68@sha256:400a4873b838d1b89194d982c45e5fb3cda4593fbfd7e08a02e76b03b21166f0 + platforms: linux/arm/v7 + - uses: docker/setup-buildx-action@v4 + - uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - id: build + uses: docker/build-push-action@v7 + with: + context: . + file: .github/images/linux-ci/Dockerfile.armhf-runtime + platforms: linux/arm/v7 + push: true + provenance: false + sbom: false + labels: ${{ inputs.publication_target == 'public-release' && 'org.opencontainers.image.source=https://github.com/WSJTX/wsjtx' || '' }} + tags: | + ${{ needs.metadata.outputs.package_root }}/linux-armv7-bookworm:${{ needs.metadata.outputs.candidate_tag }} + ${{ needs.metadata.outputs.package_root }}/linux-armv7-bookworm:${{ needs.metadata.outputs.build_tag }} + build-args: | + CROSS_BUILDER_IMAGE=${{ needs.metadata.outputs.package_root }}/linux-armhf-cross-bookworm:${{ needs.metadata.outputs.build_tag }} + IMAGE_CREATED=${{ needs.metadata.outputs.created }} + IMAGE_GENERATION=${{ needs.metadata.outputs.build_tag }} + IMAGE_REVISION=${{ github.sha }} + IMAGE_RECIPE_SHA256=${{ needs.metadata.outputs.armhf_runtime_recipe }} + IMAGE_REFRESH_EPOCH=${{ needs.metadata.outputs.refresh_epoch }} + cache-from: ${{ needs.metadata.outputs.armhf_cache_from }} + cache-to: type=inline + + warm-normal-ccache: + if: >- + inputs.promote && + (inputs.image_set == 'normal' || inputs.image_set == 'normal-and-tsan') + needs: + - metadata + - build-normal + uses: ./.github/workflows/build-linux.yml + permissions: + contents: read + packages: read + with: + version: ${{ needs.metadata.outputs.version }} + hamlib_branch: ${{ needs.metadata.outputs.normal_hamlib_ref }} + arch: x86_64 + image_tag: ${{ needs.metadata.outputs.build_tag }} + allow_stale_image: false + recache: false + save_ccache: true + + warm-arm64-ccache: + if: >- + inputs.promote && + (inputs.image_set == 'normal' || inputs.image_set == 'normal-and-tsan') + needs: + - metadata + - build-arm64 + uses: ./.github/workflows/build-linux.yml + permissions: + contents: read + packages: read + with: + version: ${{ needs.metadata.outputs.version }} + hamlib_branch: ${{ needs.metadata.outputs.normal_hamlib_ref }} + arch: aarch64 + image_tag: ${{ needs.metadata.outputs.build_tag }} + allow_stale_image: false + recache: false + save_ccache: true + + promote: + if: >- + always() && inputs.mode == 'refresh' && inputs.promote && + (inputs.image_set == 'tsan' || + (needs.build-normal.result == 'success' && + needs.build-arm64.result == 'success' && + needs.warm-normal-ccache.result == 'success' && + needs.warm-arm64-ccache.result == 'success' && + (inputs.include_armhf == false || + (needs.build-armhf-cross.result == 'success' && needs.build-armhf-runtime.result == 'success')))) && + (inputs.image_set == 'normal' || needs.build-tsan.result == 'success') + needs: + - metadata + - build-normal + - build-tsan + - build-arm64 + - build-armhf-cross + - build-armhf-runtime + - warm-normal-ccache + - warm-arm64-ccache + runs-on: ubuntu-24.04 + timeout-minutes: 15 + steps: + - uses: docker/setup-buildx-action@v4 + - uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Promote validated image digests + env: + VALIDATED_TAG: validated-${{ needs.metadata.outputs.build_tag }} + INCLUDE_ARMHF: ${{ inputs.include_armhf }} + IMAGE_SET: ${{ inputs.image_set }} + shell: bash + run: | + if [ "$IMAGE_SET" != tsan ]; then + docker buildx imagetools create --prefer-index=false \ + --tag "ghcr.io/wsjtx/wsjtx-internal/linux-noble:${VALIDATED_TAG}" \ + ghcr.io/wsjtx/wsjtx-internal/linux-noble@${{ needs.build-normal.outputs.digest }} + docker buildx imagetools create --prefer-index=false \ + --tag "ghcr.io/wsjtx/wsjtx-internal/linux-arm64-bookworm:${VALIDATED_TAG}" \ + ghcr.io/wsjtx/wsjtx-internal/linux-arm64-bookworm@${{ needs.build-arm64.outputs.digest }} + if [ "$INCLUDE_ARMHF" = true ]; then + docker buildx imagetools create --prefer-index=false \ + --tag "ghcr.io/wsjtx/wsjtx-internal/linux-armhf-cross-bookworm:${VALIDATED_TAG}" \ + ghcr.io/wsjtx/wsjtx-internal/linux-armhf-cross-bookworm@${{ needs.build-armhf-cross.outputs.digest }} + docker buildx imagetools create --prefer-index=false \ + --tag "ghcr.io/wsjtx/wsjtx-internal/linux-armv7-bookworm:${VALIDATED_TAG}" \ + ghcr.io/wsjtx/wsjtx-internal/linux-armv7-bookworm@${{ needs.build-armhf-runtime.outputs.digest }} + fi + fi + if [ "$IMAGE_SET" != normal ]; then + docker buildx imagetools create --prefer-index=false \ + --tag "ghcr.io/wsjtx/wsjtx-internal/linux-tsan-noble:${VALIDATED_TAG}" \ + ghcr.io/wsjtx/wsjtx-internal/linux-tsan-noble@${{ needs.build-tsan.outputs.digest }} + fi + + if [ "$IMAGE_SET" != normal ]; then + docker buildx imagetools create --prefer-index=false \ + --tag ghcr.io/wsjtx/wsjtx-internal/linux-tsan-noble:stable \ + ghcr.io/wsjtx/wsjtx-internal/linux-tsan-noble@${{ needs.build-tsan.outputs.digest }} + fi + if [ "$IMAGE_SET" != tsan ]; then + docker buildx imagetools create --prefer-index=false \ + --tag ghcr.io/wsjtx/wsjtx-internal/linux-arm64-bookworm:stable \ + ghcr.io/wsjtx/wsjtx-internal/linux-arm64-bookworm@${{ needs.build-arm64.outputs.digest }} + if [ "$INCLUDE_ARMHF" = true ]; then + docker buildx imagetools create --prefer-index=false \ + --tag ghcr.io/wsjtx/wsjtx-internal/linux-armhf-cross-bookworm:stable \ + ghcr.io/wsjtx/wsjtx-internal/linux-armhf-cross-bookworm@${{ needs.build-armhf-cross.outputs.digest }} + docker buildx imagetools create --prefer-index=false \ + --tag ghcr.io/wsjtx/wsjtx-internal/linux-armv7-bookworm:stable \ + ghcr.io/wsjtx/wsjtx-internal/linux-armv7-bookworm@${{ needs.build-armhf-runtime.outputs.digest }} + fi + # linux-noble:stable moves last within the normal image cohort. + docker buildx imagetools create --prefer-index=false \ + --tag ghcr.io/wsjtx/wsjtx-internal/linux-noble:stable \ + ghcr.io/wsjtx/wsjtx-internal/linux-noble@${{ needs.build-normal.outputs.digest }} + fi + + rollback: + if: inputs.mode == 'rollback' + needs: validate-inputs + runs-on: ubuntu-24.04 + timeout-minutes: 15 + steps: + - uses: docker/setup-buildx-action@v4 + - uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Restore retained generation + env: + ROLLBACK_TAG: ${{ inputs.rollback_tag }} + INCLUDE_ARMHF: ${{ inputs.include_armhf }} + IMAGE_SET: ${{ inputs.image_set }} + shell: bash + run: | + packages=() + stable_packages=() + if [ "$IMAGE_SET" != tsan ]; then + packages+=(linux-noble linux-arm64-bookworm) + stable_packages+=(linux-arm64-bookworm) + if [ "$INCLUDE_ARMHF" = true ]; then + packages+=(linux-armhf-cross-bookworm linux-armv7-bookworm) + stable_packages+=(linux-armhf-cross-bookworm linux-armv7-bookworm) + fi + # linux-noble:stable moves last within the normal image cohort. + stable_packages+=(linux-noble) + fi + if [ "$IMAGE_SET" != normal ]; then + packages+=(linux-tsan-noble) + if [ "$IMAGE_SET" = tsan ]; then + stable_packages=(linux-tsan-noble) + else + stable_packages=(linux-tsan-noble "${stable_packages[@]}") + fi + fi + + for package in "${packages[@]}"; do + docker buildx imagetools inspect \ + "ghcr.io/wsjtx/wsjtx-internal/${package}:${ROLLBACK_TAG}" >/dev/null + done + + for package in "${stable_packages[@]}"; do + docker buildx imagetools create --prefer-index=false \ + --tag "ghcr.io/wsjtx/wsjtx-internal/${package}:stable" \ + "ghcr.io/wsjtx/wsjtx-internal/${package}:${ROLLBACK_TAG}" + done diff --git a/.github/workflows/release-tag-helper.yml b/.github/workflows/release-tag-helper.yml new file mode 100644 index 00000000..c8cc375e --- /dev/null +++ b/.github/workflows/release-tag-helper.yml @@ -0,0 +1,126 @@ +name: Prepare Release Candidate + +on: + workflow_dispatch: + inputs: + version: + description: "Version without v (X.Y.Z or X.Y.Z-rcN)" + required: true + type: string + expected_sha: + description: "Full SHA at the tip of release/X.Y" + required: true + type: string + operation: + description: "Validate only, or create the immutable candidate tag and start its build" + required: true + type: choice + options: [validate, create] + default: validate + +permissions: + actions: read + contents: write + +jobs: + prepare: + runs-on: ubuntu-latest + timeout-minutes: 15 + environment: candidate-tagging + outputs: + candidate_tag: ${{ steps.validate.outputs.candidate_tag }} + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + - name: Fetch release branches and tags + run: git fetch origin '+refs/heads/release/*:refs/remotes/origin/release/*' '+refs/tags/*:refs/tags/*' + - name: Validate release commit + id: validate + env: + GH_TOKEN: ${{ github.token }} + VERSION: ${{ inputs.version }} + EXPECTED_SHA: ${{ inputs.expected_sha }} + run: | + set -euo pipefail + if [[ ! "$EXPECTED_SHA" =~ ^[0-9a-f]{40}$ ]]; then + echo "::error::expected_sha must be a full 40-character lowercase commit SHA" + exit 1 + fi + IDENTITY=$(python3 .github/scripts/release-policy.py classify "$VERSION") + BRANCH=$(jq -r .release_branch <<<"$IDENTITY") + if [ "$GITHUB_SHA" != "$EXPECTED_SHA" ]; then + echo "::error::Run this workflow from $BRANCH at $EXPECTED_SHA" + exit 1 + fi + BRANCH_SHA=$(git rev-parse --verify --quiet "refs/remotes/origin/$BRANCH^{commit}" || true) + if [ "$BRANCH_SHA" != "$EXPECTED_SHA" ]; then + echo "::error::$BRANCH tip is ${BRANCH_SHA:-missing}, expected $EXPECTED_SHA" + exit 1 + fi + git checkout --detach "$EXPECTED_SHA" + python3 .github/scripts/release-policy.py validate-source "$VERSION" + + CI_RUN=$(gh api "repos/$GITHUB_REPOSITORY/actions/workflows/ci.yml/runs?head_sha=$EXPECTED_SHA&status=completed&per_page=20" \ + --jq '.workflow_runs | sort_by(.created_at) | reverse | .[0]') + if [ -z "$CI_RUN" ] || [ "$CI_RUN" = null ]; then + echo "::error::No completed ci.yml run found for $EXPECTED_SHA" + exit 1 + fi + CI_ID=$(jq -r .id <<<"$CI_RUN") + CI_CONCLUSION=$(jq -r .conclusion <<<"$CI_RUN") + if [ "$CI_CONCLUSION" != success ]; then + echo "::error::Latest ci.yml run $CI_ID concluded $CI_CONCLUSION" + exit 1 + fi + { + echo "branch=$BRANCH" + echo "ci_run_id=$CI_ID" + echo "candidate_tag=build/v$VERSION" + } >> "$GITHUB_OUTPUT" + + - name: Verify candidate tag is create-only + id: tag + env: + VERSION: ${{ inputs.version }} + EXPECTED_SHA: ${{ inputs.expected_sha }} + run: | + .github/scripts/check-candidate-tag.sh "build/v$VERSION" "$EXPECTED_SHA" >> "$GITHUB_OUTPUT" + + - name: Create candidate tag + if: inputs.operation == 'create' && steps.tag.outputs.exists != 'true' + env: + VERSION: ${{ inputs.version }} + EXPECTED_SHA: ${{ inputs.expected_sha }} + run: | + git tag "build/v$VERSION" "$EXPECTED_SHA" + git push origin "refs/tags/build/v$VERSION:refs/tags/build/v$VERSION" + + - name: Summarize candidate preparation + env: + VERSION: ${{ inputs.version }} + EXPECTED_SHA: ${{ inputs.expected_sha }} + OPERATION: ${{ inputs.operation }} + BRANCH: ${{ steps.validate.outputs.branch }} + CI_RUN_ID: ${{ steps.validate.outputs.ci_run_id }} + run: | + { + echo "## Release candidate preparation" + echo + echo "- Version: \`$VERSION\`" + echo "- Commit: \`$EXPECTED_SHA\`" + echo "- Release branch: \`$BRANCH\`" + echo "- CI run: [\`$CI_RUN_ID\`]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$CI_RUN_ID)" + echo "- Operation: \`$OPERATION\`" + } >> "$GITHUB_STEP_SUMMARY" + + candidate: + if: inputs.operation == 'create' + needs: prepare + permissions: + contents: read + packages: read + uses: ./.github/workflows/release.yml + with: + candidate_tag: ${{ needs.prepare.outputs.candidate_tag }} + expected_sha: ${{ inputs.expected_sha }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a8b9bd42..bde30629 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,359 +1,191 @@ -name: Release +name: Build Release Candidate on: - push: - tags: ["build/v*"] + workflow_call: + inputs: + candidate_tag: + description: "Immutable internal tag (build/vX.Y.Z or build/vX.Y.Z-rcN)" + required: true + type: string + expected_sha: + description: "Full commit SHA selected by the release tag helper" + required: true + type: string + +permissions: + contents: read + packages: read + +concurrency: + group: release-candidate-${{ inputs.candidate_tag }} + cancel-in-progress: false jobs: - # ── Derive the version string once from the pushed tag ──────────── - # Strips the "build/v" prefix so artifacts are named "wsjtx-3.0.1-rc1-*" - # rather than "wsjtx-build/v3.0.1-rc1-*". RC/beta suffixes (e.g. - # build/v3.0.1-rc1 → 3.0.1-rc1) are preserved so pre-release artifacts - # are distinguishable from GA. All downstream jobs consume this - # single output so the five platform artifacts cannot disagree. prepare: runs-on: ubuntu-latest + timeout-minutes: 10 outputs: - version: ${{ steps.v.outputs.version }} - release_channel: ${{ steps.v.outputs.release_channel }} - rc_number: ${{ steps.v.outputs.rc_number }} + version: ${{ steps.identity.outputs.version }} + release_channel: ${{ steps.identity.outputs.channel }} + rc_number: ${{ steps.identity.outputs.rc_number }} + windows_signing: ${{ steps.identity.outputs.windows_signing }} + linux_image_tag: ${{ steps.linux-image.outputs.image_tag }} + armhf_image_tag: ${{ steps.armhf-image.outputs.image_tag }} + env: + CANDIDATE_TAG: ${{ inputs.candidate_tag }} + EXPECTED_SHA: ${{ inputs.expected_sha }} steps: - - uses: actions/checkout@v6 - - id: v + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + ref: ${{ env.CANDIDATE_TAG }} + - name: Verify immutable candidate identity + id: identity run: | - VERSION="${GITHUB_REF_NAME#build/v}" - if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - RELEASE_CHANNEL=GA - RC_NUMBER="" - elif [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+-rc([1-9][0-9]*)$ ]]; then - RELEASE_CHANNEL=RC - RC_NUMBER="${BASH_REMATCH[1]}" - else - echo "::error::Unsupported release tag version: $VERSION" - echo "::error::Supported release tags are build/vX.Y.Z and build/vX.Y.Z-rcN." + set -euo pipefail + if [[ ! "$CANDIDATE_TAG" =~ ^build/v(.+)$ ]]; then + echo "::error::Expected build/vX.Y.Z or build/vX.Y.Z-rcN, got $CANDIDATE_TAG" exit 1 fi - - { - echo "version=$VERSION" - echo "release_channel=$RELEASE_CHANNEL" - echo "rc_number=$RC_NUMBER" - } >> "$GITHUB_OUTPUT" - - # Enforce that the pushed tag's numeric version base - # matches CMakeLists.txt:55 VERSION (first 3 components). CMake's - # VERSION field is numeric-only and cannot carry pre-release - # suffixes like -rc1 or -beta1, so this check compares the tag - # version stripped of any `-<suffix>` against the first three - # dotted components of CMakeLists.txt VERSION. Mismatch means the - # release commit forgot to bump CMakeLists.txt in lockstep with - # the tag; fail fast here before five platform builds burn ~30 - # minutes of CI. - - name: Verify tag ↔ CMakeLists.txt version parity - run: | - TAG_VERSION="${GITHUB_REF_NAME#build/v}" - TAG_NUMERIC="${TAG_VERSION%%-*}" - CMAKE_VERSION=$(sed -nE 's/^[[:space:]]*VERSION[[:space:]]+([0-9][0-9.]*).*/\1/p' CMakeLists.txt | head -1) - CMAKE_NUMERIC=$(echo "$CMAKE_VERSION" | awk -F. '{printf "%s.%s.%s", $1, $2, $3}') - echo "Tag version: $TAG_VERSION (numeric base: $TAG_NUMERIC)" - echo "CMakeLists.txt VER: $CMAKE_VERSION (first 3 components: $CMAKE_NUMERIC)" - if [ "$TAG_NUMERIC" != "$CMAKE_NUMERIC" ]; then - echo "::error::Tag numeric base ($TAG_NUMERIC) != CMakeLists.txt VERSION first 3 components ($CMAKE_NUMERIC)." - echo "::error::Bump CMakeLists.txt:55 VERSION in the same commit that gets tagged, then retry." + ACTUAL_SHA=$(git rev-parse HEAD) + if [ "$ACTUAL_SHA" != "$EXPECTED_SHA" ]; then + echo "::error::Candidate tag resolves to $ACTUAL_SHA, expected $EXPECTED_SHA" exit 1 fi - echo "Parity check PASSED." - - # ── Build all five platforms ─────────────────────────────────────── - macos-arm64-qt: - needs: prepare - uses: ./.github/workflows/prepare-macos-qt.yml - with: - arch: "arm64" - runner: "macos-15" - deployment_target: "11.0" - - macos-intel-qt: - needs: prepare - uses: ./.github/workflows/prepare-macos-qt.yml - with: - arch: "x86_64" - runner: "macos-15-intel" - deployment_target: "10.13" + VERSION="${CANDIDATE_TAG#build/v}" + IDENTITY=$(python3 .github/scripts/release-policy.py validate-source "$VERSION") + { + echo "version=$(jq -r .version <<<"$IDENTITY")" + echo "channel=$(jq -r .channel <<<"$IDENTITY")" + echo "rc_number=$(jq -r .rc_number <<<"$IDENTITY")" + echo "windows_signing=$(jq -r .windows_signing <<<"$IDENTITY")" + } >> "$GITHUB_OUTPUT" + - 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 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + RESOLVE_ARMHF: true + run: .github/scripts/resolve-linux-ci-image-tag.py macos: - needs: [prepare, macos-arm64-qt] + needs: prepare uses: ./.github/workflows/build-macos.yml with: version: ${{ needs.prepare.outputs.version }} - hamlib_branch: "4.7.1" - arch: "arm64" - runner: "macos-15" + hamlib_branch: "4.7.2" + arch: arm64 + runner: macos-15 deployment_target: "11.0" release_channel: ${{ needs.prepare.outputs.release_channel }} rc_number: ${{ needs.prepare.outputs.rc_number }} - secrets: inherit + signing_mode: validation macos-intel: - needs: [prepare, macos-intel-qt] + needs: prepare uses: ./.github/workflows/build-macos.yml with: version: ${{ needs.prepare.outputs.version }} - hamlib_branch: "4.7.1" - arch: "x86_64" + hamlib_branch: "4.7.2" + arch: x86_64 + runner: macos-15-intel + deployment_target: "10.13" release_channel: ${{ needs.prepare.outputs.release_channel }} rc_number: ${{ needs.prepare.outputs.rc_number }} - runner: "macos-15-intel" - deployment_target: "10.13" - secrets: inherit + signing_mode: validation linux: needs: prepare uses: ./.github/workflows/build-linux.yml with: version: ${{ needs.prepare.outputs.version }} - hamlib_branch: "4.7.1" - arch: "x86_64" + hamlib_branch: "4.7.2" + arch: x86_64 + image_tag: ${{ needs.prepare.outputs.linux_image_tag }} + save_ccache: true + build_packages: true release_channel: ${{ needs.prepare.outputs.release_channel }} rc_number: ${{ needs.prepare.outputs.rc_number }} - secrets: inherit linux-arm: needs: prepare uses: ./.github/workflows/build-linux.yml with: version: ${{ needs.prepare.outputs.version }} - hamlib_branch: "4.7.1" - arch: "aarch64" + hamlib_branch: "4.7.2" + arch: aarch64 + image_tag: ${{ needs.prepare.outputs.linux_image_tag }} + save_ccache: true + build_packages: true + release_channel: ${{ needs.prepare.outputs.release_channel }} + rc_number: ${{ needs.prepare.outputs.rc_number }} + + # Cross-compile on x86_64, then run target tests, packaging, and AppImage + # validation in the paired ARMv7 runtime image under QEMU. + linux-armhf: + needs: prepare + 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 + save_ccache: true + build_packages: true release_channel: ${{ needs.prepare.outputs.release_channel }} rc_number: ${{ needs.prepare.outputs.rc_number }} - secrets: inherit windows: needs: prepare uses: ./.github/workflows/build-windows.yml with: version: ${{ needs.prepare.outputs.version }} - hamlib_branch: "4.7.1" + hamlib_branch: "4.7.2" release_channel: ${{ needs.prepare.outputs.release_channel }} rc_number: ${{ needs.prepare.outputs.rc_number }} - secrets: inherit - # ── Publish release + sync to public repo ────────────────────────── - release: - needs: [prepare, macos, macos-intel, linux, linux-arm, windows] + candidate-ready: + needs: [prepare, macos, macos-intel, linux, linux-arm, linux-armhf, windows] runs-on: ubuntu-latest - permissions: - contents: write + timeout-minutes: 15 steps: - - uses: actions/checkout@v6 - with: - fetch-depth: 0 - persist-credentials: false - - - name: Download all artifacts - uses: actions/download-artifact@v8 + - uses: actions/checkout@v7 + - uses: actions/download-artifact@v8 with: path: artifacts - - # Source tarball is published on GA releases only, not on RC (-rc*, - # -beta*, etc.) pre-releases. Rationale: RCs may carry code for features - # that are not yet intended for open source distribution (limited-access - # field testing). GA releases always include a source tarball per the - # CI/CD adoption decision on platform-matrix assets. - - name: Build source tarball (GA only) - if: ${{ !contains(github.ref_name, '-') }} - env: - VERSION: ${{ needs.prepare.outputs.version }} - run: | - # This repo has no git submodules, so git archive's default - # single-tree output captures the full source. If submodules - # are ever added, this step must be revisited — git archive - # does not recurse into submodules on its own. - git archive \ - --format=tar.gz \ - --prefix="wsjtx-${VERSION}/" \ - -o "artifacts/wsjtx-${VERSION}-src.tar.gz" \ - "${GITHUB_REF_NAME}" - ls -lh "artifacts/wsjtx-${VERSION}-src.tar.gz" - - - name: List artifacts - run: find artifacts -type f | sort - - # ── All-platforms-ready gate ─────────────────────────────────────── - # Refuse to publish unless every platform produced an installer-grade - # artifact. The release job's `needs:` already enforces structural - # success (all 5 builds ran and exited 0), but a build can exit 0 - # without actually packaging — e.g. a packaging step behind an `if:` - # that evaluated false, or an upload-artifact step that silently - # matched zero files. This gate fails the release job BEFORE any - # asset upload so partial releases never reach GitHub Releases or - # the public mirror. - # - # Expected artifact layout (one installer per platform, per the - # five build-*.yml upload-artifact steps): - # artifacts/wsjtx-<ver>-arm64-macOS.pkg/*.pkg - # artifacts/wsjtx-<ver>-x86_64-macOS.pkg/*.pkg - # artifacts/wsjtx-<ver>-linux-x86_64-AppImage/*.AppImage - # artifacts/wsjtx-<ver>-linux-aarch64-AppImage/*.AppImage - # artifacts/wsjtx-<ver>-windows-x86_64-installer/*.exe - # - # Policy: publish only when all five platforms have produced an - # installer-grade artifact. Adjust or remove this step if the - # policy evolves (e.g. to publish any-platform-ready). - - name: Verify installer-grade artifacts (all-platforms-ready gate) - env: - VERSION: ${{ needs.prepare.outputs.version }} - run: | - shopt -s nullglob - labels=( - "macOS arm64 .pkg" - "macOS x86_64 .pkg" - "Linux x86_64 .AppImage" - "Linux aarch64 .AppImage" - "Windows x86_64 .exe" - ) - patterns=( - "artifacts/wsjtx-${VERSION}-arm64-macOS.pkg/*.pkg" - "artifacts/wsjtx-${VERSION}-x86_64-macOS.pkg/*.pkg" - "artifacts/wsjtx-${VERSION}-linux-x86_64-AppImage/*.AppImage" - "artifacts/wsjtx-${VERSION}-linux-aarch64-AppImage/*.AppImage" - "artifacts/wsjtx-${VERSION}-windows-x86_64-installer/*.exe" - ) - missing=0 - echo "Installer-grade artifact gate — checking 5 platforms…" - for i in "${!labels[@]}"; do - # shellcheck disable=SC2206 # word-split is intentional; nullglob makes it safe. - matches=( ${patterns[$i]} ) - if [ ${#matches[@]} -eq 0 ]; then - echo "::error::MISSING ${labels[$i]} — no match for ${patterns[$i]}" - missing=$((missing + 1)) - else - size=$(stat --printf '%s' "${matches[0]}") - printf ' ok %-22s %s (%s bytes)\n' "${labels[$i]}" "${matches[0]}" "$size" - fi - done - if [ "$missing" -gt 0 ]; then - echo "::error::All-platforms-ready gate FAILED — $missing of 5 platform(s) missing installer-grade artifact." - echo "::error::Refusing to publish a partial release. Fix the failing build job(s) and retry the tag." - exit 1 - fi - echo "All-platforms-ready gate PASSED — all 5 installer-grade artifacts present. Proceeding to publish." - - - name: Create GitHub Release - env: - GH_TOKEN: ${{ github.token }} - run: | - TAG="${GITHUB_REF_NAME}" - # Filter to user-facing release assets. `find artifacts -type f` - # without filtering pulls in 5× ctest-results.xml (one per - # platform) and per-binary tarballs from individual-binaries-* - # that collide on basename across architectures — `gh release - # create` uses basenames as asset names and duplicates cause - # upload failures. - mapfile -t files < <(find artifacts -maxdepth 2 -type f \ - \( -name "*.pkg" -o -name "*.AppImage" -o -name "*.deb" \ - -o -name "*.exe" -o -name "*.tar.gz" -o -name "*.rpm" \)) - # SemVer pre-release tags contain a hyphen after the version - # (e.g., v3.0.1-rc1, v3.0.1-rc2, v3.0.1-beta1). Flag those as - # GitHub pre-releases so they don't appear as the latest stable. - PRERELEASE_FLAG="" - if [[ "$TAG" == *-* ]]; then - PRERELEASE_FLAG="--prerelease" - fi - gh release create "$TAG" \ - --title "WSJT-X ${{ needs.prepare.outputs.version }}" \ - --generate-notes \ - $PRERELEASE_FLAG \ - "${files[@]}" - - # ── Public mirror: GA only ───────────────────────────────────────── - # RC/beta tags (any tag carrying a '-' in the version, e.g. - # build/v3.0.1-rc1) stay internal — the public WSJTX/wsjtx repo is - # for stable releases only. The Build source tarball step above - # uses the same predicate; mirror logic must too. - - # Defense-in-depth: the workflow trigger already constrains - # github.ref_name to tags matching build/v*, but if this job - # ever runs outside that trigger (workflow_dispatch, manual - # re-run with a fork ref, misconfiguration) the force-push - # below would overwrite WSJTX/wsjtx:master with arbitrary content. - # Abort here if the ref doesn't match the expected release-tag - # shape. - - name: Verify release tag format (GA only) - if: ${{ !contains(github.ref_name, '-') }} - run: | - if [[ "$GITHUB_REF_TYPE" != "tag" || "$GITHUB_REF_NAME" != build/v* ]]; then - echo "::error::Refusing to sync — expected tag build/v*, got $GITHUB_REF_TYPE:$GITHUB_REF_NAME" - exit 1 - fi - - - name: Push to public repo (GA only) - if: ${{ !contains(github.ref_name, '-') }} - env: - TOKEN: ${{ secrets.CROSS_REPO_TOKEN }} + - name: Verify all candidate artifacts + run: python3 .github/scripts/release-policy.py verify-assets "${{ needs.prepare.outputs.version }}" artifacts + - name: Verify candidate packaging reports run: | - # A "successful" release that silently skips the mirror sync is - # the worst failure mode — it looks green in Actions but leaves - # users unable to download. Fail loud instead. - if [ -z "$TOKEN" ]; then - echo "::error::CROSS_REPO_TOKEN not set — refusing to publish without public-mirror sync" - exit 1 - fi - # Use CROSS_REPO_TOKEN (PAT with Contents:write on WSJTX/wsjtx) - # over HTTPS. Idempotent: on job re-run the remote already exists, - # so skip add. - if ! git remote get-url public >/dev/null 2>&1; then - git remote add public "https://x-access-token:${TOKEN}@github.com/WSJTX/wsjtx.git" - fi - - # Strip "build/" prefix per public release convention. Public - # users search for "v3.0.1", not "build/v3.0.1". Internal tag - # stays as-is for the wsjtx-internal release. - PUBLIC_TAG="${GITHUB_REF_NAME#build/}" - - # Derive the bare-prefix tag locally so the workflow doesn't - # depend on the team having pushed both tag forms. -f overwrites - # any pre-existing local tag at a stale SHA. - git tag -f "$PUBLIC_TAG" "$GITHUB_REF_NAME" - - # Human-auditable record of what the force-push is overwriting. - # If public master doesn't exist yet, ls-remote returns empty — - # still safe, just logs "no prior SHA". - PRIOR_SHA=$(git ls-remote public master | awk '{print $1}') - LOCAL_SHA=$(git rev-parse HEAD) - echo "Public mirror force-push audit:" - echo " internal tag: $GITHUB_REF_NAME" - echo " public tag: $PUBLIC_TAG" - echo " prior SHA: ${PRIOR_SHA:-<none>}" - echo " new SHA: $LOCAL_SHA" - - # --force retained per CI/CD adoption decision #3 (option a): - # automate the existing sync pattern. The v3.0.0 tag SHAs already - # match on both repos, so the force-push aligns history rather - # than rewrites it in the normal release case. - git push public HEAD:master --force - git push public "refs/tags/${PUBLIC_TAG}:refs/tags/${PUBLIC_TAG}" - - # Create the public-side GitHub Release with installer assets - # attached. Without this step, public-side Releases page is empty - # after a mirror push (source + tag, no downloadables) and end users - # can't find the artifacts. - - name: Create public GitHub Release (GA only) - if: ${{ !contains(github.ref_name, '-') }} + python3 .github/scripts/release-policy.py verify-signing-reports \ + "${{ needs.prepare.outputs.version }}" artifacts \ + --commit "${{ inputs.expected_sha }}" --tag "${{ inputs.candidate_tag }}" \ + --macos-mode validation --windows-mode unsigned + - name: Record candidate provenance env: - GH_TOKEN: ${{ secrets.CROSS_REPO_TOKEN }} VERSION: ${{ needs.prepare.outputs.version }} + CANDIDATE_TAG: ${{ inputs.candidate_tag }} + CANDIDATE_SHA: ${{ inputs.expected_sha }} + WINDOWS_RELEASE_MODE: ${{ needs.prepare.outputs.windows_signing }} run: | - PUBLIC_TAG="${GITHUB_REF_NAME#build/}" - # Same asset filter as the internal release. Re-find rather than - # carrying a list — keeps the all-platforms-ready gate, internal - # release, and public release mechanically aligned on one filter. - mapfile -t files < <(find artifacts -maxdepth 2 -type f \ - \( -name "*.pkg" -o -name "*.AppImage" -o -name "*.deb" \ - -o -name "*.exe" -o -name "*.tar.gz" -o -name "*.rpm" \)) - gh release create "$PUBLIC_TAG" \ - -R WSJTX/wsjtx \ - --title "WSJT-X ${VERSION}" \ - --generate-notes \ - "${files[@]}" + jq -n \ + --arg version "$VERSION" \ + --arg tag "$CANDIDATE_TAG" \ + --arg commit "$CANDIDATE_SHA" \ + --arg repository "$GITHUB_REPOSITORY" \ + --arg run_id "$GITHUB_RUN_ID" \ + --arg windows_release_mode "$WINDOWS_RELEASE_MODE" \ + '{schema: 1, version: $version, tag: $tag, commit: $commit, repository: $repository, workflow_run: $run_id, windows_release_signing: $windows_release_mode, candidate_signing: {windows: "unsigned", macos: "validation"}}' \ + > artifacts/candidate-provenance.json + - name: Upload complete candidate + uses: actions/upload-artifact@v7 + with: + name: release-candidate-${{ needs.prepare.outputs.version }} + path: artifacts + if-no-files-found: error + retention-days: 30 diff --git a/.github/workflows/sign-windows-release.yml b/.github/workflows/sign-windows-release.yml new file mode 100644 index 00000000..a040ab43 --- /dev/null +++ b/.github/workflows/sign-windows-release.yml @@ -0,0 +1,142 @@ +name: Sign Windows Release + +on: + workflow_call: + inputs: + version: + required: true + type: string + release_channel: + required: true + type: string + rc_number: + required: false + type: string + default: "" + windows_signing: + required: false + type: string + default: signpath +permissions: + actions: read + contents: read + +jobs: + build: + uses: ./.github/workflows/build-windows.yml + with: + version: ${{ inputs.version }} + hamlib_branch: "4.7.2" + release_channel: ${{ inputs.release_channel }} + rc_number: ${{ inputs.rc_number }} + + sign: + if: inputs.windows_signing != 'unsigned' + needs: build + runs-on: ubuntu-latest + timeout-minutes: 90 + environment: windows-release-signing + permissions: + actions: read + contents: read + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + - name: Require a public RC or GA invocation + env: + VERSION: ${{ inputs.version }} + CHANNEL: ${{ inputs.release_channel }} + RC_NUMBER: ${{ inputs.rc_number }} + run: | + set -euo pipefail + IDENTITY=$(python3 .github/scripts/release-policy.py classify "$VERSION") + test "$(jq -r .channel <<<"$IDENTITY")" = "$CHANNEL" + test "$(jq -r .rc_number <<<"$IDENTITY")" = "$RC_NUMBER" + test "$GITHUB_REPOSITORY" = WSJTX/wsjtx + - name: Submit release signing request to SignPath + id: signpath + uses: signpath/github-action-submit-signing-request@v3 + with: + api-token: ${{ secrets.SIGNPATH_API_TOKEN }} + organization-id: "4c211821-e011-48a2-8a84-2cc29a76a8bf" + project-slug: wsjtx + signing-policy-slug: release-signing + github-artifact-id: ${{ needs.build.outputs.installer-artifact-id }} + wait-for-completion: true + wait-for-completion-timeout-in-seconds: "3600" + output-artifact-directory: signed + - name: Record signing request + env: + REQUEST_URL: ${{ steps.signpath.outputs.signing-request-web-url }} + run: | + printf '{"schema":1,"provider":"SignPath","policy":"release-signing","request_url":"%s","tag":"%s","commit":"%s"}\n' \ + "$REQUEST_URL" "$GITHUB_REF_NAME" "$GITHUB_SHA" > windows-signing-request.json + - name: Upload signed installer + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: wsjtx-${{ inputs.version }}-windows-x86_64-installer-signed + path: signed/*.exe + if-no-files-found: error + - name: Upload signing request report + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: wsjtx-${{ inputs.version }}-windows-signing-request + path: windows-signing-request.json + if-no-files-found: error + + verify: + needs: sign + runs-on: windows-latest + timeout-minutes: 15 + environment: windows-release-signing + steps: + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 + with: + name: wsjtx-${{ inputs.version }}-windows-x86_64-installer-signed + path: signed + - name: Verify trusted Authenticode signature and timestamp + shell: pwsh + env: + EXPECTED_SIGNER_SUBJECT: ${{ vars.WINDOWS_SIGNER_SUBJECT }} + EXPECTED_SIGNER_THUMBPRINTS: ${{ vars.WINDOWS_SIGNER_THUMBPRINTS }} + run: | + $exe = Get-ChildItem signed -Filter *.exe + if ($exe.Count -ne 1) { throw "Expected exactly one signed installer" } + $signtool = Get-ChildItem "C:\Program Files (x86)\Windows Kits\10\bin\*\x64\signtool.exe" | + Sort-Object FullName | Select-Object -Last 1 + if (-not $signtool) { throw "signtool.exe not found" } + & $signtool.FullName verify /pa /all /v $exe.FullName + if ($LASTEXITCODE -ne 0) { throw "Authenticode trust verification failed" } + $signature = Get-AuthenticodeSignature $exe.FullName + if ($signature.Status -ne 'Valid') { throw "Authenticode status is $($signature.Status)" } + if (-not $signature.TimeStamperCertificate) { throw "Installer signature has no trusted timestamp" } + if (-not $env:EXPECTED_SIGNER_SUBJECT) { throw "WINDOWS_SIGNER_SUBJECT is not configured" } + if ($signature.SignerCertificate.Subject -ne $env:EXPECTED_SIGNER_SUBJECT) { + throw "Unexpected Authenticode signer subject: $($signature.SignerCertificate.Subject)" + } + $allowedThumbprints = $env:EXPECTED_SIGNER_THUMBPRINTS.Split(',') | + ForEach-Object { $_.Replace(' ', '').ToUpperInvariant() } | + Where-Object { $_ } + $actualThumbprint = $signature.SignerCertificate.Thumbprint.ToUpperInvariant() + if ($allowedThumbprints.Count -eq 0 -or $actualThumbprint -notin $allowedThumbprints) { + throw "Unexpected Authenticode signer thumbprint: $actualThumbprint" + } + $sha256 = (Get-FileHash -Algorithm SHA256 $exe.FullName).Hash.ToLowerInvariant() + [ordered]@{ + schema = 1 + tag = $env:GITHUB_REF_NAME + commit = $env:GITHUB_SHA + artifact = $exe.Name + sha256 = $sha256 + status = $signature.Status.ToString() + signer_subject = $signature.SignerCertificate.Subject + signer_thumbprint = $signature.SignerCertificate.Thumbprint + identity_verified = $true + timestamp_subject = $signature.TimeStamperCertificate.Subject + timestamp_thumbprint = $signature.TimeStamperCertificate.Thumbprint + } | ConvertTo-Json | Set-Content windows-signing-verification.json + - name: Upload verification report + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: wsjtx-${{ inputs.version }}-windows-signing-verification + path: windows-signing-verification.json + if-no-files-found: error diff --git a/.github/workflows/signpath-smoke.yml b/.github/workflows/signpath-smoke.yml new file mode 100644 index 00000000..b6aa3a41 --- /dev/null +++ b/.github/workflows/signpath-smoke.yml @@ -0,0 +1,74 @@ +name: SignPath Smoke Test + +# Signs a trivial PE through the full SignPath round trip (token, slugs, +# artifact configuration, trusted build system) without building or +# exposing WSJT source. + +on: + workflow_dispatch: + inputs: + signing-policy-slug: + description: "SignPath signing policy to exercise" + required: false + type: choice + options: + - test-signing + - release-signing + default: test-signing + +jobs: + smoke: + if: github.repository == 'WSJTX/wsjtx' + runs-on: ubuntu-latest + timeout-minutes: 90 + environment: windows-release-signing + permissions: + actions: read + contents: read + steps: + - name: Build trivial PE file + run: | + # Keep this job independent of the dispatched repository ref. It + # submits an executable with the SignPath API token below. + sudo apt-get update -q + sudo apt-get install -y -q gcc-mingw-w64-x86-64 + cat > smoke.c <<'EOF' + #include <stdio.h> + int main(void) { puts("WSJT SignPath smoke test"); return 0; } + EOF + x86_64-w64-mingw32-gcc smoke.c -o signpath-smoke.exe + file signpath-smoke.exe + + - name: Upload unsigned artifact + id: upload + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: signpath-smoke + path: signpath-smoke.exe + + - name: Submit signing request to SignPath + id: signpath + uses: signpath/github-action-submit-signing-request@v3 + with: + api-token: ${{ secrets.SIGNPATH_API_TOKEN }} + organization-id: "4c211821-e011-48a2-8a84-2cc29a76a8bf" + project-slug: "wsjtx" + signing-policy-slug: ${{ inputs.signing-policy-slug }} + github-artifact-id: ${{ steps.upload.outputs.artifact-id }} + wait-for-completion: true + wait-for-completion-timeout-in-seconds: "3600" + output-artifact-directory: signed + + - name: Verify returned signature + run: | + echo "Signing request: ${{ steps.signpath.outputs.signing-request-web-url }}" + sudo apt-get install -y -q osslsigncode + ls -la signed/ + # The test cert never chains to a trusted root, so chain + # verification can't gate here. Require instead that an + # Authenticode signature is present and parses as PKCS#7 — + # both commands hard-fail on an unsigned or malformed exe. + osslsigncode extract-signature -in signed/signpath-smoke.exe -out smoke-sig.der + openssl pkcs7 -inform DER -in smoke-sig.der -print_certs -noout + # Chain status, informational only: + osslsigncode verify signed/signpath-smoke.exe || true diff --git a/.github/workflows/warm-dependency-caches.yml b/.github/workflows/warm-dependency-caches.yml new file mode 100644 index 00000000..db9f6593 --- /dev/null +++ b/.github/workflows/warm-dependency-caches.yml @@ -0,0 +1,443 @@ +name: Refresh Build Caches + +on: + push: + branches: [develop] + paths: + - ".github/workflows/ci.yml" + - ".github/workflows/release.yml" + - ".github/workflows/build-linux.yml" + - ".github/workflows/warm-dependency-caches.yml" + - ".github/actions/build-linux-payload/**" + - ".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/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-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 }} + 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 + windows=false + macos_arm64=false + macos_x86_64=false + + enable_cache_all() { + linux_arm64=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-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 + ;; + .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 "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 GHCR retention | $retention |" + echo "| Windows x86_64 | $windows |" + echo "| macOS arm64 | $macos_arm64 |" + echo "| macOS x86_64 | $macos_x86_64 |" + } >> "$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-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 |
