Skip to content

Commit

Permalink
GH Actions: Try to grant BGMApp mic authorization by modifying TCC.db.
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleneideck committed May 19, 2022
1 parent 30ec1c2 commit 3040a20
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
27 changes: 20 additions & 7 deletions .github/workflows/build-test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,32 @@ jobs:
-workspace BGM.xcworkspace \
-scheme 'Background Music Device' \
test
echo '::endgroup::'
echo '::group::BGMXPCHelper Tests'
xcodebuild \
-quiet \
-workspace BGM.xcworkspace \
-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 \
Expand All @@ -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.
Expand Down
10 changes: 6 additions & 4 deletions BGMApp/BGMAppTests/UITests/BGMAppUITests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,16 @@ - (void) setUp {

// 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
Expand Down

0 comments on commit 3040a20

Please sign in to comment.