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
44 changes: 25 additions & 19 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
# CircleCI configuration file
# Commented out, because currently Swift 6.2 isn’t available
# on CircleCI free plan resources

version: 2.1
jobs:
build:
macos:
xcode: "16.0.0"
steps:
- checkout
- run: swift build -v
# version: 2.1
# jobs:
# build:
# macos:
# xcode: "26.0.1"
# resource_class: macos.m1.medium.gen1
# steps:
# - checkout:
# method: blobless
# - run: swift build -v

test:
macos:
xcode: "16.0.0"
steps:
- checkout
- run: swift test -v
# test:
# macos:
# xcode: "26.0.1"
# resource_class: macos.m1.medium.gen1
# steps:
# - checkout:
# method: blobless
# - run: swift test -v

workflows:
build-and-test:
jobs:
- build
- test
# workflows:
# build-and-test:
# jobs:
# - build
# - test
27 changes: 27 additions & 0 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This workflow will build a Swift project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift
# Currently commented out, as Swift 6.2 isn’t available
# on GitHub Actions.

# name: Swift

# on:
# push:
# branches: [ "main" ]
# pull_request:
# branches: [ "main" ]

# jobs:
# build:

# runs-on: macos-latest

# steps:
# - uses: actions/checkout@v4
# - uses: swift-actions/setup-swift@v2
# with:
# swift-version: "6.2"
# - name: Build
# run: swift build -v
# - name: Run tests
# run: swift test -v
18 changes: 4 additions & 14 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.10
// swift-tools-version: 6.2
// The swift-tools-version declares the minimum version of Swift required to build this package.

import Foundation
Expand All @@ -7,11 +7,11 @@ import PackageDescription
var dependencies: [PackageDescription.Package.Dependency] = [
.package(
url: "https://github.com/groue/Semaphore",
from: "0.0.8"
from: "0.1.0"
),
.package(
url: "https://github.com/pointfreeco/swift-dependencies",
from: "1.0.0"
from: "1.10.0"
)
]

