379 lines
13 KiB
YAML
379 lines
13 KiB
YAML
name: Build FreeDV (macOS)
|
|
|
|
on:
|
|
push:
|
|
branches-ignore:
|
|
- 'dr-render-manual'
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
|
BUILD_TYPE: RelWithDebInfo
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: macos-15
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: ccache
|
|
uses: hendrikmuhs/ccache-action@v1.2.23
|
|
with:
|
|
key: ${{ github.job }}
|
|
max-size: "5G"
|
|
|
|
- name: Install needed packages
|
|
run: |
|
|
brew install automake libtool numpy sox wxwidgets speexdsp portaudio libsndfile hamlib libebur128
|
|
|
|
- name: Install LLVM and Clang
|
|
uses: KyleMayes/install-llvm-action@v2
|
|
with:
|
|
version: "20.1"
|
|
|
|
- name: Build macdylibbundler
|
|
run: |
|
|
git clone https://github.com/tmiw/macdylibbundler.git
|
|
cd macdylibbundler && git checkout main && git pull
|
|
make -j$(sysctl -n hw.logicalcpu)
|
|
cd ..
|
|
|
|
- name: Build freedv-gui
|
|
shell: bash
|
|
working-directory: ${{github.workspace}}
|
|
run: |
|
|
mkdir build_osx
|
|
cd build_osx
|
|
CC=clang CXX=clang++ cmake -DCMAKE_OBJCXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ..
|
|
# Build so we have all required .h and .c/.cpp files
|
|
make -j$(sysctl -n hw.logicalcpu)
|
|
|
|
- name: Run clang-tidy on codebase
|
|
working-directory: ${{github.workspace}}/build_osx
|
|
run: |
|
|
run-clang-tidy -p .
|
|
|
|
test:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-15] # ARM64
|
|
sanitizer: [WITH_ASAN=0, WITH_ASAN=1, WITH_TSAN=1, WITH_UBSAN=1]
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
needs: ['lint']
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: ccache
|
|
uses: hendrikmuhs/ccache-action@v1.2.23
|
|
with:
|
|
key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.sanitizer }}
|
|
create-symlink: true
|
|
max-size: "5G"
|
|
|
|
#- name: Setup tmate session
|
|
# uses: mxschmitt/action-tmate@v3
|
|
# with:
|
|
# detached: true
|
|
|
|
- name: Install needed packages
|
|
run: |
|
|
brew install automake libtool numpy sox wxwidgets speexdsp portaudio libsndfile hamlib libebur128
|
|
|
|
- name: Install VB-Cable
|
|
shell: bash
|
|
working-directory: ${{github.workspace}}
|
|
run: |
|
|
brew install vb-cable
|
|
|
|
- name: Install other virtual audio devices
|
|
shell: bash
|
|
working-directory: ${{github.workspace}}
|
|
run: ./build_macos_sound_drivers.sh
|
|
|
|
- name: Build freedv-gui
|
|
shell: bash
|
|
working-directory: ${{github.workspace}}
|
|
run: BUILD_TYPE=RelWithDebInfo UT_ENABLE=1 UNIV_BUILD=0 BUILD_DEPS=0 ${{matrix.sanitizer}} ./build_osx.sh
|
|
|
|
- name: Workaround macOS permission issues
|
|
timeout-minutes: 1
|
|
run: |
|
|
${{github.workspace}}/ci/macos-set-mic-permissions.sh
|
|
|
|
- name: Make sure resource hogs aren't running
|
|
shell: bash
|
|
run: |
|
|
${{github.workspace}}/ci/macos-kill-resource-hogs.sh
|
|
|
|
- name: Execute unit tests
|
|
shell: bash
|
|
working-directory: ${{github.workspace}}/build_osx
|
|
run: |
|
|
python3 -m venv rade_venv
|
|
. ./rade_venv/bin/activate
|
|
pip3 install torch matplotlib
|
|
if [[ "${{ matrix.sanitizer }}" == "WITH_ASAN=0" ]]; then
|
|
export MAX_EXECUTION_TIMES=2
|
|
else
|
|
export MAX_EXECUTION_TIMES=1
|
|
fi
|
|
PYTHONPATH=$(pwd)/rade_src UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1:suppressions=${{github.workspace}}/test/ubsan_suppressions.txt ASAN_OPTIONS=suppressions=${{github.workspace}}/test/asan_suppressions.txt LSAN_OPTIONS=suppressions=${{github.workspace}}/test/lsan_suppressions.txt TSAN_OPTIONS=halt_on_error=1:ignore_noninstrumented_modules=1 FREEDV_COMPUTER_TO_RADIO_DEVICE="VB-Cable" FREEDV_RADIO_TO_COMPUTER_DEVICE="VB-Cable" FREEDV_COMPUTER_TO_SPEAKER_DEVICE="BlackHole1 2ch" FREEDV_MICROPHONE_TO_COMPUTER_DEVICE="BlackHole2 2ch" ctest -V --repeat until-pass:$MAX_EXECUTION_TIMES
|
|
|
|
#- name: Zip up traces
|
|
# shell: bash
|
|
# working-directory: ${{github.workspace}}/build_osx
|
|
# if: ${{ !cancelled() }}
|
|
# run: |
|
|
# zip -r InstrumentsTraces.zip instruments_trace_*
|
|
|
|
#- name: Stash instrumented results
|
|
# uses: actions/upload-artifact@v7
|
|
# if: ${{ !cancelled() }}
|
|
# with:
|
|
# name: InstrumentsTraces-${{matrix.os}}
|
|
# path: ${{github.workspace}}/build_osx/InstrumentsTraces.zip
|
|
|
|
# Only build and publish universal binary after making sure code works properly on both
|
|
# x86 and ARM. No point in doing so if there's a failure on either.
|
|
dist-pgo-instrument:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-26-intel, macos-26] # ARM64, x86_64
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
#- name: Setup tmate session
|
|
# uses: mxschmitt/action-tmate@v3
|
|
# with:
|
|
# detached: true
|
|
|
|
# There's a bug where macos-26 ends up downloading macos-26-intel's cache and thus
|
|
# having few/no cache hits. To prevent this, we make sure that the cache key is unique
|
|
# enough on both platforms to avoid inadvertent matches.
|
|
- name: ccache
|
|
uses: hendrikmuhs/ccache-action@v1.2.23
|
|
if: ${{ matrix.os == 'macos-26-intel' }}
|
|
with:
|
|
key: ${{ github.job }}-x86_64
|
|
max-size: "5G"
|
|
create-symlink: true
|
|
|
|
- name: ccache
|
|
uses: hendrikmuhs/ccache-action@v1.2.23
|
|
if: ${{ matrix.os == 'macos-26' }}
|
|
with:
|
|
key: ${{ github.job }}-aarch64
|
|
max-size: "5G"
|
|
create-symlink: true
|
|
|
|
- name: Install needed packages
|
|
run: |
|
|
brew install automake libtool numpy sox llvm@20 lld@20 # note: LLVM 21 introduces incompatibilities - see https://github.com/Homebrew/homebrew-core/issues/235411
|
|
|
|
- name: Install VB-Cable
|
|
shell: bash
|
|
working-directory: ${{github.workspace}}
|
|
run: |
|
|
brew install vb-cable
|
|
|
|
- name: Install other virtual audio devices
|
|
shell: bash
|
|
working-directory: ${{github.workspace}}
|
|
run: ./build_macos_sound_drivers.sh
|
|
|
|
- name: Workaround macOS permission issues
|
|
timeout-minutes: 1
|
|
run: |
|
|
${{github.workspace}}/ci/macos-set-mic-permissions.sh
|
|
|
|
- name: Make sure resource hogs aren't running
|
|
shell: bash
|
|
run: |
|
|
${{github.workspace}}/ci/macos-kill-resource-hogs.sh
|
|
|
|
- name: Build instrumented freedv-gui
|
|
shell: bash
|
|
working-directory: ${{github.workspace}}
|
|
run: |
|
|
BUILD_TYPE=Release UT_ENABLE=0 UNIV_BUILD=0 BUILD_DEPS=1 PGO_INSTRUMENT=1 ENABLE_LTO=1 USE_CCACHE=1 ./build_osx.sh
|
|
|
|
- name: Generate optimization profile
|
|
shell: bash
|
|
working-directory: ${{github.workspace}}
|
|
run: |
|
|
cd build_osx
|
|
LLVM_PROFILE_FILE="code-%p.profraw" FREEDV_COMPUTER_TO_RADIO_DEVICE="VB-Cable" FREEDV_RADIO_TO_COMPUTER_DEVICE="VB-Cable" FREEDV_COMPUTER_TO_SPEAKER_DEVICE="BlackHole1 2ch" FREEDV_MICROPHONE_TO_COMPUTER_DEVICE="BlackHole2 2ch" ../test/generate_pgo_profiles.sh 2>&1
|
|
|
|
- name: Stash profile data
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: profdata-${{ matrix.os }}
|
|
path: ${{github.workspace}}/build_osx/*.profraw
|
|
|
|
dist-pgo-build:
|
|
runs-on: macos-latest
|
|
env:
|
|
MACOS_NOTARYTOOL_PROFILE_NAME: "FreeDVCodeSigning"
|
|
needs: ['dist-pgo-instrument']
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
#- name: Setup tmate session
|
|
# uses: mxschmitt/action-tmate@v3
|
|
# with:
|
|
# detached: true
|
|
|
|
- name: Install needed packages
|
|
run: |
|
|
brew install automake libtool numpy sox llvm@20 lld@20 # note: LLVM 21 introduces incompatibilities - see https://github.com/Homebrew/homebrew-core/issues/235411
|
|
|
|
- name: Initialize code signing infrastructure
|
|
if: ${{ vars.FREEDV_MACOS_CODE_SIGNING_TEAM_ID != '' }}
|
|
env:
|
|
MACOS_CODE_SIGNING_USERNAME: ${{ secrets.FREEDV_MACOS_CODE_SIGNING_USERNAME }}
|
|
MACOS_CODE_SIGNING_PASSWORD: ${{ secrets.FREEDV_MACOS_CODE_SIGNING_PASSWORD }}
|
|
MACOS_CODE_SIGNING_CERTIFICATE: ${{ secrets.FREEDV_MACOS_CODE_SIGNING_CERTIFICATE }}
|
|
run: |
|
|
security create-keychain -p actions macos-build.keychain
|
|
security default-keychain -s macos-build.keychain
|
|
security unlock-keychain -p actions macos-build.keychain
|
|
security set-keychain-settings -t 3600 -u macos-build.keychain
|
|
cat <<EOF >tmp.pem
|
|
${{ env.MACOS_CODE_SIGNING_CERTIFICATE }}
|
|
EOF
|
|
openssl pkcs12 -export -in tmp.pem -out tmp.p12 -passout pass:xxxxxxxx
|
|
security import tmp.p12 -k ~/Library/Keychains/macos-build.keychain -P xxxxxxxx -T /usr/bin/codesign -T /usr/bin/productsign -f pkcs12
|
|
security set-key-partition-list -S apple-tool:,apple: -s -k actions macos-build.keychain
|
|
security find-identity -v macos-build.keychain
|
|
xcrun notarytool store-credentials --apple-id "${{ env.MACOS_CODE_SIGNING_USERNAME }}" --password "${{ env.MACOS_CODE_SIGNING_PASSWORD }}" --team-id "${{ vars.FREEDV_MACOS_CODE_SIGNING_TEAM_ID }}" ${{ env.MACOS_NOTARYTOOL_PROFILE_NAME }}
|
|
|
|
- name: Download profile data
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
merge-multiple: false
|
|
pattern: profdata-*
|
|
path: ${{github.workspace}}
|
|
|
|
- name: Merge profile data
|
|
run: |
|
|
$(xcrun -find llvm-profdata) merge -output ${{ github.workspace }}/code.profdata ${{github.workspace}}/profdata-macos-26-intel/code-*.profraw ${{github.workspace}}/profdata-macos-26/code-*.profraw
|
|
|
|
- name: Build freedv-gui (unsigned)
|
|
if: ${{ vars.FREEDV_MACOS_CODE_SIGNING_TEAM_ID == '' }}
|
|
shell: bash
|
|
working-directory: ${{github.workspace}}
|
|
run: |
|
|
rm -rf build_osx
|
|
BUILD_TYPE=Release UT_ENABLE=0 UNIV_BUILD=1 BUILD_DEPS=1 ENABLE_LTO=1 PGO_USE_PROFILE=${{ github.workspace }}/code.profdata ./build_osx.sh
|
|
|
|
- name: Build freedv-gui (signed)
|
|
if: ${{ vars.FREEDV_MACOS_CODE_SIGNING_TEAM_ID != '' }}
|
|
shell: bash
|
|
working-directory: ${{github.workspace}}
|
|
run: |
|
|
rm -rf build_osx
|
|
BUILD_TYPE=Release UT_ENABLE=0 UNIV_BUILD=1 BUILD_DEPS=1 ENABLE_LTO=1 PGO_USE_PROFILE=${{ github.workspace }}/code.profdata CODESIGN_IDENTITY=${{ vars.FREEDV_MACOS_CODE_SIGNING_TEAM_ID }} CODESIGN_KEYCHAIN_PROFILE=${{ env.MACOS_NOTARYTOOL_PROFILE_NAME }} ./build_osx.sh
|
|
|
|
- name: Package executable
|
|
working-directory: ${{github.workspace}}/build_osx
|
|
run: |
|
|
make release
|
|
|
|
- name: Validate DMG signature
|
|
if: ${{ vars.FREEDV_MACOS_CODE_SIGNING_TEAM_ID != '' }}
|
|
run: |
|
|
codesign -v ${{github.workspace}}/build_osx/src/FreeDV.dmg --verbose
|
|
|
|
- name: Rename DMG file
|
|
id: dmg-filename
|
|
run: |
|
|
FREEDV_VERSION=`cat ${{github.workspace}}/build_osx/freedv-version.txt`
|
|
mv build_osx/src/FreeDV.dmg build_osx/src/FreeDV-${FREEDV_VERSION}.dmg
|
|
cd build_osx/src
|
|
echo "DMG_FILENAME=$(echo -n FreeDV*.dmg)" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Stash disk image
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: ${{ steps.dmg-filename.outputs.DMG_FILENAME }}
|
|
path: ${{github.workspace}}/build_osx/src/${{ steps.dmg-filename.outputs.DMG_FILENAME }}
|
|
archive: false
|
|
|
|
# Test .app file generated by dist
|
|
test-app-folder:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-14, macos-15, macos-26] # ARM64, ARM64, ARM64
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
needs: ['dist-pgo-build']
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- uses: actions/download-artifact@v8
|
|
with:
|
|
merge-multiple: true
|
|
pattern: FreeDV*.dmg
|
|
path: ${{github.workspace}}
|
|
|
|
- uses: actions/download-artifact@v8
|
|
with:
|
|
merge-multiple: true
|
|
pattern: FreeDV*.dmg
|
|
path: ${{github.workspace}}
|
|
|
|
- name: Open DMG file
|
|
shell: bash
|
|
working-directory: ${{github.workspace}}
|
|
run: |
|
|
mkdir FreeDV-dmg
|
|
hdiutil attach FreeDV*.dmg -mountpoint FreeDV-dmg
|
|
|
|
- name: Install needed packages
|
|
run: |
|
|
brew install automake libtool sox
|
|
|
|
- name: Install VB-Cable
|
|
shell: bash
|
|
working-directory: ${{github.workspace}}
|
|
run: |
|
|
brew install vb-cable
|
|
|
|
- name: Install other virtual audio devices
|
|
shell: bash
|
|
working-directory: ${{github.workspace}}
|
|
run: ./build_macos_sound_drivers.sh
|
|
|
|
- name: Workaround macOS permission issues
|
|
timeout-minutes: 1
|
|
run: |
|
|
${{github.workspace}}/ci/macos-set-mic-permissions.sh
|
|
|
|
- name: Make sure resource hogs aren't running
|
|
shell: bash
|
|
run: |
|
|
${{github.workspace}}/ci/macos-kill-resource-hogs.sh
|
|
|
|
- name: Sanity check RADE
|
|
shell: bash
|
|
run: |
|
|
python3 -m venv rade_venv
|
|
. ./rade_venv/bin/activate
|
|
pip3 install torch matplotlib
|
|
FREEDV_COMPUTER_TO_RADIO_DEVICE="VB-Cable" FREEDV_RADIO_TO_COMPUTER_DEVICE="VB-Cable" FREEDV_COMPUTER_TO_SPEAKER_DEVICE="BlackHole1 2ch" FREEDV_MICROPHONE_TO_COMPUTER_DEVICE="BlackHole2 2ch" FREEDV_BINARY=./FreeDV-dmg/FreeDV.app/Contents/MacOS/FreeDV PYTHONPATH=$(pwd)/build_osx/rade_src ./test/test_rade_loss.sh 2>&1 | tee temp-test.txt
|
|
grep "PASS" temp-test.txt
|