Skip to content

Commit

Permalink
Support Swift 6.
Browse files Browse the repository at this point in the history
  • Loading branch information
YOCKOW committed Oct 27, 2024
1 parent be781b0 commit c728a3e
Show file tree
Hide file tree
Showing 12 changed files with 814 additions and 46 deletions.
64 changes: 57 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ on:
- '**'
paths:
- '**/*.swift'
- '**/*.c'
- '**/*.h'
- '.github/workflows/*.yml'
pull_request:
paths:
- '**/*.swift'
- '**/*.c'
- '**/*.h'
- '.github/workflows/*.yml'
jobs:
test:
Expand All @@ -21,27 +25,65 @@ jobs:
matrix:
os:
- ubuntu-22.04
- macOS-12
- ubuntu-24.04
- macOS-14
- macOS-15
swift-version:
- '6.0.1'
- '5.10.1'
- '5.10'
swift-compat-ver:
- '6'
- '5'
# - '4.2'
# - '4'
exclude:
- os: ubuntu-22.04
swift-version: '5.10'
- os: ubuntu-24.04
swift-version: '5.10'
- os: macOS-14
swift-version: '5.10.1'
- os: macOS-15
swift-version: '5.10.1'
- os: macOS-15
swift-version: '5.10'
- swift-version: '5.10.1'
swift-compat-ver: '6'
- swift-version: '5.10'
swift-compat-ver: '6'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install dependencies
if: runner.os == 'Linux'
run: |
sudo apt update
sudo apt install libcurl4-openssl-dev
- uses: actions/checkout@v4
- name: Use a cache for ".build" directory.
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: .build
key: build-${{ github.workspace }}-${{ runner.os }}-${{ matrix.swift-compat-ver }}-${{ hashFiles('**/*.swift') }}
key: build-${{ github.workspace }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.swift-version }}-${{ matrix.swift-compat-ver }}-${{ hashFiles('**/*.swift') }}
restore-keys: |
build-${{ github.workspace }}-${{ runner.os }}-${{ matrix.swift-compat-ver }}-
build-${{ github.workspace }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.swift-version }}-${{ matrix.swift-compat-ver }}-
build-${{ github.workspace }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.swift-version }}-
build-${{ github.workspace }}-${{ runner.os }}-${{ matrix.os }}-
build-${{ github.workspace }}-${{ runner.os }}-
build-${{ github.workspace }}-
- uses: YOCKOW/Action-setup-swift@main
with:
swift-version: '5.7'
swift-version: ${{ matrix.swift-version }}
## NEEDS WORKAROUND FOR https://github.com/swiftlang/swift-package-manager/issues/8064
# DEBUG mode
- name: Build with debug mode.
id: debug_build
run: swift build --configuration debug -Xswiftc -swift-version -Xswiftc ${{ matrix.swift-compat-ver }}
continue-on-error: true
- name: Retry build with debug mode if necessary
if: steps.debug_build.outcome == 'failure'
run: swift build --configuration debug -Xswiftc -swift-version -Xswiftc ${{ matrix.swift-compat-ver }}
continue-on-error: true
- name: Test with debug mode.
id: debug_test
run: swift test --configuration debug -Xswiftc -swift-version -Xswiftc ${{ matrix.swift-compat-ver }}
Expand All @@ -52,6 +94,14 @@ jobs:
rm -rf $(cd .build/debug && pwd -P)
swift test --configuration debug -Xswiftc -swift-version -Xswiftc ${{ matrix.swift-compat-ver }}
# RELEASE mode
- name: Build with release mode.
id: release_build
run: swift build --configuration release -Xswiftc -enable-testing -Xswiftc -swift-version -Xswiftc ${{ matrix.swift-compat-ver }}
continue-on-error: true
- name: Retry build with release mode if necessary
if: steps.release_build.outcome == 'failure'
run: swift build --configuration release -Xswiftc -enable-testing -Xswiftc -swift-version -Xswiftc ${{ matrix.swift-compat-ver }}
continue-on-error: true
- name: Test with release mode.
id: release_test
run: swift test --configuration release -Xswiftc -enable-testing -Xswiftc -swift-version -Xswiftc ${{ matrix.swift-compat-ver }}
Expand All @@ -60,4 +110,4 @@ jobs:
if: steps.release_test.outcome == 'failure'
run: |
rm -rf $(cd .build/release && pwd -P)
swift test --configuration release -Xswiftc -swift-version -Xswiftc ${{ matrix.swift-compat-ver }}
swift test --configuration release -Xswiftc -swift-version -Xswiftc ${{ matrix.swift-compat-ver }}
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The MIT License (MIT)
Copyright (c) 2021-2023 YOCKOW
Copyright (c) 2021-2024 YOCKOW

Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
Expand Down
14 changes: 7 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ let package = Package(
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url:"https://github.com/YOCKOW/SwiftNetworkGear.git", "0.16.0"..<"2.0.0"),
.package(url:"https://github.com/YOCKOW/SwiftPredicate.git", from: "1.2.1"),
.package(url:"https://github.com/YOCKOW/SwiftRanges.git", from: "3.1.2"),
.package(url:"https://github.com/YOCKOW/SwiftUnicodeSupplement.git", from: "1.3.0"),
.package(url:"https://github.com/YOCKOW/SwiftXHTML.git", from: "2.6.0"),
.package(url:"https://github.com/YOCKOW/ySwiftExtensions.git", from: "1.9.0"),
.package(url:"https://github.com/YOCKOW/SwiftNetworkGear.git", "0.19.1"..<"2.0.0"),
.package(url:"https://github.com/YOCKOW/SwiftPredicate.git", from: "1.3.0"),
.package(url:"https://github.com/YOCKOW/SwiftRanges.git", from: "3.2.1"),
.package(url:"https://github.com/YOCKOW/SwiftUnicodeSupplement.git", from: "1.5.0"),
.package(url:"https://github.com/YOCKOW/SwiftXHTML.git", from: "2.8.0"),
.package(url:"https://github.com/YOCKOW/ySwiftExtensions.git", from: "1.11.1"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand All @@ -47,7 +47,7 @@ let package = Package(
]
),
],
swiftLanguageVersions: [.v5]
swiftLanguageVersions: [.v5, .version("6")]
)

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ It does *not* provide functions like a mailer.

