Skip to content

Commit

Permalink
Fridge 0.9.3
Browse files Browse the repository at this point in the history
Added support for array types to main Fridge interface (#37)
Expanded CI test collection. (#23)

Squashed commits:
commit fa8dbf8
commit 81b1f08
commit 523930d

Closes #23

Signed-off-by: Veljko Tekelerović <veljko.tekelerovic@gmail.com>
  • Loading branch information
vexy committed Sep 24, 2022
1 parent 8a84b5f commit ac3cfda
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 9 deletions.
80 changes: 72 additions & 8 deletions .github/workflows/tests_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,79 @@ on:
jobs:
build:
runs-on: macos-latest
name: Fridge library testing suite
name: Fridge warmup build

steps:
- uses: actions/checkout@v2
- name: pure swift build
- name: Pure swift build
run: swift build -v
- name: Test - iOS Simulator 8
run: xcodebuild test-without-building -scheme "Fridge" -destination "platform=iOS Simulator,name=iPhone 8"
- name: Test - iOS Simulator 11
run: xcodebuild test-without-building -scheme "Fridge" -destination "platform=iOS Simulator,name=iPhone 11"
- name: Test - iOS Simulator 12
run: xcodebuild test-without-building -scheme "Fridge" -destination "platform=iOS Simulator,name=iPhone 12"

tests-ios:
runs-on: macos-latest
name: Fridge test destination`:` iOS

steps:
- uses: actions/checkout@v2
- name: iOS Simulator SE
run: xcodebuild clean test -scheme "Fridge" -destination "platform=iOS Simulator,name=iPhone SE"
- name: iOS Simulator iPod touch
run: xcodebuild clean test -scheme "Fridge" -destination "platform=iOS Simulator,name=iPhone iPod touch"
- name: iOS Simulator 8
run: xcodebuild clean test -scheme "Fridge" -destination "platform=iOS Simulator,name=iPhone 8"
- name: iOS Simulator 11
run: xcodebuild clean test -scheme "Fridge" -destination "platform=iOS Simulator,name=iPhone 11"
- name: iOS Simulator 11 Pro
run: xcodebuild clean test -scheme "Fridge" -destination "platform=iOS Simulator,name=iPhone 11 Pro"
- name: iOS Simulator 11 Pro Max
run: xcodebuild clean test -scheme "Fridge" -destination "platform=iOS Simulator,name=iPhone 11 Pro Max"
- name: iOS Simulator 12
run: xcodebuild clean test -scheme "Fridge" -destination "platform=iOS Simulator,name=iPhone 12"
- name: iOS Simulator 12 Pro
run: xcodebuild clean test -scheme "Fridge" -destination "platform=iOS Simulator,name=iPhone 12 Pro"
- name: iOS Simulator 12 Pro Max
run: xcodebuild clean test -scheme "Fridge" -destination "platform=iOS Simulator,name=iPhone 12 Pro Max"

tests-macos:
runs-on: macos-latest
name: Fridge test destination`:` macOS

steps:
- uses: actions/checkout@v2
- name: Mac x86_64
run: xcodebuild clean test -scheme "Fridge" -destination "platform=macOS,arch=x86_64"
- name: Mac Catalyst
run: xcodebuild clean test -scheme "Fridge" -destination "platform=macOS,arch=x86_64,variant=Mac Catalyst"
- name: DriverKit
run: xcodebuild clean test -scheme "Fridge" -destination "platform=macOS,arch=x86_64,variant=DriverKit"

tests-watchos:
runs-on: macos-latest
name: Fridge test destination`:` watchOS

steps:
- uses: actions/checkout@v2
- name: Apple Watch Series 5 - 40mm
run: xcodebuild clean test -scheme "Fridge" -destination "platform=watchOS Simulator,name=Apple Watch Series 5 - 40mm"
- name: Apple Watch Series 5 - 44mm
run: xcodebuild clean test -scheme "Fridge" -destination "platform=watchOS Simulator,name=Apple Watch Series 5 - 44mm"
- name: Apple Watch Series 6 - 40mm
run: xcodebuild clean test -scheme "Fridge" -destination "platform=watchOS Simulator,name=Apple Watch Series 6 - 40mm"
- name: Apple Watch Series 6 - 44mm
run: xcodebuild clean test -scheme "Fridge" -destination "platform=watchOS Simulator,name=Apple Watch Series 6 - 44mm"
- name: Apple Watch Series 7 - 41mm
run: xcodebuild clean test -scheme "Fridge" -destination "platform=watchOS Simulator,name=Apple Watch Series 7 - 41mm"
- name: Apple Watch Series 7 - 45mm
run: xcodebuild clean test -scheme "Fridge" -destination "platform=watchOS Simulator,name=Apple Watch Series 7 - 45mm"

tests-tvos:
runs-on: macos-latest
name: Fridge test destination`:` tvOS

steps:
- uses: actions/checkout@v2
- name: Apple TV
run: xcodebuild clean test -scheme "Fridge" -destination "platform=tvOS Simulator,name=Apple TV"
- name: Apple TV 4k
run: xcodebuild clean test -scheme "Fridge" -destination "platform=tvOS Simulator,name=Apple TV 4k (2nd generation)"
- name: Apple TV 4k (at 1080p)
run: xcodebuild clean test -scheme "Fridge" -destination "platform=tvOS Simulator,name=Apple TV 4k (at 1080p) (2nd generation)"
2 changes: 2 additions & 0 deletions Sources/Fridge/Freezer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ final internal class Freezer {
}
}

//MARK: --

/// Unfreezes an object from Fridge persistant storage.
func unfreeze<T: Decodable>(identifier: String) throws -> T {
do {
Expand Down
22 changes: 21 additions & 1 deletion Sources/Fridge/Fridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ extension Fridge {

//MARK: - Object persistent storage
extension Fridge {
/// Tries to freeze an object into persistant storage (if possible).
/// Tries to freeze an object into persistant storage.
public static func freeze🧊<E: Encodable>(_ object: E, id: String) throws {
let freezer = Freezer()
do {
Expand All @@ -121,12 +121,32 @@ extension Fridge {
}
}

/// Tries to freeze array of objects into persistant storage.
public static func freeze🧊<C: Codable>(_ objects: [C], id: String) throws {
let freezer = Freezer()
do {
try freezer.freeze(objects: objects, identifier: id)
} catch let err {
print("<Fridge.Freezer> Error occured: \(err.localizedDescription)")
throw FreezingErrors.dataStoringError
}
}

//MARK: --

/// Tries to unfreeze an object from persistant storage.
public static func unfreeze🪅🎉<D: Decodable>(_ key: String) throws -> D {
let unfreezer = Freezer()
let unfrozenObject: D = try unfreezer.unfreeze(identifier: key) // propagate any Errors further
return unfrozenObject
}

/// Tries to unfreeze an array of objects from persistant storage.
public static func unfreeze🪅🎉<C: Codable>(_ key: String) throws -> [C] {
let unfreezer = Freezer()
let unfrozenObject: [C] = try unfreezer.unfreeze(identifier: key) // propagate any Errors further
return unfrozenObject
}
}

//MARK: - Utilities
Expand Down

0 comments on commit ac3cfda

Please sign in to comment.