Skip to content

Commit

Permalink
Swift 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
NikSativa committed Sep 27, 2024
1 parent e6d4592 commit 798d54f
Show file tree
Hide file tree
Showing 15 changed files with 129 additions and 222 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/swift_macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: "NikSativa CI"

on:
push:
branches:
- "main"
paths:
- ".github/workflows/**"
- "Package.swift"
- "Source/**"
- "Tests/**"
pull_request:
paths:
- ".github/workflows/**"
- "Package.swift"
- "Source/**"
- "Tests/**"

concurrency:
group: ${{ github.ref_name }}
cancel-in-progress: true
jobs:
macOS:
name: "macOS ${{ matrix.xcode }} ${{ matrix.swift }}"
runs-on: ${{ matrix.runsOn }}
env:
DEVELOPER_DIR: "/Applications/${{ matrix.xcode }}.app/Contents/Developer"
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
include:
- xcode: "Xcode_16"
runsOn: macOS-15
swift: "6.0"
outputFilter: xcbeautify --renderer github-actions
- xcode: "Xcode_15.4"
runsOn: macOS-14
swift: "5.10"
outputFilter: xcbeautify --renderer github-actions
- xcode: "Xcode_15.2"
runsOn: macOS-14
swift: "5.9"
outputFilter: xcbeautify --renderer github-actions
- xcode: "Xcode_14.3"
runsOn: macOS-13
swift: "5.8"
outputFilter: xcbeautify --renderer github-actions
steps:
- uses: NeedleInAJayStack/setup-swift@feat/swift-6 # swift-actions/setup-swift@main
with:
swift-version: ${{ matrix.swift }}
- uses: actions/checkout@v4
- name: "Build ${{ matrix.xcode }} ${{ matrix.swift }}"
run: swift build -v | ${{ matrix.outputFilter }}
- name: "Test ${{ matrix.xcode }} ${{ matrix.swift }}"
run: swift test -v | ${{ matrix.outputFilter }}
13 changes: 9 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ let package = Package(
],
path: "Source",
resources: [
.copy("../PrivacyInfo.xcprivacy")
.process("PrivacyInfo.xcprivacy")
],
swiftSettings: [
.define("supportsVisionOS", .when(platforms: [.visionOS])),
]),
// test
.testTarget(name: "SpryKitTests",
Expand All @@ -60,7 +63,9 @@ let package = Package(
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax")
],
path: "Tests")
],
swiftLanguageModes: [.v6]
path: "Tests",
swiftSettings: [
.define("supportsVisionOS", .when(platforms: [.visionOS])),
])
]
)
36 changes: 0 additions & 36 deletions Package@swift-5.5.swift

This file was deleted.

36 changes: 0 additions & 36 deletions Package@swift-5.6.swift

This file was deleted.

36 changes: 0 additions & 36 deletions Package@swift-5.7.swift

This file was deleted.

5 changes: 2 additions & 3 deletions Package@swift-5.8.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ let package = Package(
],
path: "Source",
resources: [
.copy("../PrivacyInfo.xcprivacy")
.process("PrivacyInfo.xcprivacy")
]),
.testTarget(name: "SpryTests",
dependencies: [
"SpryKit"
],
path: "Tests")
],
swiftLanguageVersions: [.v5]
]
)
13 changes: 9 additions & 4 deletions Package@swift-5.9.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,18 @@ let package = Package(
],
path: "Source",
resources: [
.copy("../PrivacyInfo.xcprivacy")
.process("PrivacyInfo.xcprivacy")
],
swiftSettings: [
.define("supportsVisionOS", .when(platforms: [.visionOS])),
]),
.testTarget(name: "SpryTests",
dependencies: [
"SpryKit"
],
path: "Tests")
],
swiftLanguageVersions: [.v5]
path: "Tests",
swiftSettings: [
.define("supportsVisionOS", .when(platforms: [.visionOS])),
])
]
)
16 changes: 8 additions & 8 deletions Source/Helpers/Image+Helpers.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import Foundation

#if os(iOS) || os(tvOS) || os(watchOS) || (swift(>=5.9) && os(visionOS))
import UIKit

public typealias Image = UIImage
#elseif os(macOS)
#if os(macOS)
import Cocoa

public typealias Image = NSImage
#elseif os(iOS) || os(tvOS) || os(watchOS) || supportsVisionOS
import UIKit

public typealias Image = UIImage
#endif

