From b59b98abaabb4dff73f245cab2e13b7a0affcab9 Mon Sep 17 00:00:00 2001 From: Sami Suteria Date: Wed, 21 May 2025 14:08:16 -0700 Subject: [PATCH 01/11] update check to allow for schemas with just federated resolvers --- Sources/Graphiti/Schema/Schema.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Sources/Graphiti/Schema/Schema.swift b/Sources/Graphiti/Schema/Schema.swift index 959b297..72f698e 100644 --- a/Sources/Graphiti/Schema/Schema.swift +++ b/Sources/Graphiti/Schema/Schema.swift @@ -16,11 +16,12 @@ public final class Schema { try component.update(typeProvider: typeProvider, coders: coders) } - guard let query = typeProvider.query else { - fatalError("Query type is required.") + guard typeProvider.query != nil || !typeProvider.federatedResolvers.isEmpty else { + fatalError("Schema must contain at least 1 query or federated resolver") } + schema = try GraphQLSchema( - query: query, + query: typeProvider.query, mutation: typeProvider.mutation, subscription: typeProvider.subscription, types: typeProvider.types, From 0428770c63d67840d79ec794cebe918284736a4b Mon Sep 17 00:00:00 2001 From: Sami Suteria Date: Wed, 21 May 2025 14:54:44 -0700 Subject: [PATCH 02/11] add tests --- .../FederationOnlySchemaTests.swift | 194 ++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 Tests/GraphitiTests/FederationTests/FederationOnlySchemaTests.swift diff --git a/Tests/GraphitiTests/FederationTests/FederationOnlySchemaTests.swift b/Tests/GraphitiTests/FederationTests/FederationOnlySchemaTests.swift new file mode 100644 index 0000000..88fa739 --- /dev/null +++ b/Tests/GraphitiTests/FederationTests/FederationOnlySchemaTests.swift @@ -0,0 +1,194 @@ +import Foundation +import Graphiti +import GraphQL +import NIO +import XCTest + +final class FederationOnlySchemaTests: XCTestCase { + private var group: MultiThreadedEventLoopGroup! + private var api: FederationOnlyAPI! + + struct Profile: Codable { + let name: String + let email: String? + } + + struct User: Codable { + let id: String + + func profile(context: NoContext, args: NoArguments) async throws -> Profile { + if id == "1" { + return Profile(name: "User \(id)", email: nil) + } else { + return Profile(name: "User \(id)", email: "\(id)@example.com") + } + } + + struct Key: Codable { + let id: String + } + } + + struct FederationOnlyResolver { + func user(context: NoContext, key: User.Key) async throws -> User { + User(id: key.id) + } + } + + struct FederationOnlyAPI: API { + var resolver: FederationOnlyResolver + var schema: Schema + } + + static let federatedSDL: String = + """ + type User @key(fields: "id") { + id: String! + profile: Profile! + } + + type Profile { + name: String! + email: String + } + """ + + override func setUpWithError() throws { + let schema = try SchemaBuilder(FederationOnlyResolver.self, NoContext.self) + .setFederatedSDL(to: Self.federatedSDL) + .add { + Type(User.self) { + Field("id", at: \.id) + Field("profile", at: User.profile) + } + .key(at: FederationOnlyResolver.user) { + Argument("id", at: \.id) + } + + Type(Profile.self) { + Field("name", at: \.name) + Field("email", at: \.email) + } + } + .build() + group = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount) + api = FederationOnlyAPI(resolver: FederationOnlyResolver(), schema: schema) + } + + override func tearDownWithError() throws { + try group.syncShutdownGracefully() + group = nil + api = nil + } + + func execute(request: String, variables: [String: Map] = [:]) throws -> GraphQLResult { + try api + .execute( + request: request, + context: NoContext(), + on: group, + variables: variables + ) + .wait() + } + + func testUserFederationSimple() throws { + let representations: [String: Map] = [ + "representations": [ + ["__typename": "User", "id": "1234"], + ], + ] + + let query = + """ + query user($representations: [_Any!]!) { + _entities(representations: $representations) { + ... on User { + id + } + } + } + """ + + try XCTAssertEqual( + execute(request: query, variables: representations), + GraphQLResult(data: [ + "_entities": [ + [ + "id": "1234" + ] + ] + ]) + ) + } + + func testUserFederationNested() throws { + let representations: [String: Map] = [ + "representations": [ + ["__typename": "User", "id": "1234"], + ], + ] + + let query = + """ + query user($representations: [_Any!]!) { + _entities(representations: $representations) { + ... on User { + id + profile { name, email } + } + } + } + """ + + try XCTAssertEqual( + execute(request: query, variables: representations), + GraphQLResult(data: [ + "_entities": [ + [ + "id": "1234", + "profile": [ + "name": "User 1234", + "email": "1234@example.com" + ] + ] + ] + ]) + ) + } + + func testUserFederationNestedOptional() throws { + let representations: [String: Map] = [ + "representations": [ + ["__typename": "User", "id": "1"], + ], + ] + + let query = + """ + query user($representations: [_Any!]!) { + _entities(representations: $representations) { + ... on User { + id + profile { name, email } + } + } + } + """ + + try XCTAssertEqual( + execute(request: query, variables: representations), + GraphQLResult(data: [ + "_entities": [ + [ + "id": "1", + "profile": [ + "name": "User 1", + "email": .null + ] + ] + ] + ]) + ) + } +} From 25a3a7cd5824ac78971a305293191070a5f642ce Mon Sep 17 00:00:00 2001 From: Sami Suteria Date: Wed, 21 May 2025 15:06:41 -0700 Subject: [PATCH 03/11] throw error instead of fatal error --- Sources/Graphiti/Schema/Schema.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/Graphiti/Schema/Schema.swift b/Sources/Graphiti/Schema/Schema.swift index 72f698e..36dcb53 100644 --- a/Sources/Graphiti/Schema/Schema.swift +++ b/Sources/Graphiti/Schema/Schema.swift @@ -1,6 +1,10 @@ import GraphQL import NIO +public struct SchemaError: Error, Equatable { + let description: String +} + public final class Schema { public let schema: GraphQLSchema @@ -17,7 +21,7 @@ public final class Schema { } guard typeProvider.query != nil || !typeProvider.federatedResolvers.isEmpty else { - fatalError("Schema must contain at least 1 query or federated resolver") + throw SchemaError(description: "Schema must contain at least 1 query or federated resolver") } schema = try GraphQLSchema( From c4baf420e5f0c427e86062d809c826f720241e75 Mon Sep 17 00:00:00 2001 From: Sami Suteria Date: Wed, 21 May 2025 15:06:53 -0700 Subject: [PATCH 04/11] add test for schema with no query or federated resolvers --- Tests/GraphitiTests/SchemaTests.swift | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Tests/GraphitiTests/SchemaTests.swift b/Tests/GraphitiTests/SchemaTests.swift index ef2c79f..b4db8ce 100644 --- a/Tests/GraphitiTests/SchemaTests.swift +++ b/Tests/GraphitiTests/SchemaTests.swift @@ -140,6 +140,29 @@ class SchemaTests: XCTestCase { ]) ) } + + func testSchemaWithNoQuery() { + struct User: Codable { + let id: String + } + + struct TestResolver {} + + do { + let _ = try Schema { + Type(User.self) { + Field("id", at: \.id) + } + } + } catch { + XCTAssertEqual( + error as? SchemaError, + SchemaError( + description: "Schema must contain at least 1 query or federated resolver" + ) + ) + } + } } private class TestAPI: API { From 3930b12540715dcb542985771587a95cba0ff16e Mon Sep 17 00:00:00 2001 From: Sami Suteria Date: Wed, 21 May 2025 15:12:48 -0700 Subject: [PATCH 05/11] run swift format --- .../Graphiti/Federation/Key/Type+Key.swift | 20 ++-- Sources/Graphiti/Schema/Schema.swift | 4 +- .../SchemaBuilders/SchemaBuilder.swift | 14 +-- .../FederationOnlySchemaTests.swift | 104 +++++++++--------- .../HelloWorldAsyncTests.swift | 2 +- 5 files changed, 73 insertions(+), 71 deletions(-) diff --git a/Sources/Graphiti/Federation/Key/Type+Key.swift b/Sources/Graphiti/Federation/Key/Type+Key.swift index 0215547..d1e8443 100644 --- a/Sources/Graphiti/Federation/Key/Type+Key.swift +++ b/Sources/Graphiti/Federation/Key/Type+Key.swift @@ -1,7 +1,6 @@ import GraphQL public extension Type { - @discardableResult /// Define and add the federated key to this type. /// /// For more information, see https://www.apollographql.com/docs/federation/entities @@ -9,6 +8,7 @@ public extension Type { /// - function: The resolver function used to load this entity based on the key value. /// - _: The key value. The name of this argument must match a Type field. /// - Returns: Self for chaining. + @discardableResult func key( at function: @escaping AsyncResolve, @ArgumentComponentBuilder _ argument: () -> ArgumentComponent @@ -17,7 +17,6 @@ public extension Type { return self } - @discardableResult /// Define and add the federated key to this type. /// /// For more information, see https://www.apollographql.com/docs/federation/entities @@ -25,6 +24,7 @@ public extension Type { /// - function: The resolver function used to load this entity based on the key value. /// - _: The key values. The names of these arguments must match Type fields. /// - Returns: Self for chaining. + @discardableResult func key( at function: @escaping AsyncResolve, @ArgumentComponentBuilder _ arguments: () @@ -34,7 +34,6 @@ public extension Type { return self } - @discardableResult /// Define and add the federated key to this type. /// /// For more information, see https://www.apollographql.com/docs/federation/entities @@ -42,6 +41,7 @@ public extension Type { /// - function: The resolver function used to load this entity based on the key value. /// - _: The key value. The name of this argument must match a Type field. /// - Returns: Self for chaining. + @discardableResult func key( at function: @escaping SimpleAsyncResolve, @ArgumentComponentBuilder _ argument: () -> ArgumentComponent @@ -50,7 +50,6 @@ public extension Type { return self } - @discardableResult /// Define and add the federated key to this type. /// /// For more information, see https://www.apollographql.com/docs/federation/entities @@ -58,6 +57,7 @@ public extension Type { /// - function: The resolver function used to load this entity based on the key value. /// - _: The key values. The names of these arguments must match Type fields. /// - Returns: Self for chaining. + @discardableResult func key( at function: @escaping SimpleAsyncResolve, @ArgumentComponentBuilder _ arguments: () @@ -67,7 +67,6 @@ public extension Type { return self } - @discardableResult /// Define and add the federated key to this type. /// /// For more information, see https://www.apollographql.com/docs/federation/entities @@ -75,6 +74,7 @@ public extension Type { /// - function: The resolver function used to load this entity based on the key value. /// - _: The key value. The name of this argument must match a Type field. /// - Returns: Self for chaining. + @discardableResult func key( at function: @escaping SyncResolve, @ArgumentComponentBuilder _ arguments: () @@ -84,7 +84,6 @@ public extension Type { return self } - @discardableResult /// Define and add the federated key to this type. /// /// For more information, see https://www.apollographql.com/docs/federation/entities @@ -92,6 +91,7 @@ public extension Type { /// - function: The resolver function used to load this entity based on the key value. /// - _: The key values. The names of these arguments must match Type fields. /// - Returns: Self for chaining. + @discardableResult func key( at function: @escaping SyncResolve, @ArgumentComponentBuilder _ argument: () -> ArgumentComponent @@ -102,8 +102,6 @@ public extension Type { } public extension Type { - @available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *) - @discardableResult /// Define and add the federated key to this type. /// /// For more information, see https://www.apollographql.com/docs/federation/entities @@ -111,6 +109,8 @@ public extension Type { /// - function: The resolver function used to load this entity based on the key value. /// - _: The key value. The name of this argument must match a Type field. /// - Returns: Self for chaining. + @available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *) + @discardableResult func key( at function: @escaping ConcurrentResolve, @ArgumentComponentBuilder _ argument: () -> ArgumentComponent @@ -119,8 +119,6 @@ public extension Type { return self } - @available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *) - @discardableResult /// Define and add the federated key to this type. /// /// For more information, see https://www.apollographql.com/docs/federation/entities @@ -128,6 +126,8 @@ public extension Type { /// - function: The resolver function used to load this entity based on the key value. /// - _: The key values. The names of these arguments must match Type fields. /// - Returns: Self for chaining. + @available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *) + @discardableResult func key( at function: @escaping ConcurrentResolve, @ArgumentComponentBuilder _ arguments: () -> [ArgumentComponent] diff --git a/Sources/Graphiti/Schema/Schema.swift b/Sources/Graphiti/Schema/Schema.swift index 36dcb53..590b860 100644 --- a/Sources/Graphiti/Schema/Schema.swift +++ b/Sources/Graphiti/Schema/Schema.swift @@ -21,7 +21,9 @@ public final class Schema { } guard typeProvider.query != nil || !typeProvider.federatedResolvers.isEmpty else { - throw SchemaError(description: "Schema must contain at least 1 query or federated resolver") + throw SchemaError( + description: "Schema must contain at least 1 query or federated resolver" + ) } schema = try GraphQLSchema( diff --git a/Sources/Graphiti/SchemaBuilders/SchemaBuilder.swift b/Sources/Graphiti/SchemaBuilders/SchemaBuilder.swift index b96a2d3..55ea3f8 100644 --- a/Sources/Graphiti/SchemaBuilders/SchemaBuilder.swift +++ b/Sources/Graphiti/SchemaBuilders/SchemaBuilder.swift @@ -27,19 +27,19 @@ public final class SchemaBuilder { subscriptionFields = [] } - @discardableResult /// Allows for setting API encoders and decoders with customized settings. /// - Parameter newCoders: The new coders to use /// - Returns: This object for method chaining + @discardableResult public func setCoders(to newCoders: Coders) -> Self { coders = newCoders return self } - @discardableResult /// Allows for setting SDL for federated subgraphs. /// - Parameter newSDL: The new SDL to use /// - Returns: This object for method chaining + @discardableResult public func setFederatedSDL(to newSDL: String) -> Self { federatedSDL = newSDL return self @@ -63,10 +63,10 @@ public final class SchemaBuilder { return self } - @discardableResult /// Adds multiple query operation definitions to the schema. /// - Parameter component: The query operations to add /// - Returns: This object for method chaining + @discardableResult public func add( @TypeComponentBuilder _ components: () -> [TypeComponent] @@ -77,10 +77,10 @@ public final class SchemaBuilder { return self } - @discardableResult /// Adds multiple query operation definitions to the schema. /// - Parameter component: The query operations to add /// - Returns: This object for method chaining + @discardableResult public func addQuery( @FieldComponentBuilder _ fields: () -> [FieldComponent] @@ -91,10 +91,10 @@ public final class SchemaBuilder { return self } - @discardableResult /// Adds multiple mutation operation definitions to the schema. /// - Parameter component: The query operations to add /// - Returns: This object for method chaining + @discardableResult public func addMutation( @FieldComponentBuilder _ fields: () -> [FieldComponent] @@ -105,10 +105,10 @@ public final class SchemaBuilder { return self } - @discardableResult /// Adds multiple subscription operation definitions to the schema. /// - Parameter component: The query operations to add /// - Returns: This object for method chaining + @discardableResult public func addSubscription( @FieldComponentBuilder _ fields: () -> [FieldComponent] @@ -119,10 +119,10 @@ public final class SchemaBuilder { return self } - @discardableResult /// Adds multiple type, query, mutation, and subscription definitions using partial schemas to the schema. /// - Parameter partials: Partial schemas that declare types, query, mutation, and/or subscription definiton /// - Returns: Thie object for method chaining + @discardableResult public func use(partials: [PartialSchema]) -> Self { for type in partials.flatMap({ $0.types }) { typeComponents.append(type) diff --git a/Tests/GraphitiTests/FederationTests/FederationOnlySchemaTests.swift b/Tests/GraphitiTests/FederationTests/FederationOnlySchemaTests.swift index 88fa739..9092c8d 100644 --- a/Tests/GraphitiTests/FederationTests/FederationOnlySchemaTests.swift +++ b/Tests/GraphitiTests/FederationTests/FederationOnlySchemaTests.swift @@ -16,7 +16,7 @@ final class FederationOnlySchemaTests: XCTestCase { struct User: Codable { let id: String - func profile(context: NoContext, args: NoArguments) async throws -> Profile { + func profile(context _: NoContext, args _: NoArguments) async throws -> Profile { if id == "1" { return Profile(name: "User \(id)", email: nil) } else { @@ -30,7 +30,7 @@ final class FederationOnlySchemaTests: XCTestCase { } struct FederationOnlyResolver { - func user(context: NoContext, key: User.Key) async throws -> User { + func user(context _: NoContext, key: User.Key) async throws -> User { User(id: key.id) } } @@ -41,17 +41,17 @@ final class FederationOnlySchemaTests: XCTestCase { } static let federatedSDL: String = - """ - type User @key(fields: "id") { - id: String! - profile: Profile! - } + """ + type User @key(fields: "id") { + id: String! + profile: Profile! + } - type Profile { - name: String! - email: String - } - """ + type Profile { + name: String! + email: String + } + """ override func setUpWithError() throws { let schema = try SchemaBuilder(FederationOnlyResolver.self, NoContext.self) @@ -100,24 +100,24 @@ final class FederationOnlySchemaTests: XCTestCase { ] let query = - """ - query user($representations: [_Any!]!) { - _entities(representations: $representations) { - ... on User { - id - } - } - } - """ + """ + query user($representations: [_Any!]!) { + _entities(representations: $representations) { + ... on User { + id + } + } + } + """ try XCTAssertEqual( execute(request: query, variables: representations), GraphQLResult(data: [ "_entities": [ [ - "id": "1234" - ] - ] + "id": "1234", + ], + ], ]) ) } @@ -130,16 +130,16 @@ final class FederationOnlySchemaTests: XCTestCase { ] let query = - """ - query user($representations: [_Any!]!) { - _entities(representations: $representations) { - ... on User { - id - profile { name, email } - } - } - } - """ + """ + query user($representations: [_Any!]!) { + _entities(representations: $representations) { + ... on User { + id + profile { name, email } + } + } + } + """ try XCTAssertEqual( execute(request: query, variables: representations), @@ -149,10 +149,10 @@ final class FederationOnlySchemaTests: XCTestCase { "id": "1234", "profile": [ "name": "User 1234", - "email": "1234@example.com" - ] - ] - ] + "email": "1234@example.com", + ], + ], + ], ]) ) } @@ -165,16 +165,16 @@ final class FederationOnlySchemaTests: XCTestCase { ] let query = - """ - query user($representations: [_Any!]!) { - _entities(representations: $representations) { - ... on User { - id - profile { name, email } - } - } - } - """ + """ + query user($representations: [_Any!]!) { + _entities(representations: $representations) { + ... on User { + id + profile { name, email } + } + } + } + """ try XCTAssertEqual( execute(request: query, variables: representations), @@ -184,10 +184,10 @@ final class FederationOnlySchemaTests: XCTestCase { "id": "1", "profile": [ "name": "User 1", - "email": .null - ] - ] - ] + "email": .null, + ], + ], + ], ]) ) } diff --git a/Tests/GraphitiTests/HelloWorldTests/HelloWorldAsyncTests.swift b/Tests/GraphitiTests/HelloWorldTests/HelloWorldAsyncTests.swift index 90ead0c..186d498 100644 --- a/Tests/GraphitiTests/HelloWorldTests/HelloWorldAsyncTests.swift +++ b/Tests/GraphitiTests/HelloWorldTests/HelloWorldAsyncTests.swift @@ -318,8 +318,8 @@ class HelloWorldAsyncTests: XCTestCase { } } -@available(macOS 12, iOS 15, watchOS 8, tvOS 15, *) /// A very simple publish/subscriber used for testing +@available(macOS 12, iOS 15, watchOS 8, tvOS 15, *) class SimplePubSub { private var subscribers: [Subscriber] From 76f0c88722527a506c22f3ac284bb345e583a72a Mon Sep 17 00:00:00 2001 From: Sami Suteria Date: Thu, 22 May 2025 11:24:19 -0500 Subject: [PATCH 06/11] update action version --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index df28140..9a260c1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,7 +51,7 @@ jobs: --format html \ --output-dir=.test-coverage - name: Upload test coverage html - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: test-coverage-report path: .test-coverage From e8d28ed477c83a95fb74cee557ae5422a117bdc2 Mon Sep 17 00:00:00 2001 From: Sami Suteria Date: Fri, 23 May 2025 12:59:31 -0500 Subject: [PATCH 07/11] remove parallel --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9a260c1..1025b44 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,7 +41,7 @@ jobs: - uses: swift-actions/setup-swift@v2 - uses: actions/checkout@v3 - name: Test - run: swift test --parallel --enable-code-coverage + run: swift test --enable-code-coverage - name: Get test coverage html run: | llvm-cov show \ From 70f62916a56f70a50e600f831954c6cdfc213915 Mon Sep 17 00:00:00 2001 From: Sami Suteria Date: Sat, 7 Jun 2025 13:12:30 -0700 Subject: [PATCH 08/11] update workflow --- .github/workflows/build.yml | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1025b44..d490d99 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,7 +32,7 @@ jobs: xcode-version: latest-stable - uses: actions/checkout@v3 - name: Build and test - run: swift test --parallel --enable-test-discovery + run: swift test --parallel linux: name: Test on Linux @@ -42,19 +42,20 @@ jobs: - uses: actions/checkout@v3 - name: Test run: swift test --enable-code-coverage - - name: Get test coverage html - run: | - llvm-cov show \ - $(swift build --show-bin-path)/GraphitiPackageTests.xctest \ - --instr-profile $(swift build --show-bin-path)/codecov/default.profdata \ - --ignore-filename-regex="\.build|Tests" \ - --format html \ - --output-dir=.test-coverage - - name: Upload test coverage html - uses: actions/upload-artifact@v4 - with: - name: test-coverage-report - path: .test-coverage + # TODO: Add test coverage, but it's currently not working with Swift 6.1.0 + # - name: Get test coverage html + # run: | + # llvm-cov show \ + # $(swift build --show-bin-path)/GraphitiPackageTests.xctest \ + # --instr-profile $(swift build --show-bin-path)/codecov/default.profdata \ + # --ignore-filename-regex="\.build|Tests" \ + # --format html \ + # --output-dir=.test-coverage + # - name: Upload test coverage html + # uses: actions/upload-artifact@v4 + # with: + # name: test-coverage-report + # path: .test-coverage backcompat-ubuntu-22_04: name: Test Swift ${{ matrix.swift }} on Ubuntu 22.04 From ccfb34aeaa63bccc1c7fe2415d57b8f3a51c7b4c Mon Sep 17 00:00:00 2001 From: Sami Suteria Date: Sat, 7 Jun 2025 13:23:19 -0700 Subject: [PATCH 09/11] Trigger Build From 199ba6e088b194f9b3461d11db85b98957004e09 Mon Sep 17 00:00:00 2001 From: Sami Suteria Date: Sat, 7 Jun 2025 13:27:07 -0700 Subject: [PATCH 10/11] update workflow --- .github/workflows/build.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d490d99..9b25b0a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,13 +35,18 @@ jobs: run: swift test --parallel linux: - name: Test on Linux + name: Test Swift ${{ matrix.swift }} on Ubuntu Latest runs-on: ubuntu-latest + strategy: + matrix: + swift: ["6.0", "6.1"] steps: - uses: swift-actions/setup-swift@v2 + with: + swift-version: ${{ matrix.swift }} - uses: actions/checkout@v3 - name: Test - run: swift test --enable-code-coverage + run: swift test --parallel # TODO: Add test coverage, but it's currently not working with Swift 6.1.0 # - name: Get test coverage html # run: | From 7e442e13765cd5d26fca0a7d4939ebea4199e38d Mon Sep 17 00:00:00 2001 From: Sami Suteria Date: Sat, 7 Jun 2025 13:34:09 -0700 Subject: [PATCH 11/11] update workflow --- .github/workflows/build.yml | 57 ++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9b25b0a..c002be5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,44 +35,35 @@ jobs: run: swift test --parallel linux: - name: Test Swift ${{ matrix.swift }} on Ubuntu Latest + name: Test Swift ${{ matrix.swift }} runs-on: ubuntu-latest + container: + image: swift:${{ matrix.swift }} strategy: matrix: - swift: ["6.0", "6.1"] + swift: ["5.8", "5.9", "5.10", "6.0", "6.1"] steps: - - uses: swift-actions/setup-swift@v2 - with: - swift-version: ${{ matrix.swift }} - - uses: actions/checkout@v3 - - name: Test - run: swift test --parallel - # TODO: Add test coverage, but it's currently not working with Swift 6.1.0 - # - name: Get test coverage html - # run: | - # llvm-cov show \ - # $(swift build --show-bin-path)/GraphitiPackageTests.xctest \ - # --instr-profile $(swift build --show-bin-path)/codecov/default.profdata \ - # --ignore-filename-regex="\.build|Tests" \ - # --format html \ - # --output-dir=.test-coverage - # - name: Upload test coverage html - # uses: actions/upload-artifact@v4 - # with: - # name: test-coverage-report - # path: .test-coverage - - backcompat-ubuntu-22_04: - name: Test Swift ${{ matrix.swift }} on Ubuntu 22.04 - runs-on: ubuntu-22.04 - strategy: - matrix: - swift: ["5.8", "5.9", "5.10"] - steps: - - uses: swift-actions/setup-swift@v2 - with: - swift-version: ${{ matrix.swift }} - uses: actions/checkout@v3 - name: Test run: swift test --parallel + # TODO: Add test coverage upload but it's currently not working with Swift 6.1.0/Ubuntu-latest + # test-coverage: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v3 + # - name: Test + # run: swift test --parallel --enable-code-coverage + # - name: Get test coverage html + # run: | + # llvm-cov show \ + # $(swift build --show-bin-path)/GraphitiPackageTests.xctest \ + # --instr-profile $(swift build --show-bin-path)/codecov/default.profdata \ + # --ignore-filename-regex="\.build|Tests" \ + # --format html \ + # --output-dir=.test-coverage + # - name: Upload test coverage html + # uses: actions/upload-artifact@v4 + # with: + # name: test-coverage-report + # path: .test-coverage