diff --git a/.github/workflows/mac-menubar-ci.yml b/.github/workflows/mac-menubar-ci.yml new file mode 100644 index 00000000..f7d9cc1c --- /dev/null +++ b/.github/workflows/mac-menubar-ci.yml @@ -0,0 +1,34 @@ +name: macOS Menubar CI + +# The macOS menubar (mac/) ships from release-menubar.yml, which only packages the app. +# Its Swift test suite (170+ tests covering the credential stores, Keychain cache, +# serve connection, quota parsing) gated nothing until this workflow. Runs on every +# PR touching mac/** so a red test fails the PR, the same way tests.yml does for the CLI. +on: + push: + branches: [main] + paths: + - .github/workflows/mac-menubar-ci.yml + - mac/** + pull_request: + paths: + - .github/workflows/mac-menubar-ci.yml + - mac/** + +permissions: + contents: read + +jobs: + test: + runs-on: macos-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v6 + - name: Swift toolchain + run: swift --version + - name: Build + run: swift build --package-path mac + - name: Test + run: swift test --package-path mac + - name: Package (same script the release uses) + run: mac/Scripts/package-app.sh ci-smoke diff --git a/mac/Tests/CodeBurnMenubarTests/DataClientProcessTests.swift b/mac/Tests/CodeBurnMenubarTests/DataClientProcessTests.swift index 93d4ed6e..24939dea 100644 --- a/mac/Tests/CodeBurnMenubarTests/DataClientProcessTests.swift +++ b/mac/Tests/CodeBurnMenubarTests/DataClientProcessTests.swift @@ -89,38 +89,46 @@ struct DataClientProcessTests { /// Concurrency + timeout smoke test: launch more hung subprocesses than /// there are cooperative threads, all at once, with a short timeout, and - /// assert every call returns once the timeout kills its sleep. + /// assert every call returns because the timeout killed its sleep. /// /// NOTE: this does NOT reproduce the production permanent deadlock (16/16 - /// cooperative threads parked in waitUntilExit). In a short-lived unit-test - /// process libdispatch spins up replacement threads for blocked workers, so - /// even the old blocking-on-the-pool code completes here. The real deadlock - /// built up over ~2 days under the @MainActor refresh loop and is confirmed - /// by the live `sample`, not by this test. Kept as a guard that the - /// off-pool wait + timeout path stays correct under concurrency. - @Test("concurrent timed-out processes all complete") - func concurrentTimedOutProcessesAllComplete() { + /// cooperative threads parked in waitUntilExit). The real deadlock built up + /// over ~2 days under the @MainActor refresh loop and is confirmed by the + /// live `sample`, not by this test. Kept as a guard that the off-pool wait + /// + timeout path stays correct under concurrency. + /// + /// The body must stay `async` and await the group directly. It used to + /// block on a `DispatchSemaphore` with a 15s deadline, on the claim that a + /// test body runs on a real thread. It does not: Swift Testing invokes even + /// synchronous test bodies from a task on the cooperative pool, so the wait + /// parked one of the pool's `activeProcessorCount` workers on the very work + /// it was waiting for. A 16-core dev box has slack, a 3-core CI runner does + /// not, and the wait expired with the group making no progress at all. + /// Keeping it `async` also lets the compiler reject the blocking wait, + /// which is unavailable from asynchronous contexts. + @Test("concurrent timed-out processes all complete", .timeLimit(.minutes(1))) + func concurrentTimedOutProcessesAllComplete() async { let count = ProcessInfo.processInfo.activeProcessorCount * 2 + 4 - let done = DispatchSemaphore(value: 0) - - Task { - await withTaskGroup(of: Void.self) { group in - for _ in 0.. [Int32?] in + for _ in 0..