// MARK: - Image.spry
Expand All @@ -20,7 +20,7 @@ public extension Image {
func testData() -> Data? {
#if os(macOS)
return png
#elseif os(iOS) || os(tvOS) || os(watchOS) || (swift(>=5.9) && os(visionOS))
#elseif os(iOS) || os(tvOS) || os(watchOS) || supportsVisionOS
return pngData()
#endif
}
Expand All @@ -45,7 +45,7 @@ public extension Image.spry {
static let testImage2: Image = .init(systemName: "diamond")!
static let testImage3: Image = .init(systemName: "octagon")!
static let testImage4: Image = .init(systemName: "oval")!
#elseif os(iOS) || os(tvOS) || (swift(>=5.9) && os(visionOS))
#elseif os(iOS) || os(tvOS) || supportsVisionOS
static let testImage: Image = Self.image(withColor: .blue)
static let testImage1: Image = Self.image(withColor: .green)
static let testImage2: Image = Self.image(withColor: .red)
Expand All @@ -59,7 +59,7 @@ public extension Image.spry {
color.setFill()
context.fill(rect)
}
#elseif (swift(>=5.9) && os(visionOS))
#elseif supportsVisionOS
let data = UIGraphicsImageRenderer(bounds: rect).pngData { context in
color.setFill()
context.fill(rect)
Expand Down
6 changes: 4 additions & 2 deletions Source/Matcher/XCTAssertThrowsAssertion.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#if (os(macOS) || os(iOS) || (swift(>=5.9) && os(visionOS))) && (arch(x86_64) || arch(arm64))
import CwlPreconditionTesting
import Foundation
import XCTest
Expand All @@ -8,6 +7,7 @@ public func XCTAssertThrowsAssertion(_ message: @autoclosure () -> String = "",
file: StaticString = #filePath,
line: UInt = #line,
_ expression: @escaping () throws -> some Any) {
#if (os(macOS) || os(iOS) || supportsVisionOS) && (arch(x86_64) || arch(arm64))
print(" --- ⚠️ ignore this assertion in console! this is a result of XCTAssertThrowsAssertion ⚠️ --- ")
XCTAssertNotNil(catchBadInstruction(in: {
do {
Expand All @@ -16,6 +16,9 @@ public func XCTAssertThrowsAssertion(_ message: @autoclosure () -> String = "",
XCTFail("catch error: " + error.localizedDescription, file: file, line: line)
}
}), message(), file: file, line: line)
#else
print(" --- ⚠️ this is a result of XCTAssertThrowsAssertion. it is not supported on this platform ⚠️ --- ")
#endif
}

@inline(__always)
Expand All @@ -25,4 +28,3 @@ public func XCTAssertThrowsAssertion(_ expression: @autoclosure @escaping () thr
line: UInt = #line) {
XCTAssertThrowsAssertion(message(), file: file, line: line, expression)
}
#endif
File renamed without changes.
13 changes: 6 additions & 7 deletions Tests/ArgumentTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import XCTest

final class ArgumentTests: XCTestCase {
func test_CustomStringConvertible() {
XCTAssertEqual(Argument.anything.description, "Argument.anything")
XCTAssertEqual(Argument.nonNil.description, "Argument.nonNil")
XCTAssertEqual(Argument.nil.description, "Argument.nil")
XCTAssertEqual(Argument.validator { _ in true }.description, "Argument.validator")
XCTAssertEqual(Argument.closure.description, "Argument.closure")
XCTAssertEqual(Argument.anything.description, "Argument.anything", "Argument.anything")
XCTAssertEqual(Argument.nonNil.description, "Argument.nonNil", "Argument.nonNil")
XCTAssertEqual(Argument.nil.description, "Argument.nil", "Argument.nil")
XCTAssertEqual(Argument.validator { _ in true }.description, "Argument.validator", "Argument.validator")
XCTAssertEqual(Argument.closure.description, "Argument.closure", "Argument.closure")
XCTAssertEqual(Argument.skipped.description, "Argument.skipped", "Argument.skipped")
}

func test_is_equal_args_list() {
Expand All @@ -22,11 +23,9 @@ final class ArgumentTests: XCTestCase {
// when the args lists have different counts
specifiedArgs = []
actualArgs = [1]
#if (os(macOS) || os(iOS) || (swift(>=5.9) && os(visionOS))) && (arch(x86_64) || arch(arm64))
XCTAssertThrowsAssertion {
_ = subjectAction()
}
#endif

// .anything
specifiedArgs = [
Expand Down
Loading

0 comments on commit 798d54f

Please sign in to comment.