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
47 changes: 33 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-homeatlas-spm-${{ hashFiles('**/Package.resolved') }}
key: ${{ runner.os }}-homeatlas-spm-${{ hashFiles('Package.swift') }}
restore-keys: |
${{ runner.os }}-homeatlas-spm-

Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-homeatlas-spm-${{ hashFiles('**/Package.resolved') }}
key: ${{ runner.os }}-homeatlas-spm-${{ hashFiles('Package.swift') }}
restore-keys: |
${{ runner.os }}-homeatlas-spm-

Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:
uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-homeatlas-spm-generators-${{ hashFiles('**/Package.resolved') }}
key: ${{ runner.os }}-homeatlas-spm-generators-${{ hashFiles('Package.swift') }}
restore-keys: |
${{ runner.os }}-homeatlas-spm-generators-

Expand All @@ -122,23 +122,42 @@ jobs:

- name: Codegen sanity (no diffs)
run: |
set +e

# Re-run generator with the current catalog and ensure tree remains clean
swift run HomeKitServiceGenerator Resources/homekit-services.yaml --output Sources/HomeAtlas/Generated
# Check for diffs, ignoring timestamp changes (line 2 of generated files)
if git diff --exit-code -- ':!**/Generated/**/*.swift'; then
echo "No unexpected changes outside Generated directory"
else
echo "ERROR: Unexpected changes detected outside Generated directory"
GEN_EXIT=$?
if [ $GEN_EXIT -ne 0 ]; then
echo "::error::Generator exited with code $GEN_EXIT"
exit 1
fi
Comment on lines 124 to 133

echo "--- git status after generator run ---"
git status --short
echo "--- git diff --stat ---"
git diff --stat

# Check for diffs outside Generated directories
# Use positive pathspec to check only non-generated files
NON_GEN_DIFF=$(git diff --name-only | grep -v '/Generated/' || true)
if [ -n "$NON_GEN_DIFF" ]; then
echo "::error::Unexpected changes detected outside Generated directories:"
echo "$NON_GEN_DIFF"
git diff -- $(echo "$NON_GEN_DIFF" | head -20)
Comment on lines +142 to +146
exit 1
fi
echo "No unexpected changes outside Generated directories"

# For generated files, check only meaningful changes (ignore timestamp line)
if git diff -U0 Sources/HomeAtlas/Generated Sources/HomeAtlasMacros/Generated | grep -E "^[\+\-]" | grep -v -E "^(\+\+\+|---)" | grep -v "Generated on"; then
echo "ERROR: Unexpected changes in generated files (excluding timestamps)"
git diff Sources/HomeAtlas/Generated Sources/HomeAtlasMacros/Generated
git diff -U0 -- 'Sources/HomeAtlas/Generated' 'Sources/HomeAtlasMacros/Generated' > /tmp/gen-diff.txt || true
# Filter to only +/- content lines, exclude file headers and timestamp lines
MEANINGFUL=$(grep -E '^\+|^-' /tmp/gen-diff.txt | grep -v -E '^\+\+\+|^---' | grep -v 'Generated on' || true)
if [ -n "$MEANINGFUL" ]; then
echo "::error::Unexpected changes in generated files (excluding timestamps):"
echo "$MEANINGFUL"
exit 1
else
echo "Generated files have only timestamp changes, which is expected"
fi
echo "Generated files have only timestamp changes, which is expected"

# Verify package builds on multiple Swift versions
swift-versions:
Expand All @@ -161,7 +180,7 @@ jobs:
uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-homeatlas-swift${{ matrix.swift }}-spm-${{ hashFiles('**/Package.resolved') }}
key: ${{ runner.os }}-homeatlas-swift${{ matrix.swift }}-spm-${{ hashFiles('Package.swift') }}
restore-keys: |
${{ runner.os }}-homeatlas-swift${{ matrix.swift }}-spm-

Expand Down
5 changes: 3 additions & 2 deletions Sources/HomeAtlas/Accessory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,10 @@ private extension Accessory {

/// A strongly-typed wrapper for HomeKit accessories (stub for non-HomeKit platforms).
@MainActor
public final class Accessory {
public final class Accessory: HomeKitDescribable {
public var name: String { "" }
public var uniqueIdentifier: UUID { UUID() }
public let uniqueIdentifier: UUID = UUID()
public var localizedDescription: String { "" }
public var isReachable: Bool { false }
Comment on lines +317 to 321
Comment on lines 318 to 321
public var isBlocked: Bool { false }
public var supportsIdentify: Bool { false }
Expand Down
3 changes: 2 additions & 1 deletion Sources/HomeAtlas/Characteristic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,10 @@ extension Duration {

/// A strongly-typed wrapper for HomeKit characteristics (stub for non-HomeKit platforms).
@MainActor
open class Characteristic<Value> {
open class Characteristic<Value>: HomeKitDescribable {
public var characteristicType: String { "" }
public var localizedDescription: String { "" }
public let uniqueIdentifier: UUID = UUID()
public var supportsRead: Bool { false }
Comment on lines +317 to 321
public var supportsWrite: Bool { false }
public var supportsEventNotification: Bool { false }
Expand Down
4 changes: 2 additions & 2 deletions Sources/HomeAtlas/Service.swift
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,13 @@ public extension Service {

/// A strongly-typed wrapper for HomeKit services (stub for non-HomeKit platforms).
@MainActor
open class Service {
open class Service: HomeKitDescribable {
public var serviceType: String { "" }
public var name: String? { nil }
public var localizedDescription: String { "" }
public var isPrimaryService: Bool { false }
public var isUserInteractive: Bool { false }
public var uniqueIdentifier: UUID { UUID() }
public let uniqueIdentifier: UUID = UUID()
Comment on lines +224 to +230

public init() {}

Expand Down
Loading