GH Actions: Try to grant BGMApp mic authorization by modifying TCC.db.

This commit is contained in:
Kyle Neideck 2022-05-19 17:24:33 +10:00
parent 30ec1c24b7
commit 3040a20766
No known key found for this signature in database
GPG key ID: CAA8D9B8E39EC18C
2 changed files with 26 additions and 11 deletions

View file

@ -75,6 +75,8 @@ jobs:
-workspace BGM.xcworkspace \
-scheme 'Background Music Device' \
test
echo '::endgroup::'
echo '::group::BGMXPCHelper Tests'
xcodebuild \
-quiet \
@ -82,14 +84,23 @@ jobs:
-scheme 'BGMXPCHelper' \
test
echo '::endgroup::'
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.
dbPath="$HOME/Library/Application Support/com.apple.TCC/TCC.db"
values="'kTCCServiceMicrophone','com.bearisdriving.BGM.App',0,2,2,1,NULL,NULL,NULL,'UNUSED',NULL,0,1652845317"
sqlQuery="INSERT OR IGNORE INTO access VALUES($values);"
sudo sqlite3 "$dbPath" "$sqlQuery"
echo '::group::BGMApp Tests'
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 &
# 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 \
@ -104,6 +115,8 @@ jobs:
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.

View file

@ -76,14 +76,16 @@
// Make the "Background Music wants to use the microphone" dialog appear every time so the test
// doesn't need logic to handle both cases.
if (@available(macOS 10.15.4, *)) {
[app resetAuthorizationStatusForResource:XCUIProtectedResourceMicrophone];
}
// TODO: Commented out to check if CI builds can grant access by modifying TCC.db.
// if (@available(macOS 10.15.4, *)) {
// [app resetAuthorizationStatusForResource:XCUIProtectedResourceMicrophone];
// }
// Launch BGMApp.
[app launch];
[self acceptMicrophoneAuthorizationDialog];
// TODO: Commented out to check if CI builds can grant access by modifying TCC.db.
// [self acceptMicrophoneAuthorizationDialog];
if (![icon waitForExistenceWithTimeout:20.0]) {
// The status bar icon/button has this type when using older versions of XCTest, so try