diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..4e4e097 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,27 @@ +name: Tests + +on: + pull_request: + branches: + - main + push: + branches: + - main + +jobs: + build-and-test: + runs-on: macos-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Swift + uses: swift-actions/setup-swift@v2 + with: + swift-version: '6.0' + + - name: Build + run: swift build --build-tests + + - name: Run tests + run: swift test diff --git a/Package.swift b/Package.swift index e308ca1..b8687ff 100644 --- a/Package.swift +++ b/Package.swift @@ -21,28 +21,20 @@ let package = Package( name: "QuickLayout", targets: ["QuickLayout"] ), - .library( - name: "QuickLayoutCore", - targets: ["QuickLayoutCore"] - ), .library( name: "FastResultBuilder", targets: ["FastResultBuilder"] ), - .library( - name: "QuickLayoutBridge", - targets: ["QuickLayoutBridge"] - ), ], dependencies: [ - .package(url: "https://github.com/apple/swift-syntax.git", from: "600.0.0") + .package(url: "https://github.com/apple/swift-syntax.git", from: "602.0.0"), ], targets: [ .target( name: "QuickLayout", dependencies: [ "QuickLayoutMacro", - "QuickLayoutBridge", + .target(name: "QuickLayoutBridge", condition: .when(platforms: [.iOS])), ], path: "Sources/QuickLayout/QuickLayout", exclude: [ @@ -55,11 +47,11 @@ let package = Package( .product(name: "SwiftSyntaxMacros", package: "swift-syntax"), .product(name: "SwiftCompilerPlugin", package: "swift-syntax"), ], - path: "Sources/QuickLayout/QuickLayoutMacro", + path: "Sources/QuickLayout/QuickLayoutMacro" ), .target( name: "QuickLayoutCore", - path: "Sources/QuickLayout/QuickLayoutCore", + path: "Sources/QuickLayout/QuickLayoutCore" ), .target( name: "FastResultBuilder", @@ -70,12 +62,23 @@ let package = Package( ), .target( name: "QuickLayoutBridge", - dependencies: ["FastResultBuilder", "QuickLayoutCore"], + dependencies: [ + "FastResultBuilder", + .target(name: "QuickLayoutCore", condition: .when(platforms: [.iOS])), + ], path: "Sources/QuickLayout/QuickLayoutBridge", exclude: [ "__server_snapshot_tests__", "__tests__", ] ), - ], + .testTarget( + name: "QuickLayoutMacroTests", + dependencies: [ + "QuickLayoutMacro", + .product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"), + ], + path: "Sources/QuickLayout/QuickLayoutMacroTests" + ) + ] ) diff --git a/Sources/QuickLayout/QuickLayout/QuickLayout.swift b/Sources/QuickLayout/QuickLayout/QuickLayout.swift index c9d63d9..cf4e5cf 100644 --- a/Sources/QuickLayout/QuickLayout/QuickLayout.swift +++ b/Sources/QuickLayout/QuickLayout/QuickLayout.swift @@ -5,4 +5,6 @@ * LICENSE file in the root directory of this source tree. */ +#if canImport(QuickLayoutBridge) @_exported import QuickLayoutBridge +#endif diff --git a/Sources/QuickLayout/QuickLayoutMacroTests/QuickLayoutTests.swift b/Sources/QuickLayout/QuickLayoutMacroTests/QuickLayoutTests.swift index d090901..2c8aa66 100644 --- a/Sources/QuickLayout/QuickLayoutMacroTests/QuickLayoutTests.swift +++ b/Sources/QuickLayout/QuickLayoutMacroTests/QuickLayoutTests.swift @@ -5,10 +5,11 @@ * LICENSE file in the root directory of this source tree. */ -import QuickLayoutMacro import SwiftSyntaxMacros import SwiftSyntaxMacrosTestSupport import XCTest +#if canImport(QuickLayoutMacro) +@testable import QuickLayoutMacro // patternlint-disable meta-subclass-view @@ -476,3 +477,4 @@ class QuickLayoutTests: XCTestCase { ) } } +#endif