Expand All @@ -30,30 +30,20 @@ if ProcessInfo.processInfo.environment["SPI_BUILDER"] == "1" {
let package = Package(
name: "Canopy",
defaultLocalization: "en",
platforms: [.iOS(.v15), .macOS(.v12)],
platforms: [.iOS(.v18), .macOS(.v15)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(name: "Canopy", targets: ["Canopy"]),
.library(name: "CanopyTestTools", targets: ["CanopyTestTools"])
],
dependencies: dependencies,
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "Canopy",
dependencies: [
"Semaphore",
.product(name: "Dependencies", package: "swift-dependencies")
],
path: "Targets/Canopy/Sources"
// https://danielsaidi.com/blog/2022/05/18/how-to-suppress-linking-warning
// Canopy by default gives a warning about unsafe code for application extensions. Not sure why it says that.
// See the above blog post for more info.
// The following line is OK to have in local development, but in live setting, cannot be used.
// This could also be obsolete, latest Canopy does not give warnings with extensions any more.
// Keeping this info here just for a while longer.
// linkerSettings: [.unsafeFlags(["-Xlinker", "-no_application_extension"])]
),
.target(
name: "CanopyTestTools",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import CloudKit

@available(iOS 16.4, macOS 13.3, *)
extension CKDatabaseAPI {
func randomCKRecordError(
codes: Set<CKError.Code>,
Expand All @@ -22,14 +21,14 @@ extension CKDatabaseAPI {

var partialErrors: [AnyHashable: Error] = [:]
if let saved = recordsToSave {
saved.forEach {
partialErrors[$0.recordID] = randomCKRecordError(codes: otherCodes).ckError
for oneSaved in saved {
partialErrors[oneSaved.recordID] = randomCKRecordError(codes: otherCodes).ckError
}
}

if let deleted = recordIDsToDelete {
deleted.forEach {
partialErrors[$0] = randomCKRecordError(codes: otherCodes).ckError
for oneDeleted in deleted {
partialErrors[oneDeleted] = randomCKRecordError(codes: otherCodes).ckError
}
}

Expand Down
3 changes: 1 addition & 2 deletions Targets/Canopy/Sources/CKDatabaseAPI/CKDatabaseAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import Foundation
import os.log
import Semaphore

@available(iOS 16.4, macOS 13.3, *)
actor CKDatabaseAPI: CKDatabaseAPIType {
private let database: CKDatabaseType
private let databaseScope: CKDatabase.Scope
internal let settingsProvider: () async -> CanopySettingsType
internal let settingsProvider: @Sendable () async -> CanopySettingsType
private let tokenStore: TokenStoreType
private let fetchDatabaseChangesSemaphore = AsyncSemaphore(value: 1)
private let fetchZoneChangesSemaphore = AsyncSemaphore(value: 1)
Expand Down
1 change: 0 additions & 1 deletion Targets/Canopy/Sources/Canopy/Canopy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Foundation
/// You construct Canopy with injected CloudKit container and databases, token store, and settings provider.
/// Canopy has reasonable defaults for all of these, and you need to only override the ones that need to use
/// a different value from the default.
@available(iOS 16.4, macOS 13.3, *)
public actor Canopy: CanopyType {
private let containerProvider: @Sendable () -> CKContainerType
private let publicCloudDatabaseProvider: @Sendable () -> CKDatabaseType
Expand Down
1 change: 0 additions & 1 deletion Targets/Canopy/Sources/Canopy/MockCanopyWithCKMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import CloudKit
/// MockCanopyWithCKMocks is mostly appropriate to use as a testing tool for Canopy’s
/// own logic, or when you need to inject your own Canopy settings for various behaviors.
/// For using in your own tests, `MockCanopy` is more appropriate and simpler to use.
@available(iOS 16.4, macOS 13.3, *)
public struct MockCanopyWithCKMocks: CanopyType {
private let mockPrivateCKDatabase: CKDatabaseType?
private let mockSharedCKDatabase: CKDatabaseType?
Expand Down
2 changes: 0 additions & 2 deletions Targets/Canopy/Sources/Dependency/Canopy+Dependency.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import Dependencies

@available(iOS 16.4, macOS 13.3, *)
private enum CanopyKey: DependencyKey, Sendable {
static let liveValue: CanopyType = Canopy()
}

@available(iOS 16.4, macOS 13.3, *)
public extension DependencyValues {
/// Canopy packaged as CloudKit dependency via swift-dependencies.
var cloudKit: CanopyType {
Expand Down
16 changes: 8 additions & 8 deletions Targets/Canopy/Tests/CKDatabaseScopeExtensionTests.swift
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
@testable import Canopy
import CloudKit
import XCTest
import Testing

final class CKDatabaseScopeExtensionTests: XCTestCase {
func test_private_scope() {
XCTAssertEqual(CKDatabase.Scope.private.asString, "private")
@Suite struct CKDatabaseScopeExtensionTests {
@Test func test_private_scope() {
#expect(CKDatabase.Scope.private.asString == "private")
}

func test_shared_scope() {
XCTAssertEqual(CKDatabase.Scope.shared.asString, "shared")
@Test func test_shared_scope() {
#expect(CKDatabase.Scope.shared.asString == "shared")
}

func test_public_scope() {
XCTAssertEqual(CKDatabase.Scope.public.asString, "public")
@Test func test_public_scope() {
#expect(CKDatabase.Scope.public.asString == "public")
}
}
12 changes: 6 additions & 6 deletions Targets/Canopy/Tests/CKRecordZoneIDExtensionTests.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
@testable import Canopy
import CloudKit
import XCTest
import Testing

final class CKRecordZoneIDExtensionTests: XCTestCase {
func test_private_zone() {
@Suite struct CKRecordZoneIDExtensionTests {
@Test func test_private_zone() {
let privateZoneID = CKRecordZone.ID(zoneName: "someZone", ownerName: CKCurrentUserDefaultName)
XCTAssertEqual(privateZoneID.ckDatabaseScope, .private)
#expect(privateZoneID.ckDatabaseScope == .private)
}

func test_shared_zone() {
@Test func test_shared_zone() {
let sharedZoneID = CKRecordZone.ID(zoneName: "someSharedZone", ownerName: "someOtherPerson")
XCTAssertEqual(sharedZoneID.ckDatabaseScope, .shared)
#expect(sharedZoneID.ckDatabaseScope == .shared)
}
}
Loading