diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..410ff6c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +# editorconfig.org + +root = true + +[*] +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c6d6fec --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,42 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - "*" + workflow_dispatch: + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + mac: + name: macOS + strategy: + matrix: + xcode: ["16.4"] + config: ["debug", "release"] + runs-on: macos-15 + steps: + - uses: actions/checkout@v4 + - name: Select Xcode ${{ matrix.xcode }} + run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app + - name: Run ${{ matrix.config }} tests + run: swift test -c ${{ matrix.config }} + + linux: + name: Linux + strategy: + matrix: + swift: + - "6.2" + runs-on: ubuntu-latest + container: swift:${{ matrix.swift }} + steps: + - uses: actions/checkout@v4 + - name: Build + run: swift test diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..84a7d6c --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,25 @@ +on: + push: + branches: + - main + +concurrency: + group: format-${{ github.ref }} + cancel-in-progress: true + +jobs: + swift_format: + name: swift-format + runs-on: macos-15 + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - name: Select Xcode 16.4 + run: sudo xcode-select -s /Applications/Xcode_16.4.app + - name: Format + run: make format + - uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: Run swift-format + branch: "main" diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml deleted file mode 100644 index 796f2bd..0000000 --- a/.github/workflows/swift.yml +++ /dev/null @@ -1,21 +0,0 @@ -# This workflow will build a Swift project -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift - -name: Swift - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -jobs: - test-linux: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: swift-actions/setup-swift@v1 - with: - swift-version: 5.9 - - name: Run tests - run: swift test -v diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c924aad --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +test: + swift test + +format: + find . \ + -path '*/Documentation.docc' -prune -o \ + -name '*.swift' \ + -not -path '*/.*' -print0 \ + | xargs -0 xcrun swift-format --ignore-unparsable-files --in-place diff --git a/Package.swift b/Package.swift index 2d54c64..36f03ef 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.9 +// swift-tools-version: 6.0 import PackageDescription @@ -13,9 +13,6 @@ let package = Package( targets: [ .target( name: "GraphQLPagination", - swiftSettings: [ - .enableExperimentalFeature("StrictConcurrency"), - ] ), .testTarget( name: "GraphQLPaginationTests", diff --git a/Sources/GraphQLPagination/Connection.swift b/Sources/GraphQLPagination/Connection.swift index 86aac35..c7d2566 100644 --- a/Sources/GraphQLPagination/Connection.swift +++ b/Sources/GraphQLPagination/Connection.swift @@ -40,7 +40,7 @@ extension BasicConnection { nodes: [Node], pagination: any GraphPaginatable, cursor: CursorType - ) where Node: GraphCursorable { + ) where Node: GraphCursorable & Sendable { self.init(nodes: nodes, pagination: pagination.pagination, cursor: cursor) } /// Build a connection from nodes for any forward paginatable input. @@ -48,7 +48,7 @@ extension BasicConnection { nodes: [Node], pagination: any GraphForwardPaginatable, cursor: CursorType - ) where Node: GraphCursorable { + ) where Node: GraphCursorable & Sendable { self.init(nodes: nodes, pagination: pagination.pagination, cursor: cursor) } /// Build a connection from nodes with optional pagination input. @@ -56,7 +56,7 @@ extension BasicConnection { nodes: [Node], pagination: GraphPagination?, cursor: CursorType - ) where Node: GraphCursorable { + ) where Node: GraphCursorable & Sendable { let result = EdgeBuilder.build( cursor: cursor, nodes: nodes, @@ -70,5 +70,7 @@ extension BasicConnection { extension BasicConnection: Codable where Node: Codable {} extension BasicConnection: Equatable where Node: Equatable {} +extension BasicConnection: Sendable where Node: Sendable {} extension BasicEdge: Codable where Node: Codable {} extension BasicEdge: Equatable where Node: Equatable {} +extension BasicEdge: Sendable where Node: Sendable {}