Skip to content

Commit

Permalink
swift-test.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
NikSativa committed Sep 26, 2024
1 parent e6d4592 commit f01bf80
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 124 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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.0"
runsOn: firebreak
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: swift-actions/[email protected]
# 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 }}
36 changes: 0 additions & 36 deletions [email protected]

This file was deleted.

36 changes: 0 additions & 36 deletions [email protected]

This file was deleted.

36 changes: 0 additions & 36 deletions [email protected]

This file was deleted.

2 changes: 1 addition & 1 deletion Source/Helpers/Image+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public extension Image.spry {
color.setFill()
context.fill(rect)
}
#elseif (swift(>=5.9) && os(visionOS))
#elseif(swift(>=5.9) && os(visionOS))
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) || (swift(>=5.9) && os(visionOS))) && (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
18 changes: 9 additions & 9 deletions Tests/CrossPlatformTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private enum Screen {
}
}

#elseif (swift(>=5.9) && os(visionOS))
#elseif(swift(>=5.9) && os(visionOS))
public enum Screen {
/// visionOS doesn't have a screen scale, so we'll just use 2x for Tests.
/// override it on your own risk.
Expand Down Expand Up @@ -63,7 +63,7 @@ private struct PlatformImage {
return sdk.png
}

#elseif (swift(>=5.9) && os(visionOS))
#elseif(swift(>=5.9) && os(visionOS))
init?(data: Data) {
let scale = syncMainThread { Screen.scale }

Expand Down Expand Up @@ -120,23 +120,23 @@ private extension NSImage {
@inline(__always)
private func syncMainThread<T: Sendable>(_ callback: @MainActor () -> T) -> T {
if Thread.isMainThread {
MainActor.assumeIsolated {
callback()
return MainActor.assumeIsolated {
return callback()
}
} else {
DispatchQueue.main.sync {
callback()
return DispatchQueue.main.sync {
return callback()
}
}
}
#else
@inline(__always)
private func syncMainThread<T>(_ callback: @MainActor () -> T) -> T {
if Thread.isMainThread {
callback()
return callback()
} else {
DispatchQueue.main.sync {
callback()
return DispatchQueue.main.sync {
return callback()
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions Tests/StubbableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,8 @@ final class StubbableTests: XCTestCase {
func test_on_a_class() {
StubbableTestHelper.stub(.classFunction).andReturn("fallbackValue")
StubbableTestHelper.resetStubs()
#if (os(macOS) || os(iOS) || (swift(>=5.9) && os(visionOS))) && (arch(x86_64) || arch(arm64))

XCTAssertThrowsAssertion(StubbableTestHelper.classFunction())
#endif

StubbableTestHelper.stub(.classFunction).andReturn("fallbackValue")
XCTAssertEqual(StubbableTestHelper.classFunction(), "fallbackValue")
Expand Down Expand Up @@ -377,9 +376,8 @@ final class StubbableTests: XCTestCase {

func test_class_version_spot_check() {
StubbableTestHelper.stub(.classFunction).andReturn("original return value")
#if (os(macOS) || os(iOS) || (swift(>=5.9) && os(visionOS))) && (arch(x86_64) || arch(arm64))

XCTAssertThrowsAssertion(StubbableTestHelper.stub(.classFunction).andReturn("original return value"))
#endif

let newReturnValue = "new return value"
StubbableTestHelper.stubAgain(.classFunction).andReturn(newReturnValue)
Expand Down

0 comments on commit f01bf80

Please sign in to comment.