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

Adopt swift-testing #124

Merged
merged 7 commits into from
Jul 17, 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
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: macos-latest
steps:
- name: 🛒 Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: 👷 Build Website
run: .github/scripts/generate-docs.sh
2 changes: 1 addition & 1 deletion .github/workflows/documentation-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 🛒 Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: 🧱 Install dependencies
run: sudo apt-get install -y jq
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ios-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
changed: ${{ steps.filter.outputs.changed }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: filter
with:
Expand All @@ -38,7 +38,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Build and Test
run: |
set -o pipefail && \
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/linux-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
changed: ${{ steps.filter.outputs.changed }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: filter
with:
Expand All @@ -35,10 +35,8 @@ jobs:
strategy:
matrix:
swift: [ "swift:5.10.1", "swiftlang/swift:nightly-6.0" ]
os: [ amazonlinux2, bookworm, focal, jammy, rhel-ubi9, mantic, noble ]
os: [ amazonlinux2, focal, jammy, rhel-ubi9, mantic, noble ]
exclude:
- swift: "swiftlang/swift:nightly-6.0"
os: "bookworm"
- swift: "swiftlang/swift:nightly-6.0"
os: "mantic"
- swift: "swiftlang/swift:nightly-6.0"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/macos-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
changed: ${{ steps.filter.outputs.changed }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: filter
with:
Expand All @@ -38,7 +38,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Build and Test
run: |
set -o pipefail && \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tvos-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
changed: ${{ steps.filter.outputs.changed }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: filter
with:
Expand All @@ -38,7 +38,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Build and Test
run: |
set -o pipefail && \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/visionos-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
changed: ${{ steps.filter.outputs.changed }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: filter
with:
Expand All @@ -38,7 +38,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Build and Test
run: |
set -o pipefail && \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/watchos-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
changed: ${{ steps.filter.outputs.changed }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: filter
with:
Expand All @@ -38,7 +38,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Build and Test
run: |
set -o pipefail && \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: macos-11.0
steps:
- name: 🛒 Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: 👷 Build Website
run: .github/scripts/generate-docs.sh
Expand Down
175 changes: 106 additions & 69 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,82 +20,119 @@ let package = Package(
// .library(name: "Vexillographer", targets: [ "Vexillographer" ]),
],

dependencies: [
.package(url: "https://github.com/apple/swift-async-algorithms.git", from: "1.0.0"),
.package(url: "https://github.com/nicklockwood/SwiftFormat.git", from: "0.54.1"),
.package(url: "https://github.com/apple/swift-syntax.git", exact: "600.0.0-prerelease-2024-06-12"),
],
dependencies: .init {
Package.Dependency.package(url: "https://github.com/apple/swift-async-algorithms.git", from: "1.0.0")
Package.Dependency.package(url: "https://github.com/nicklockwood/SwiftFormat.git", from: "0.54.1")
Package.Dependency.package(url: "https://github.com/swiftlang/swift-syntax.git", exact: "600.0.0-prerelease-2024-06-12")

#if os(Linux)
// Linux does not come bundled with swift-testing
Package.Dependency.package(url: "https://github.com/apple/swift-testing.git", exact: "0.11.0")
#endif

},

targets: .init {

// Vexil

Target.target(
name: "Vexil",
dependencies: [
.target(name: "VexilMacros"),
.product(name: "AsyncAlgorithms", package: "swift-async-algorithms"),
],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency"),
]
)
Target.testTarget(
name: "VexilTests",
dependencies: .init {
Target.Dependency.target(name: "Vexil")

#if os(Linux)
// Linux does not come bundled with swift-testing
Target.Dependency.product(name: "Testing", package: "swift-testing")
#endif

targets: {
var targets: [Target] = [

// Vexil

.target(
name: "Vexil",
dependencies: [
.target(name: "VexilMacros"),
.product(name: "AsyncAlgorithms", package: "swift-async-algorithms"),
],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency"),
]
),
.testTarget(
name: "VexilTests",
dependencies: [
.target(name: "Vexil"),
],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency"),
]
),

// Vexillographer

// .target(
// name: "Vexillographer",
// dependencies: [
// .target(name: "Vexil"),
// ]
// ),

// Macros

.macro(
name: "VexilMacros",
dependencies: [
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency"),
]
),

]
},
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency"),
]
)

// Vexillographer

// Target.target(
// name: "Vexillographer",
// dependencies: [
// .target(name: "Vexil"),
// ]
// ),

// Macros

Target.macro(
name: "VexilMacros",
dependencies: [
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency"),
]
)

#if !os(Linux)
targets += [
.testTarget(
name: "VexilMacroTests",
dependencies: [
.target(name: "VexilMacros"),
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"),
],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency"),
]
),
]

// We can't disable macro validation using `swift test` so these are guaranteed to fail on Linux
Target.testTarget(
name: "VexilMacroTests",
dependencies: [
.target(name: "VexilMacros"),
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"),
],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency"),
]
)

#endif

return targets
}(),
},

swiftLanguageVersions: [
.v6,
]

)

// MARK: - Helpers

@resultBuilder
enum CollectionBuilder<Element> {

typealias Component = [Element]

static func buildExpression(_ expression: Element) -> Component {
[expression]
}

static func buildBlock(_ components: Component...) -> Component {
components.flatMap { $0 }
}

static func buildLimitedAvailability(_ components: [Element]) -> Component {
components
}

}

extension Array {
init(@CollectionBuilder<Element> collecting: () -> [Element]) {
self = collecting()
}
}
Loading
Loading