Skip to content
Merged
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
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ jobs:
command -v rg >/dev/null || brew install ripgrep
./scripts/vocab-check.sh

# swift format lint (#1165) with Xcode's own swift-format: about a second, and every finding fails the leg.
# .swift-format has the rules; scripts/swift-format-lint.sh says which are off and why.
- name: swift format lint
if: matrix.check == 'package tests'
run: ./scripts/swift-format-lint.sh

- name: Package tests
if: matrix.check == 'package tests'
working-directory: Packages/ShowRecorderKit
Expand Down
53 changes: 53 additions & 0 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"version" : 1,
"indentation" : {
"spaces" : 4
},
"lineLength" : 130,
"indentConditionalCompilationBlocks" : false,
"rules" : {
"AllPublicDeclarationsHaveDocumentation" : false,
"AlwaysUseLiteralForEmptyCollectionInit" : false,
"AlwaysUseLowerCamelCase" : true,
"AmbiguousTrailingClosureOverload" : true,
"AvoidRetroactiveConformances" : true,
"BeginDocumentationCommentWithOneLineSummary" : false,
"DoNotUseSemicolons" : false,
"DontRepeatTypeInStaticProperties" : true,
"FileScopedDeclarationPrivacy" : true,
"FullyIndirectEnum" : true,
"GroupNumericLiterals" : true,
"IdentifiersMustBeASCII" : true,
"NeverForceUnwrap" : false,
"NeverUseForceTry" : false,
"NeverUseImplicitlyUnwrappedOptionals" : false,
"NoAccessLevelOnExtensionDeclaration" : false,
"NoAssignmentInExpressions" : true,
"NoBlockComments" : true,
"NoCasesWithOnlyFallthrough" : true,
"NoEmptyLinesOpeningClosingBraces" : false,
"NoEmptyTrailingClosureParentheses" : true,
"NoLabelsInCasePatterns" : true,
"NoLeadingUnderscores" : false,
"NoParensAroundConditions" : true,
"NoPlaygroundLiterals" : true,
"NoVoidReturnOnFunctionSignature" : true,
"OmitExplicitReturns" : false,
"OneCasePerLine" : true,
"OneVariableDeclarationPerLine" : false,
"OnlyOneTrailingClosureArgument" : true,
"OrderedImports" : false,
"ReplaceForEachWithForLoop" : true,
"ReturnVoidInsteadOfEmptyTuple" : true,
"TypeNamesShouldBeCapitalized" : true,
"UseEarlyExits" : false,
"UseExplicitNilCheckInConditions" : true,
"UseLetInEveryBoundCaseVariable" : true,
"UseShorthandTypeNames" : true,
"UseSingleLinePropertyGetter" : true,
"UseSynthesizedInitializer" : true,
"UseTripleSlashForDocumentationComments" : true,
"UseWhereClausesInForLoops" : false,
"ValidateDocumentationComments" : false
}
}
2 changes: 1 addition & 1 deletion App/RecordScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ final class RecordScreenModel {
self.takeTelemetry.handle(event, context: TakeContext(
recorder: self.recorder, mixerFamily: self.mixer.family.map { String(describing: $0) }))
// The App Store rating prompt counts clean Takes here; it asks later, when the screen is idle.
if case let .takeEnded(end) = event { self.countForRating(end) }
if case .takeEnded(let end) = event { self.countForRating(end) }
let followUp = TakeFollowUp(event)
if followUp.contains(.liveActivity) { followLiveActivity() }
if followUp.contains(.proOffer) { offerProAfterTake() }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/// What to do when a Drive connects while Drive only Takes (#196, #630) wait on the Device (#805): move them now,
/// ask the operator first, or leave them.
public enum DriveOnlyMoveOffer: Equatable, Sendable {
case move, ask(takeCount: Int), leave
case move
case ask(takeCount: Int)
case leave

/// Never during a Take. Where Record to isn't offered, or with Drive or Both chosen, the Takes move as before;
/// with the Device chosen the operator is asked, once per Drive connection. Mark the connection asked only on `ask`:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public enum DriveSpeedTest {
for index in 0..<frames { buffer[index] = sinf(Float(index + channel * 7) * 0.05) * 0.25 }
return buffer
}
defer { buffers.forEach { $0.deallocate() } }
defer { for buffer in buffers { buffer.deallocate() } }
let pointers = buffers.map { UnsafePointer($0) }

let clock = ContinuousClock()
Expand Down
5 changes: 4 additions & 1 deletion Packages/ShowRecorderKit/Sources/Recording/Recorder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,10 @@ public final class Recorder {
}
}

