# Builds and tests the app (windows/) and the library that it uses # (core/, ssh/): on Windows 95 to Windows 11, and on Linux, macOS and # Haiku over clang-retro MFC's portable Win32 layer (winport/) name: Build # The nightly release (nightly.yml) takes its files from this # workflow's artifacts on main. Each artifact is a .tar.gz or a .zip, # because an artifact does not keep the executable bit of a file. on: push: branches: [main] pull_request: workflow_dispatch: permissions: contents: read jobs: # libdmodemctl (core/) and libdmodemssh (ssh/), with no app: the # tests, the tests with the sanitizers, and SSH against a real sshd core: name: Library and SSH tests (Linux) runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - name: Packages run: | sudo apt-get update sudo apt-get install -y --no-install-recommends \ cmake ninja-build pkg-config - name: Build run: | cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo cmake --build build - name: Test run: ctest --test-dir build --output-on-failure - name: Test with the sanitizers run: | cmake -S . -B build-asan -G Ninja -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_C_FLAGS="-fsanitize=address,undefined -fno-sanitize-recover=all" cmake --build build-asan --target dmodemctl_test ctest --test-dir build-asan --output-on-failure -R dmodemctl - name: SSH against a real sshd run: | sudo apt-get install -y --no-install-recommends openssh-server putty-tools sudo useradd -m dmtest echo 'dmtest:Sesame-42' | sudo chpasswd # a key in a file, one of PuTTY's (.ppk) and one in an agent ssh-keygen -q -t ed25519 -N '' -f "$RUNNER_TEMP/key" : > "$RUNNER_TEMP/empty" puttygen -t rsa -b 2048 -o "$RUNNER_TEMP/key.ppk" --new-passphrase "$RUNNER_TEMP/empty" ssh-keygen -q -t ecdsa -N '' -f "$RUNNER_TEMP/agentkey" eval "$(ssh-agent -a "$RUNNER_TEMP/agent.sock")" ssh-add "$RUNNER_TEMP/agentkey" unset SSH_AUTH_SOCK puttygen "$RUNNER_TEMP/key.ppk" -O public-openssh -o "$RUNNER_TEMP/ppk.pub" cat "$RUNNER_TEMP/key.pub" "$RUNNER_TEMP/agentkey.pub" "$RUNNER_TEMP/ppk.pub" > "$RUNNER_TEMP/authorized_keys" sudo install -d -m 700 -o dmtest ~dmtest/.ssh sudo install -m 600 -o dmtest "$RUNNER_TEMP/authorized_keys" ~dmtest/.ssh/authorized_keys sudo mkdir -p /run/sshd sudo /usr/sbin/sshd -p 2222 -o ListenAddress=127.0.0.1 -o PasswordAuthentication=yes DMODEM_SSH_TEST=127.0.0.1:2222:dmtest:Sesame-42 DMODEM_SSH_TEST_KEY="$RUNNER_TEMP/key" \ DMODEM_SSH_TEST_PPK="$RUNNER_TEMP/key.ppk" DMODEM_SSH_TEST_AGENT="$RUNNER_TEMP/agent.sock" \ build/ssh/dmodemssh_test # Both Windows builds use clang-retro (https://clang-retro.github.io/), # its toolchain package from its setup-toolchain action, on Linux windows-9x: name: Windows 95 and later, the modem built in (clang-retro, win32-picolibc) runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 with: submodules: true - uses: clang-retro/dos-sdk/.github/actions/setup-toolchain@main id: clang-dos - name: Packages run: | sudo dpkg --add-architecture i386 sudo apt-get update sudo apt-get install -y --no-install-recommends ninja-build wine wine32:i386 - name: Build run: | cmake -S . -B build/win9x -G Ninja -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_TOOLCHAIN_FILE=cmake/clang-retro.cmake -DCLANG_RETRO_CONFIG=win32-picolibc \ -DCMAKE_CROSSCOMPILING_EMULATOR=wine cmake --build build/win9x - name: Test (Wine) run: | export WINEDEBUG=-all WINEPREFIX="$RUNNER_TEMP/wine" wineboot -i >/dev/null 2>&1 || true ctest --test-dir build/win9x --output-on-failure - name: Imports (Windows 95, 98 and ME, and NT 4.0) run: | python3 "$CLANG_DOS/share/clang-dos/check-imports.py" build/win9x/windows/dmodem.exe python3 "$CLANG_DOS/share/clang-dos/check-imports.py" --nt 4.0 build/win9x/windows/dmodem.exe # (no iphlpapi.dll, which Windows 95 does not have, and no msvcrt.dll) if "$CLANG_DOS/bin/llvm-objdump" -p build/win9x/windows/dmodem.exe | grep -i "DLL Name: \(msvcrt\|iphlpapi\)"; then exit 1 fi "$CLANG_DOS/bin/llvm-nm" build/win9x/windows/dmodem.exe | grep -q dmodem_embed_start - uses: actions/upload-artifact@v4 with: name: dmodem-windows-9x path: build/win9x/windows/dmodem.exe # The app with the modem built in (external/D-Modem), on msvcrt: # Windows 98 SE, ME, 2000 and later. (The Windows 95 build above has # the modem too, on picolibc and libc++.) windows-98: name: Windows 98 SE and later, the modem built in (clang-retro, win98) runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 with: submodules: true - uses: clang-retro/dos-sdk/.github/actions/setup-toolchain@main id: clang-dos - name: Packages run: | sudo apt-get update sudo apt-get install -y --no-install-recommends ninja-build - name: Build run: | cmake -S . -B build/win98 -G Ninja -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_TOOLCHAIN_FILE=cmake/clang-retro.cmake -DCLANG_RETRO_CONFIG=win98 cmake --build build/win98 - name: Imports (Windows 98 SE) run: python3 "$CLANG_DOS/share/clang-dos/check-imports.py" build/win98/windows/dmodem.exe - uses: actions/upload-artifact@v4 with: name: dmodem-windows-98 path: build/win98/windows/dmodem.exe windows: name: Windows 7 and later (clang-retro) runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 with: submodules: true - uses: clang-retro/dos-sdk/.github/actions/setup-toolchain@main id: clang-dos - name: Packages run: | sudo dpkg --add-architecture i386 sudo apt-get update sudo apt-get install -y --no-install-recommends ninja-build wine wine32:i386 - name: Build run: | cmake -S . -B build/win7 -G Ninja -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_TOOLCHAIN_FILE=cmake/clang-retro.cmake -DCLANG_RETRO_CONFIG=win7 \ -DCMAKE_CROSSCOMPILING_EMULATOR=wine cmake --build build/win7 - name: Test (Wine) run: | export WINEDEBUG=-all WINEPREFIX="$RUNNER_TEMP/wine" wineboot -i >/dev/null 2>&1 || true ctest --test-dir build/win7 --output-on-failure - uses: actions/upload-artifact@v4 with: name: dmodem-windows path: build/win7/windows/dmodem.exe # The Windows app for Linux and macOS (winport/), over the portable # Win32 layer of clang-retro MFC, with the modem built in # (external/D-Modem) winport-linux: name: Windows app on Linux, the modem built in (clang-retro MFC's Win32 layer) runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 with: submodules: true - uses: actions/checkout@v4 with: repository: clang-retro/mfc path: mfc submodules: recursive - name: Packages run: | sudo apt-get update sudo apt-get install -y --no-install-recommends \ cmake ninja-build clang llvm libx11-dev xvfb xauth \ libusb-1.0-0-dev libasound2-dev - name: Build run: | cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DDMODEM_GUI_WINPORT=ON -DCLANG_RETRO_MFC="$PWD/mfc" \ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ cmake --build build --target dmodem-win32 - name: The built-in modem is in the app run: nm build/winport/dmodem-win32 | grep -q dmodem_embed_start - name: Smoke test (Xvfb) run: xvfb-run -a winport/test/smoke.sh build/winport/dmodem-win32 - name: Package run: tar -C build/winport -czf dmodem-win32-linux-x86_64.tar.gz dmodem-win32 - uses: actions/upload-artifact@v4 with: name: dmodem-win32-linux path: dmodem-win32-linux-x86_64.tar.gz # arm64 for a Mac with Apple silicon, and x86_64 for an Intel Mac. The # runner has Apple silicon: it builds the x86_64 app with # CMAKE_OSX_ARCHITECTURES=x86_64 (winport/CMakeLists.txt). winport-macos: name: Windows app on macOS (${{ matrix.arch }}), the modem built in (clang-retro MFC's Win32 layer) runs-on: macos-15 strategy: fail-fast: false matrix: include: - arch: arm64 artifact: dmodem-win32-macos - arch: x86_64 artifact: dmodem-win32-macos-x86_64 steps: - uses: actions/checkout@v4 with: submodules: true - uses: actions/checkout@v4 with: repository: clang-retro/mfc path: mfc submodules: recursive - name: Packages run: brew install llvm - name: Build run: | cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DDMODEM_GUI_WINPORT=ON -DCLANG_RETRO_MFC="$PWD/mfc" \ -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} \ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ cmake --build build --target dmodem-win32 -j"$(sysctl -n hw.ncpu)" - name: The app is for ${{ matrix.arch }} only run: | lipo -archs build/winport/dmodem-win32 test "$(lipo -archs build/winport/dmodem-win32)" = "${{ matrix.arch }}" - name: The built-in modem is in the app run: nm build/winport/dmodem-win32 | grep -q dmodem_embed_start - name: Library tests run: | cmake --build build --target dmodemctl_test xfer_test -j"$(sysctl -n hw.ncpu)" ctest --test-dir build --output-on-failure -R '^(dmodemctl|xfer)$' - name: Package run: tar -C build/winport -czf dmodem-win32-macos-${{ matrix.arch }}.tar.gz dmodem-win32 - uses: actions/upload-artifact@v4 with: name: ${{ matrix.artifact }} path: dmodem-win32-macos-${{ matrix.arch }}.tar.gz # The app for Haiku (x86_64), cross-built on Linux with the runner's # clang against a sysroot of Haiku's own packages (D-Modem's # platforms/haiku/haiku_sysroot.py, which checks them against the # repositories' SHA-256). Nothing here runs the app: that needs a # Haiku guest. Refer to docs/haiku.md. winport-haiku: name: Windows app on Haiku, the modem built in (clang-retro MFC's Win32 layer) runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 with: submodules: true - uses: actions/checkout@v4 with: repository: clang-retro/mfc path: mfc submodules: recursive - name: Packages run: | sudo apt-get update sudo apt-get install -y --no-install-recommends \ cmake ninja-build clang lld llvm libzstd1 python3 - name: Haiku packages cache uses: actions/cache@v4 with: path: haiku-packages key: haiku-packages-${{ hashFiles('external/D-Modem/platforms/haiku/haiku_sysroot.py') }} - name: Sysroot run: python3 external/D-Modem/platforms/haiku/haiku_sysroot.py haiku-sysroot --cache haiku-packages - name: Build run: | cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_TOOLCHAIN_FILE="$PWD/cmake/haiku.cmake" \ -DHAIKU_SYSROOT="$PWD/haiku-sysroot" \ -DDMODEM_GUI_WINPORT=ON -DCLANG_RETRO_MFC="$PWD/mfc" cmake --build build --target dmodem-win32 - name: The built-in modem is in the app run: llvm-nm build/winport/dmodem-win32 | grep -q dmodem_embed_start - name: Package run: tar -C build/winport -czf dmodem-win32-haiku-x86_64.tar.gz dmodem-win32 - uses: actions/upload-artifact@v4 with: name: dmodem-win32-haiku path: dmodem-win32-haiku-x86_64.tar.gz # The app for Mac OS X 10.4 (Tiger) and later, PowerPC and Intel # (i386), as one fat program, over the Mac OS X 10.0-10.5 port of # clang-retro MFC (cmake/macosx-legacy.cmake). All of it builds on # Linux: clang of clang-retro/llvm (its llvm-prebuilt release, which # has emulated TLS for 10.4), the macosx10.4 sysroot of dos-sdk (libc++ # and Apple's MacOSX10.4u.sdk, under Apple's license), and Apple's ld64 # and ar for PowerPC (dos-sdk's scripts/build-cctools-ppc.sh, kept in # the cache). winport-macosx-legacy: name: Windows app on Mac OS X 10.4 and later (PowerPC and i386), the modem built in runs-on: ubuntu-24.04 env: GH_TOKEN: ${{ github.token }} steps: - uses: actions/checkout@v4 with: submodules: true - uses: actions/checkout@v4 with: repository: clang-retro/mfc path: mfc submodules: recursive - uses: actions/checkout@v4 with: repository: clang-retro/dos-sdk path: dos-sdk - name: Packages run: | sudo apt-get update sudo apt-get install -y --no-install-recommends \ cmake ninja-build clang automake autoconf libtool uuid-dev libssl-dev zstd - name: clang (clang-retro/llvm, llvm-prebuilt) run: | asset=$(gh api repos/clang-retro/llvm/releases/tags/llvm-prebuilt --jq \ '[.assets[] | select(.name | startswith("llvm-linux-"))] | sort_by(.created_at) | last | .name') echo "Using $asset" gh release download llvm-prebuilt -R clang-retro/llvm -p "$asset" -O llvm.tar.zst mkdir -p "$RUNNER_TEMP/llvm" tar --zstd -xf llvm.tar.zst -C "$RUNNER_TEMP/llvm" rm llvm.tar.zst "$RUNNER_TEMP/llvm/bin/clang" --version | head -1 echo "MACOSX_LEGACY_LLVM=$RUNNER_TEMP/llvm" >> "$GITHUB_ENV" - name: The macosx10.4 sysroot (libc++ and MacOSX10.4u.sdk) run: | sh dos-sdk/packaging/get-toolchain.sh -s macosx10.4 "$RUNNER_TEMP/sysroots" echo "MACOSX_LEGACY_SYSROOT=$RUNNER_TEMP/sysroots/macosx10.4" >> "$GITHUB_ENV" - uses: actions/cache@v4 id: cctools with: path: ${{ runner.temp }}/cctools-ppc key: cctools-ppc-${{ hashFiles('dos-sdk/scripts/build-cctools-ppc.sh', 'dos-sdk/scripts/cctools-ppc-old-objects.patch') }} - name: cctools (ld64 and ar for PowerPC) if: steps.cctools.outputs.cache-hit != 'true' run: | PREFIX="$RUNNER_TEMP/cctools-ppc" SRC="$RUNNER_TEMP/cctools-port" \ sh dos-sdk/scripts/build-cctools-ppc.sh > cctools.log 2>&1 || { tail -50 cctools.log; exit 1; } - name: Build (PowerPC and i386) run: | export MACOSX_LEGACY_CCTOOLS="$RUNNER_TEMP/cctools-ppc" for arch in powerpc i386; do cmake -S . -B build/$arch -G Ninja -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_TOOLCHAIN_FILE="$PWD/cmake/macosx-legacy.cmake" \ -DMACOSX_LEGACY_ARCH=$arch -DCLANG_RETRO_MFC="$PWD/mfc" \ -DDMODEM_GUI_WINPORT=ON cmake --build build/$arch --target dmodem-win32 done - name: The fat program, with the built-in modem for each processor run: | cct="$RUNNER_TEMP/cctools-ppc/bin/powerpc-apple-darwin8-" mkdir -p out "${cct}lipo" -create build/powerpc/winport/dmodem-win32 build/i386/winport/dmodem-win32 \ -output out/dmodem-win32 "${cct}lipo" -info out/dmodem-win32 for arch in ppc i386; do "${cct}lipo" out/dmodem-win32 -verify_arch $arch "${cct}nm" -arch $arch out/dmodem-win32 | grep -q dmodem_embed_start done # (each part is for Mac OS X 10.4) "${cct}otool" -arch all -l out/dmodem-win32 | grep -A2 LC_VERSION_MIN_MACOSX | grep -c "version 10.4" | grep -qx 2 - name: Package run: tar -C out -czf dmodem-win32-macosx10.4.tar.gz dmodem-win32 - uses: actions/upload-artifact@v4 with: name: dmodem-win32-macosx-legacy path: dmodem-win32-macosx10.4.tar.gz