# Requirements

- Swift 5
- Swift 5, 6
- macOS(>=10.15) or Linux

## Dependencies
Expand Down
4 changes: 2 additions & 2 deletions Sources/MailMessage/Body.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* *************************************************************************************************
Body.swift
© 2021 YOCKOW.
© 2021,2024 YOCKOW.
Licensed under MIT License.
See "LICENSE.txt" for more information.
************************************************************************************************ */
Expand Down Expand Up @@ -28,7 +28,7 @@ public protocol MainBody: Body {
}

/// Represents plain text.
public struct PlainText: MainBody {
public struct PlainText: MainBody, Sendable {
/// The mail message.
public let text: String

Expand Down
6 changes: 3 additions & 3 deletions Sources/MailMessage/ContentTransferEncoding.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* *************************************************************************************************
ContentTransferEncoding.swift
© 2021 YOCKOW.
© 2021,2024 YOCKOW.
Licensed under MIT License.
See "LICENSE.txt" for more information.
************************************************************************************************ */

import Foundation
import NetworkGear

public enum ContentTransferEncodingError: Error {
public enum ContentTransferEncodingError: Error, Sendable {
case cannotEncode
case non7bitRepresentation
case unexpectedError
Expand Down Expand Up @@ -88,7 +88,7 @@ public final class ContentTransferEncodingStream: MIMESafeInputStream {
}
}

private static let _encoders: [ContentTransferEncoding: (ContentTransferEncodingStream) throws -> MIMESafeData?] = [
private static let _encoders: [ContentTransferEncoding: @Sendable (ContentTransferEncodingStream) throws -> MIMESafeData?] = [
._7bit: {
guard let data = try $0.input._getBytes($0._buffer, maxLength: $0._bufferSize),
!data.isEmpty else {
Expand Down
2 changes: 1 addition & 1 deletion Sources/MailMessage/File.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import yExtensions
/// [RFC 2045 §7](https://tools.ietf.org/html/rfc2045#section-7).
/// It consists of the same characters with "Message-ID" defined in
/// [RFC 5322 §3.6.4](https://tools.ietf.org/html/rfc5322#section-3.6.4).
public struct ContentID: RawRepresentable {
public struct ContentID: RawRepresentable, Sendable {
public typealias RawValue = String

/// `dot-atom-text`
Expand Down
8 changes: 5 additions & 3 deletions Sources/MailMessage/MIMESafeData.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* *************************************************************************************************
MIMESafeData.swift
© 2021 YOCKOW.
© 2021,2024 YOCKOW.
Licensed under MIT License.
See "LICENSE.txt" for more information.
************************************************************************************************ */
Expand All @@ -13,7 +13,8 @@ public struct UInt7: Equatable,
AdditiveArithmetic,
Numeric,
ExpressibleByIntegerLiteral,
Strideable {
Strideable,
Sendable {
public typealias Magnitude = UInt8
public typealias IntegerLiteralType = UInt8
public typealias Stride = UInt8.Stride
Expand Down Expand Up @@ -91,7 +92,8 @@ public struct MIMESafeData: Equatable,
BidirectionalCollection,
RangeReplaceableCollection,
RandomAccessCollection,
MutableCollection {
MutableCollection,
Sendable {
public typealias Element = UInt7
public typealias Index = Data.Index
public typealias SubSequence = MIMESafeData
Expand Down
8 changes: 4 additions & 4 deletions Sources/MailMessage/MailAddress.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* *************************************************************************************************
MailAddress.swift
© 2022-2023 YOCKOW.
© 2022-2024 YOCKOW.
Licensed under MIT License.
See "LICENSE.txt" for more information.
************************************************************************************************ */
Expand Down Expand Up @@ -54,7 +54,7 @@ private extension Unicode.Scalar {
}
}

public enum MailAddressParserError: Error, Equatable {
public enum MailAddressParserError: Error, Equatable, Sendable {
// MARK: - Lexer Errors

case unterminatedQuotedString
Expand Down Expand Up @@ -439,8 +439,8 @@ extension MailAddressSyntaxNode {

/// Represents a mail address based on [RFC 7504](https://www.rfc-editor.org/info/rfc7504) and
/// [RFC6854](https://www.rfc-editor.org/info/rfc6854).
public struct MailAddress: Equatable, Hashable, LosslessStringConvertible {
public enum DomainPart: Equatable, Hashable, LosslessStringConvertible {
public struct MailAddress: Equatable, Hashable, LosslessStringConvertible, Sendable {
public enum DomainPart: Equatable, Hashable, LosslessStringConvertible, Sendable {
case domain(Domain)
case ipAddress(IPAddress)

Expand Down
9 changes: 7 additions & 2 deletions Sources/MailMessage/MailMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ import NetworkGear
/// Represents entire mail message
@dynamicMemberLookup
public struct MailMessage {
public struct Header: Sequence {
public struct Header: Sequence, Sendable {
// At first, I was considering using `HTTPHeader` in `NetworkGear` module.
// It validates, however, strictly its value.
// I gave up and implement original `Header` for that reason.

public struct Name: Equatable, Comparable, Hashable, ExpressibleByStringLiteral, CustomStringConvertible {
public struct Name: Equatable,
Comparable,
Hashable,
ExpressibleByStringLiteral,
CustomStringConvertible,
Sendable {
/// "From"
public static let from: Name = "From"

Expand Down
11 changes: 8 additions & 3 deletions Sources/MailMessage/Person.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* *************************************************************************************************
Person.swift
© 2021,2023 YOCKOW.
© 2021,2023-2024 YOCKOW.
Licensed under MIT License.
See "LICENSE.txt" for more information.
************************************************************************************************ */
Expand All @@ -11,7 +11,7 @@ import yExtensions
/// Represents `mailbox` defined in [RFC 5322](https://tools.ietf.org/html/rfc5322).
///
/// Note: Each properties will not be validated as of now.
public struct Person: LosslessStringConvertible, Equatable, Hashable {
public struct Person: LosslessStringConvertible, Equatable, Hashable, Sendable {
/// The person's name
public var displayName: String?

Expand Down Expand Up @@ -68,7 +68,12 @@ public struct Person: LosslessStringConvertible, Equatable, Hashable {

/// Represents `"group"`defined in [RFC 5322](https://tools.ietf.org/html/rfc5322).
@dynamicMemberLookup
public struct Group: LosslessStringConvertible, BidirectionalCollection, RangeReplaceableCollection, Equatable, Hashable {
public struct Group: LosslessStringConvertible,
BidirectionalCollection,
RangeReplaceableCollection,
Equatable,
Hashable,
Sendable {
public var persons: [Person]

public typealias Iterator = Array<Person>.Iterator
Expand Down
Loading

0 comments on commit c728a3e

Please sign in to comment.