Skip to content

Merge pull request #721 from mrbaloghakos/master #36

Merge pull request #721 from mrbaloghakos/master

Merge pull request #721 from mrbaloghakos/master #36

# TODO: Split this into multiple .yml files? Multiple jobs?
name: Build, Test and Release
on:
push:
branches:
- '*'
tags:
- '*'
pull_request:
branches:
- '*'
jobs:
# Build and test in the same job because the UI tests expect BGMDriver to be installed.
build-and-test:
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
matrix:
# TODO: Add older macOS versions.
os:
- macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Work in a case-sensitive disk image.
# This lets us catch failures that only happen on case-sensitive filesystems.
run: |
hdiutil create \
-type SPARSEBUNDLE \
-fs 'Case-sensitive Journaled HFS+' \
-volname bgmbuild \
-nospotlight \
-verbose \
-attach \
-size 100m \
bgmbuild.dmg
sudo cp -r . /Volumes/bgmbuild
cd /Volumes/bgmbuild
- name: Install coreutils for actions/runner/issues/884 workaround.
# See https://github.com/actions/runner/issues/884#issuecomment-1018851327
run: brew install coreutils
- name: Build and install Background Music.
run: |
# `sudo` and `tput` expect this to be set.
export TERM=xterm-256color
genv --default-signal=PIPE yes | sudo ./build_and_install.sh
- name: Print the log file.
if: always()
run: cat build_and_install.log
- name: Log some checksums.
run: 'find */build/Release/*/ -type f -exec md5 {} \;'
- name: Log the installed audio devices and their IDs.
run: |
system_profiler SPAudioDataType
say -a '?'
- name: Check the BGM dirs and files were installed.
run: |
# These commands fail if the dir/file isn't found.
ls -la "/Applications/Background Music.app"
ls -la "/Library/Audio/Plug-Ins/HAL/Background Music Device.driver"
ls -la "/usr/local/libexec/BGMXPCHelper.xpc" \
|| ls -la "/Library/Application Support/Background Music/BGMXPCHelper.xpc"
ls -la "/Library/LaunchDaemons/com.bearisdriving.BGM.XPCHelper.plist"
- name: Close BGMApp (which the install script opened).
run: >-
osascript -e 'tell application "Background Music" to quit'
|| killall "Background Music"
- name: Skip the UI tests. (They don't work on GitHub Actions yet.)
run: BGMApp/BGMAppTests/UITests/skip-ui-tests.py
- name: Run the tests.
run: |
echo '::group::BGMDriver Tests'
xcodebuild \
-quiet \
-workspace BGM.xcworkspace \
-scheme 'Background Music Device' \
test
echo '::endgroup::'
echo '::group::BGMXPCHelper Tests'
xcodebuild \
-quiet \
-workspace BGM.xcworkspace \
-scheme 'BGMXPCHelper' \
test
echo '::endgroup::'
# Grant BGMApp authorization to use input devices.
# This is necessary for the UI tests because accepting the "Background Music would like to
# use the microphone" dialog programmatically isn't reliable.
# TODO: Commented out because we would need to generate the csreq (codesign signature)
# value to match the BGMApp bundle the tests will run against.
# dbPath="$HOME/Library/Application Support/com.apple.TCC/TCC.db"
# values="'kTCCServiceMicrophone','com.bearisdriving.BGM.App',0,2,2,1,X'FADE0C000000004800000001000000070000000800000014545ABE68FAF437700B14984BB24117EDDA1BBF2C0000000800000014386FB63B9CD6BA6E83CEDEAF4EDEE177C1FAEA92',NULL,NULL,'UNUSED',NULL,0,1652845317"
# sqlQuery="INSERT OR IGNORE INTO access VALUES($values);"
# sqlite3 "$dbPath" "$sqlQuery" || (echo "Failed to modify $dbPath"; exit 1)
# # Log the added TCC.db entry.
# sqlite3 "$dbPath" "select * from access where client like '%BGM%';"
echo '::group::BGMApp Tests'
# TODO: Commented out in case it uses too much CPU.
# log stream --info \
# --predicate 'process == "coreaudiod" or
# process == "Background Music" or
# process == "BGMXPCHelper" or
# composedMessage contains[cd] "Background Music" or
# composedMessage contains "BGM"' > app.log &
xcodebuild \
-quiet \
-workspace BGM.xcworkspace \
-scheme 'Background Music' \
test
echo '::endgroup::'
- name: Upload the test results.
if: always()
uses: actions/upload-artifact@v3
with:
name: bgm-test-results
path: |
/Users/runner/Library/Developer/Xcode/DerivedData/*/Logs/Test/*.xcresult
app.log
/Users/runner/Library/Logs/CrashReporter/*
/Users/runner/Library/Logs/DiagnosticReports/*
- name: Uninstall Background Music.
run: |
# `tput` expects this to be set.
export TERM=xterm-256color
genv --default-signal=PIPE yes | sudo ./uninstall.sh
- name: Check the BGM dirs and files were removed.
run: |
if ls -la "/Applications/Background Music.app"; then exit 1; fi
if ls -la "/Library/Audio/Plug-Ins/HAL/Background Music Device.driver"; then exit 1; fi
if ls -la "/usr/local/libexec/BGMXPCHelper.xpc"; then exit 1; fi
if ls -la "/Library/Application Support/Background Music/BGMXPCHelper.xpc"; then
exit 1
fi
if ls -la "/Library/LaunchDaemons/com.bearisdriving.BGM.XPCHelper.plist"; then exit 1; fi
release:
runs-on: macos-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build the .pkg installer.
run: |
# `sudo` and `tput` expect this to be set.
export TERM=xterm-256color
# If this build is for a tag with "DEBUG" in its name, build a debug package. (More
# detailed logging, no optimization, etc.)
if [[ "$GITHUB_REF" =~ .*DEBUG.* ]]; then
sudo ./package.sh -d
else
sudo ./package.sh
fi
- name: Install the .pkg.
# Delete archives/ first because it contains a copy of Background Music.app.
# Background Music.app is "relocatable", which means that if the user moves it and then
# installs a new version, macOS will put the new version in the same place. This makes sure
# the installer puts Background Music.app in /Applications so the build won't fail when we
# check that later.
#
# package.sh puts the archives in a zipfile next to the .pkg, so we can still upload them
# after deleting the directory here.
#
# TODO: On TravisCI, this was failing for debug builds. We couldn't figure out why, so we
# might have to ignore that with
# || [[ "$GITHUB_REF" =~ .*DEBUG.* ]]
run: |
sudo rm -rf archives
sudo installer \
-pkg Background-Music-*/BackgroundMusic-*.pkg \
-target / \
-verbose \
-dumplog
- name: Print the installer logs.
if: always()
# This trims the start of the log to save space.
run: grep -E -A 9999 -B 20 'Background.?Music' /var/log/install.log
- name: Check the BGM dirs and files were installed.
if: always()
run: |
ls -la "/Applications/Background Music.app"
ls -la "/Library/Audio/Plug-Ins/HAL/Background Music Device.driver"
ls -la "/usr/local/libexec/BGMXPCHelper.xpc" \
|| ls -la "/Library/Application Support/Background Music/BGMXPCHelper.xpc"
ls -la "/Library/LaunchDaemons/com.bearisdriving.BGM.XPCHelper.plist"
- name: Upload the .pkg installer and archives.
if: always()
uses: actions/upload-artifact@v3
with:
name: pkg-installer
path: Background-Music-*
- name: Upload the log file from the package.sh build.
if: always()
uses: actions/upload-artifact@v3
with:
name: build-and-install-log-for-pkg
path: build_and_install.log
# TODO: Create a GitHub release. This is the Travis YAML that was handling it:
# deploy:
# provider: releases
# api_key:
# secure: j5Gd[...]
# file_glob: true
# file: Background-Music-*/*
# skip_cleanup: true
# name: $TRAVIS_TAG
# prerelease: true
# draft: true
# on:
# repo: kyleneideck/BackgroundMusic
# tags: true
# # TODO: Use "condition" to build master and tags?
# condition: $DEPLOY = true