private enum DeviceCopyDelete: Sendable { case refused(String), onlyCopy, checked }
private enum DeviceCopyDelete: Sendable {
case refused(String)
case onlyCopy, checked
}

/// Whether Take `take`'s Device copy is refused, is the only copy, or needs the Drive check first (#925). The refusals
/// are checked here; the files and the Drive are read on a thread of their own (#1021), counted like a Show detail edit.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public final class TakeTelemetry {
send(.takeStarted(
channelCount: context.channelCount, destinations: context.destinations, mixerFamily: context.mixerFamily
))
case let .takeEnded(end):
case .takeEnded(let end):
let seconds = startedAt.map { Int(now().timeIntervalSince($0)) } ?? 0
startedAt = nil
send(.takeStopped(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ public final class PostHogSink: TelemetrySink {
var properties: [String: Any] = ["app": "showrecorder"]
for (key, value) in event.properties {
switch value {
case let .int(number): properties[key] = number
case let .string(text): properties[key] = text
case let .bool(flag): properties[key] = flag
case .int(let number): properties[key] = number
case .string(let text): properties[key] = text
case .bool(let flag): properties[key] = flag
}
}
return properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ public struct WatchStatus: Codable, Equatable, Sendable {

/// The wire keeps the old names, "armed" and "notArmed", so a paired watch a version behind still reads them.
private enum CodingKeys: String, CodingKey {
case notReady = "notArmed", ready = "armed", recording
case notReady = "notArmed"
case ready = "armed"
case recording
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ struct LevelFeedTests {

/// The measurement's result, or `.timedOut` after `timeout` (default `hangGuard`), so a measurement that never ends
/// fails the test instead of hanging the run (and the shared build lock with it).
enum Outcome: Equatable { case level(Double?), timedOut }
enum Outcome: Equatable {
case level(Double?)
case timedOut
}
/// Not a task group: that waits for every child, so a measurement that never ends would hang it anyway.
static func result(_ task: Task<Double?, Never>, within timeout: Duration = hangGuard) async -> Outcome {
let (outcomes, sink) = AsyncStream<Outcome>.makeStream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct PeakMetersLevelTests {
buffer.initialize(from: samples, count: samples.count)
return buffer
}
defer { buffers.forEach { $0.deallocate() } }
defer { for buffer in buffers { buffer.deallocate() } }
var pointers = buffers.map { UnsafePointer<Float>($0) }
pointers.withUnsafeMutableBufferPointer {
meters.record(AudioBlock(channels: $0.baseAddress!, channelCount: channels, frameCount: samples.count, hostTime: 0))
Expand Down
2 changes: 2 additions & 0 deletions docs/DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ xcodebuild -project ShowRecorder.xcodeproj -scheme ShowRecorder \

`scripts/verify.sh` runs the checks CI runs, but only those the branch's changes need: the vocabulary check, package tests, macOS and iOS Simulator builds, the app's unit tests (`AppTests`, hosted on the Mac build, so no Simulator; CI runs them on its macOS leg), and the website's lint, tests and build. It prints its plan first; a docs-only change needs none (except `docs/release-notes/`, which the site's changelog test reads, so it runs the site checks), and a change to `verify.sh`, CI or an unlisted path runs everything. `VERIFY_ALL=1` runs everything, `VERIFY_QUICK=1` skips the macOS and iOS app builds and `AppTests` and leaves them to CI (everything else runs as the changes need; a signed device build is skipped too, and CI doesn't run that one), `VERIFY_PLAN_ONLY=1` prints the plan and stops, and the header of `verify.sh` lists which paths pick which checks. Set `DEVICE_ID` and `DEVELOPMENT_TEAM` to also build for a device. The package tests, both app builds and the website run side by side, as CI runs them: each writes its own log, and at the end `verify.sh` prints each step's result and time and the log of any that failed. Each app build has its own build folder (`build/dd-mac`, `build/dd-ios`, `build/dd-device`; `DERIVED_DATA` changes the `build/dd` prefix), so they don't wait on each other; an older `build/dd` can be deleted. Ctrl-C stops every step. CI runs on every pull request on GitHub's free hosted `macos-26` runner and must pass before a PR merges.

`scripts/swift-format-lint.sh` runs `swift format lint` (#1165; swift-format comes with the toolchain) on every tracked Swift file outside `spikes/`, in every `verify.sh` plan and in CI's package tests leg. It changes no file, takes about a second, and any finding fails it. The rules are in `.swift-format`; the header of the script lists the four that are off because the code breaks them widely, and says why layout (indentation, line length, line breaks) isn't checked yet.

### Two heavy builds at a time

Several agents often work on this Mac at once, in their own worktrees. Many builds run side by side starve each other, and tests with time limits fail under the load. So every heavy build takes one of two build slots, shared by all worktrees of the repo: slot 1 is the lock file `.git/verify.lock`, slot 2 is `.git/verify.lock.2`. A build takes the first free slot; a third one waits until either frees and says so: "== Waiting for another build on this Mac to finish". Builds that hold a slot run at low priority (`nice -n 10`).
Expand Down
32 changes: 32 additions & 0 deletions scripts/swift-format-lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh
# `swift format lint` (#1165), the check CI runs: swift-format comes with the Swift toolchain, so nothing to install.
# It changes no file. Every finding fails it.
#
# What it checks is in .swift-format at the top of the repo:
# - The rules list is complete on purpose. A rule left out is off, and a name the toolchain doesn't know fails
# every file ("unrecognized rule"), so add a rule only when CI's Xcode and your own toolchain both have it.
# - Off because the code breaks them widely (counts from 2026-12-03): DoNotUseSemicolons (820), OrderedImports (218,
# mostly `@testable import` first), OneVariableDeclarationPerLine (161) and NoAccessLevelOnExtensionDeclaration
# (7 `private extension`s). Turning one on is its own PR, with the cleanup.
# - Layout (indentation, line length, line breaks, spacing, trailing commas) isn't checked at all:
# --debug-disable-pretty-print turns that half of the linter off. The code is laid out by hand, and with the
# config's 4 spaces and 130 columns swift-format still wants about 3,200 changes. The layout settings in
# .swift-format are there for Xcode's "Format with swift-format" and for a later reformat.
#
# spikes/ (experiments) isn't checked. With no Swift toolchain it says so and passes: CI still checks.
# SHOWRECORDER_REAL_SWIFT=<path> the swift to use (default /usr/bin/swift, then `swift` on PATH), as scripts/bin/swift
set -eu
cd "$(dirname "$0")/.."

swift="${SHOWRECORDER_REAL_SWIFT:-/usr/bin/swift}"
[ -x "$swift" ] || swift=$(command -v swift || true)
if [ -z "$swift" ] || ! version=$("$swift" format --version 2>/dev/null); then
echo "== swift format lint: no swift format here; skipped, CI still checks"
exit 0
fi
echo "swift-format $version"

# Tracked files only, so build folders and package checkouts stay out.
files=$(git ls-files -- '*.swift' ':!spikes/')
# shellcheck disable=SC2086 # one path per word: no tracked Swift file has a space in its name
"$swift" format lint --strict --parallel --debug-disable-pretty-print $files
2 changes: 1 addition & 1 deletion scripts/test-verify-plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ else
printf '%s\n' "$f" | grep -qE "$sim_pattern" && { echo "FAIL: CI runs the mixer-sim job for $f"; fail=1; }
done
fi
grep -q "needs: \[changes, app, site, mixer-sim\]" .github/workflows/ci.yml ||
grep -q "needs: \[changes, app, site, mixer-sim, scripts\]" .github/workflows/ci.yml ||
{ echo "FAIL: the required Test and build check doesn't wait for the mixer-sim job"; fail=1; }

[ $fail -eq 0 ] && echo "verify.sh plan: all cases pass"
Expand Down
4 changes: 4 additions & 0 deletions scripts/verify.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh
# Runs the checks CI runs, but only the ones the changed files need:
# spelling scripts/spelling-check.sh every plan: CI's American spelling check, on the whole repo
# format scripts/swift-format-lint.sh every plan: CI's swift format lint (#1165), about a second, no build
# take grep every plan: Take control on the recorder only in TakeSequencer (#551)
# vocab scripts/vocab-check.sh App/, package Sources/, CONTEXT.md, scripts/vocab-*
# package swift test Packages/
Expand Down Expand Up @@ -139,6 +140,9 @@ fi
echo "== American spelling (CI's check)"
./scripts/spelling-check.sh

echo "== swift format lint (CI's check)"
./scripts/swift-format-lint.sh

echo "== Take control (#551)"
if grep -rnE 'recorder\.(startTake|stopTake|addMarker|endShow|startNewShow|prepareNextShow)\(' App Packages/ShowRecorderKit/Sources \
--include='*.swift' | grep -vE '^Packages/ShowRecorderKit/Sources/Recording/(TakeSequencer|Recorder)\.swift:'; then
Expand Down
Loading