Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to Swift 5.9 as the minimum version #59

Merged
merged 2 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,3 @@ jobs:
with:
fail_ci_if_error: true
verbose: true

build-5_4_2:
runs-on: macos-11
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Check Swift version
run: |
sudo xcode-select -s /Applications/Xcode_12.5.1.app/
export TOOLCHAINS=swift
swift --version
- name: Run tests
run: swift test
1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5.9
1 change: 0 additions & 1 deletion .swiftformat
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
--swiftversion 5.7
--exclude .build

# rules
Expand Down
13 changes: 4 additions & 9 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.4
// swift-tools-version: 5.9

import PackageDescription

Expand Down Expand Up @@ -31,13 +31,8 @@ let package = Package(
.process("data/uritemplate-test/extended-tests.json"),
.process("data/uritemplate-test/negative-tests.json"),
]),
],
swiftLanguageVersions: [.v5])

#if swift(>=5.6) || os(macOS) || os(Linux)
package.targets.append(
.executableTarget(
name: "ScreamURITemplateExample",
dependencies: ["ScreamURITemplate"])
)
#endif
dependencies: ["ScreamURITemplate"]),
],
swiftLanguageVersions: [.v5])
6 changes: 1 addition & 5 deletions Sources/ScreamURITemplate/Internal/Components.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@

import Foundation

#if swift(>=5.5)
typealias ComponentBase = Sendable
#else
protocol ComponentBase {}
#endif
typealias ComponentBase = Sendable

protocol Component: ComponentBase {
func expand(variables: [String: VariableValue]) throws -> String
Expand Down
7 changes: 3 additions & 4 deletions Sources/ScreamURITemplate/Internal/ValueFormatting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ func percentEncode(string: String, withAllowedCharacters allowedCharacterSet: Ch

extension StringProtocol {
func formatForTemplateExpansion(variableSpec: VariableSpec, expansionConfiguration: ExpansionConfiguration) throws -> String {
let modifiedValue: String
if let prefixLength = variableSpec.prefixLength() {
modifiedValue = String(prefix(prefixLength))
let modifiedValue = if let prefixLength = variableSpec.prefixLength() {
String(prefix(prefixLength))
} else {
modifiedValue = String(self)
String(self)
}
let encodedExpansion = try percentEncode(string: modifiedValue, withAllowedCharacters: expansionConfiguration.percentEncodingAllowedCharacterSet, allowPercentEncodedTriplets: expansionConfiguration.allowPercentEncodedTriplets)
if expansionConfiguration.named {
Expand Down
4 changes: 1 addition & 3 deletions Sources/ScreamURITemplate/URITemplate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ public struct URITemplate {
}
}

#if swift(>=5.5)
extension URITemplate: Sendable {}
#endif
extension URITemplate: Sendable {}

extension URITemplate: CustomStringConvertible {
public var description: String {
Expand Down
12 changes: 5 additions & 7 deletions Tests/ScreamURITemplateTests/Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ import ScreamURITemplate
import XCTest

class Tests: XCTestCase {
#if swift(>=5.5)
func testSendable() {
let template: URITemplate = "https://api.github.com/repos/{owner}/{repo}/collaborators/{username}"
let sendable = template as Sendable
XCTAssertNotNil(sendable)
}
#endif
func testSendable() {
let template: URITemplate = "https://api.github.com/repos/{owner}/{repo}/collaborators/{username}"
let sendable = template as Sendable
XCTAssertNotNil(sendable)
}

func testCustomStringConvertible() {
let template: URITemplate = "https://api.github.com/repos/{owner}/{repo}/collaborators/{username}"
Expand Down