Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add macos CI build and test #33

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/mac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: macos

on: [pull_request]

jobs:
build:
runs-on: macos-13
steps:
- uses: actions/checkout@v4
- run: |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind documenting these steps with names?

cd src/macos/ATDriverGenericMacOS
xcodebuild
- run: |
pluginkit -e use -i com.bocoup.ATDriverGenericMacOS.ATDriverGenericMacOSExtension
defaults write com.apple.Accessibility SpeechVoiceIdentifierForLanguage '{2 = {en = "com.bocoup.ATDriverGenericMacOS.ATDriverGenericMacOSExtension.ATDriverGenericMacOSExtension";};}'
say hello
say hello
say hello
say hello
say hello
log show --process ATDriverGenericService | tail -n 10
Comment on lines +16 to +21
Copy link
Contributor

@jugglinmike jugglinmike Jan 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect to see five occurrences of the string "hello" in the service logs, but the latest build only reported an error, "no such file or directory".

If the log really is supposed to prove that the speech was captured, then we can make the results easier to interpret with without much more effort by choosing different strings: using five distinct strings will make sequence errors apparent and make it easier to detect when messages are dropped/duplicated. For instance

say hello one of five
say hello two of five
say hello three of five
say hello four of five
say hello five of five

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This combination of say hello and log show here is to try and get any output to indicate the extension and service working.

I first tried it with one say hello. log didn't show anything.

I think the system picking up the configuration change isn't instant. It may be polling based or something?

Either way I think a next step is to use cli to listen for speech from the application extension, and repeat say hello until output shows up. I suspect there isn't a fixed number of say hello we would need to see it show up. In a way I got lucky that 5 worked, but maybe it sometimes need 10, and sometimes 1 may be enough.

45 changes: 33 additions & 12 deletions lib/cli.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
'use strict';
"use strict";

const yargs = require('yargs/yargs');
const { hideBin } = require('yargs/helpers');
const fs = require("fs/promises");

const createCommandServer = require('./create-command-server');
const createVoiceServer = require('./create-voice-server');
const NAMED_PIPE = '\\\\?\\pipe\\my_pipe';
const yargs = require("yargs/yargs");
const { hideBin } = require("yargs/helpers");

const createCommandServer = require("./create-command-server");
const createVoiceServer = require("./create-voice-server");
const WINDOWS_NAMED_PIPE = "\\\\?\\pipe\\my_pipe";
const MACOS_SYSTEM_DIR = "/usr/local/var/at_driver_generic";
const MACOS_SOCKET_UNIX_PATH = "/usr/local/var/at_driver_generic/driver.socket";
const DEFAULT_PORT = 4382;

/**
Expand All @@ -16,7 +20,7 @@ const log = (...args) => console.error(new Date().toISOString(), ...args);

module.exports = async (process) => {
const argv = yargs(hideBin(process.argv))
.option('port', {
.option("port", {
coerce(string) {
if (!/^(0|[1-9][0-9]*)$/.test(string)) {
throw new TypeError(
Expand All @@ -26,29 +30,46 @@ module.exports = async (process) => {
return Number(string);
},
default: DEFAULT_PORT,
describe: 'TCP port on which to listen for WebSocket connections',
describe: "TCP port on which to listen for WebSocket connections",
// Do not use the `number` type provided by `yargs` because it tolerates
// JavaScript numeric literal forms which are likely typos in this
// context (e.g. `0xf` or `1e-0`).
type: 'string',
type: "string",
requiresArg: true,
})
.parse();

const socketPath = await prepareSocketPath();

const [commandServer, voiceServer] = await Promise.all([
createCommandServer(argv.port),
createVoiceServer(NAMED_PIPE),
createVoiceServer(socketPath),
]);

log(`listening on port ${argv.port}`);

commandServer.on('error', (error) => {
commandServer.on("error", (error) => {
log(`error: ${error}`);
});

voiceServer.on('message', (message) => {
voiceServer.on("message", (message) => {
log(`sending message ${JSON.stringify(message)}`);

commandServer.broadcast(message);
});

voiceServer.on("error", (error) => {
log(`error: ${error}`);
});
};

const prepareSocketPath = async () => {
if (process.platform === "win32") {
return WINDOWS_NAMED_PIPE;
} else if (process.platform === "darwin") {
await fs.mkdir(MACOS_SYSTEM_DIR, { recursive: true });
await fs.unlink(MACOS_SOCKET_UNIX_PATH).catch(() => {});
return MACOS_SOCKET_UNIX_PATH;
}
throw new Error(`unknown host platform '${process.platform}'`);
};
1,113 changes: 1,113 additions & 0 deletions src/macos/ATDriverGenericMacOS/ATDriverGenericMacOS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
wasCreatedForAppExtension = "YES"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AD64B3A12B2B995C00AC0234"
BuildableName = "ATDriverGenericMacOSExtension.appex"
BlueprintName = "ATDriverGenericMacOSExtension"
ReferencedContainer = "container:ATDriverGenericMacOS.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AD64B3642B2B995B00AC0234"
BuildableName = "ATDriverGenericMacOS.app"
BlueprintName = "ATDriverGenericMacOS"
ReferencedContainer = "container:ATDriverGenericMacOS.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AD64B3952B2B995C00AC0234"
BuildableName = "ATDriverGenericMacOSUITests.xctest"
BlueprintName = "ATDriverGenericMacOSUITests"
ReferencedContainer = "container:ATDriverGenericMacOS.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AD64B38B2B2B995C00AC0234"
BuildableName = "ATDriverGenericMacOSTests.xctest"
BlueprintName = "ATDriverGenericMacOSTests"
ReferencedContainer = "container:ATDriverGenericMacOS.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AD64B3642B2B995B00AC0234"
BuildableName = "ATDriverGenericMacOS.app"
BlueprintName = "ATDriverGenericMacOS"
ReferencedContainer = "container:ATDriverGenericMacOS.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
askForAppToLaunch = "Yes"
launchAutomaticallySubstyle = "2">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AD64B3642B2B995B00AC0234"
BuildableName = "ATDriverGenericMacOS.app"
BlueprintName = "ATDriverGenericMacOS"
ReferencedContainer = "container:ATDriverGenericMacOS.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>ATDriverGenericMacOSExtension.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>AD64B3642B2B995B00AC0234</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>AD64B3A12B2B995C00AC0234</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// ATDriverGenericMacOSApp.swift
// ATDriverGenericMacOS
//
// Created by Z Goddard on 12/14/23.
//

import CoreMIDI
import SwiftUI

@main
class ATDriverGenericMacOSApp: App {
@ObservedObject private var hostModel = AudioUnitHostModel()

required init() {}

var body: some Scene {
WindowGroup {
ContentView(hostModel: hostModel)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"images" : [
{
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading