Skip to content

Commit e7039aa

Browse files
authored
Add CasePathsCore module (#212)
* Add `CasePathsCore` module It's possible for a library to integrate with case paths in a way that doesn't require their use and the penalty involved in building their macros, so let's introduce a "core" module that contains the core functionality of the library, less macros and other deprecations. * wip * wip * wip * Update DocC * wip
1 parent dc49b7a commit e7039aa

35 files changed

+213
-200
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
matrix:
2222
xcode:
2323
- '15.4'
24-
- '16.0'
24+
- '16.2'
2525
steps:
2626
- uses: actions/checkout@v4
2727
- name: Select Xcode ${{ matrix.xcode }}
@@ -38,7 +38,7 @@ jobs:
3838
matrix:
3939
xcode:
4040
- '15.4'
41-
- '16.0'
41+
- '16.2'
4242
steps:
4343
- uses: actions/checkout@v4
4444
- name: Select Xcode ${{ matrix.xcode }}
@@ -64,29 +64,22 @@ jobs:
6464
run: swift test -c release --parallel
6565

6666
wasm:
67-
name: SwiftWasm
67+
name: Wasm
6868
runs-on: ubuntu-latest
6969
env:
7070
OMIT_MACRO_TESTS: 1
71-
strategy:
72-
matrix:
73-
include:
74-
- toolchain: swift-DEVELOPMENT-SNAPSHOT-2024-09-18-a
75-
swift-sdk: swift-wasm-DEVELOPMENT-SNAPSHOT-2024-09-20-a
76-
checksum: ac7318b8beee4870162292715654499127833b847af6b3d94c32e574579ea189
7771
steps:
7872
- uses: actions/checkout@v4
7973
- uses: bytecodealliance/actions/wasmtime/setup@v1
8074
- name: Install Swift and Swift SDK for WebAssembly
8175
run: |
8276
PREFIX=/opt/swift
83-
SWIFT_TOOLCHAIN_TAG="${{ matrix.toolchain }}"
84-
SWIFT_SDK_TAG="${{ matrix.swift-sdk }}"
8577
set -ex
86-
curl -f -o /tmp/swift.tar.gz "https://download.swift.org/development/ubuntu2204/$SWIFT_TOOLCHAIN_TAG/$SWIFT_TOOLCHAIN_TAG-ubuntu22.04.tar.gz"
78+
curl -f -o /tmp/swift.tar.gz "https://download.swift.org/swift-6.0.2-release/ubuntu2204/swift-6.0.2-RELEASE/swift-6.0.2-RELEASE-ubuntu22.04.tar.gz"
8779
sudo mkdir -p $PREFIX; sudo tar -xzf /tmp/swift.tar.gz -C $PREFIX --strip-component 1
88-
$PREFIX/usr/bin/swift sdk install "https://github.com/swiftwasm/swift/releases/download/$SWIFT_SDK_TAG/$SWIFT_SDK_TAG-wasm32-unknown-wasi.artifactbundle.zip" --checksum ${{ matrix.checksum }}
80+
$PREFIX/usr/bin/swift sdk install https://github.com/swiftwasm/swift/releases/download/swift-wasm-6.0.2-RELEASE/swift-wasm-6.0.2-RELEASE-wasm32-unknown-wasi.artifactbundle.zip --checksum 6ffedb055cb9956395d9f435d03d53ebe9f6a8d45106b979d1b7f53358e1dcb4
8981
echo "$PREFIX/usr/bin" >> $GITHUB_PATH
82+
9083
- name: Build tests
9184
run: swift build --swift-sdk wasm32-unknown-wasi --build-tests -Xlinker -z -Xlinker stack-size=$((1024 * 1024))
9285
- name: Run tests
@@ -130,4 +123,4 @@ jobs:
130123
env:
131124
OMIT_MACRO_TESTS: 1
132125
steps:
133-
- uses: johankool/swift-android-test-action@v1
126+
- uses: johankool/swift-android-test-action@v1

.github/workflows/format.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,16 @@ concurrency:
1212
jobs:
1313
swift_format:
1414
name: swift-format
15-
runs-on: macos-14
15+
runs-on: macos-15
16+
permissions:
17+
contents: write
1618
steps:
1719
- uses: actions/checkout@v4
18-
- name: Xcode Select
19-
run: sudo xcode-select -s /Applications/Xcode_16.0.app
20-
- name: Tap
21-
run: brew install swift-format
20+
- name: Select Xcode 16.2
21+
run: sudo xcode-select -s /Applications/Xcode_16.2.app
2222
- name: Format
2323
run: make format
24-
- uses: stefanzweifel/git-auto-commit-action@v4
24+
- uses: stefanzweifel/git-auto-commit-action@v5
2525
with:
2626
commit_message: Run swift-format
2727
branch: 'main'
28-
env:
29-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.spi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
version: 1
22
builder:
33
configs:
4-
- documentation_targets: [CasePaths]
4+
- documentation_targets: [CasePathsCore, CasePaths]

Package.resolved

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,42 @@ let package = Package(
1616
.library(
1717
name: "CasePaths",
1818
targets: ["CasePaths"]
19-
)
19+
),
20+
.library(
21+
name: "CasePathsCore",
22+
targets: ["CasePathsCore"]
23+
),
2024
],
2125
dependencies: [
22-
.package(url: "https://github.com/swiftlang/swift-syntax", "509.0.0"..<"601.0.0-prerelease"),
26+
.package(url: "https://github.com/swiftlang/swift-syntax", "509.0.0"..<"601.0.0"),
2327
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.2.2"),
2428
],
2529
targets: [
2630
.target(
2731
name: "CasePaths",
2832
dependencies: [
33+
"CasePathsCore",
2934
"CasePathsMacros",
35+
]
36+
),
37+
.target(
38+
name: "CasePathsCore",
39+
dependencies: [
3040
.product(name: "IssueReporting", package: "xctest-dynamic-overlay"),
3141
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"),
3242
]
3343
),
34-
.testTarget(
35-
name: "CasePathsTests",
36-
dependencies: ["CasePaths"]
37-
),
3844
.macro(
3945
name: "CasePathsMacros",
4046
dependencies: [
4147
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
4248
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
4349
]
4450
),
51+
.testTarget(
52+
name: "CasePathsTests",
53+
dependencies: ["CasePaths"]
54+
),
4555
]
4656
)
4757

[email protected]

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,42 @@ let package = Package(
1616
.library(
1717
name: "CasePaths",
1818
targets: ["CasePaths"]
19-
)
19+
),
20+
.library(
21+
name: "CasePathsCore",
22+
targets: ["CasePathsCore"]
23+
),
2024
],
2125
dependencies: [
22-
.package(url: "https://github.com/swiftlang/swift-syntax", "509.0.0"..<"601.0.0-prerelease"),
26+
.package(url: "https://github.com/swiftlang/swift-syntax", "509.0.0"..<"601.0.0"),
2327
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.2.2"),
2428
],
2529
targets: [
2630
.target(
2731
name: "CasePaths",
2832
dependencies: [
33+
"CasePathsCore",
2934
"CasePathsMacros",
35+
]
36+
),
37+
.target(
38+
name: "CasePathsCore",
39+
dependencies: [
3040
.product(name: "IssueReporting", package: "xctest-dynamic-overlay"),
3141
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"),
3242
]
3343
),
34-
.testTarget(
35-
name: "CasePathsTests",
36-
dependencies: ["CasePaths"]
37-
),
3844
.macro(
3945
name: "CasePathsMacros",
4046
dependencies: [
4147
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
4248
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
4349
]
4450
),
51+
.testTarget(
52+
name: "CasePathsTests",
53+
dependencies: ["CasePaths"]
54+
),
4555
],
4656
swiftLanguageModes: [.v6]
4757
)

Sources/CasePaths/Documentation.docc/AnyCasePathDeprecations.md

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# ``CasePaths/CasePathable()``
22

3-
## Topics
3+
## Further reading
44

5-
### CasePathable conformance
6-
7-
- ``CasePathable``
5+
See the [`CasePathsCore`](../casepathscore) module for the `CasePathable` protocol and other core
6+
library types.

Sources/CasePaths/Documentation.docc/CasePaths.md

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,17 @@ Case paths bring the power and ergonomics of key paths to enums.
44

55
## Overview
66

7-
<!-- TODO: Copy over README -->
7+
This module exports the core functionality of the Case Paths library, as well as the `@CasePathable`
8+
macro.
89

9-
## Topics
10-
11-
### Case paths
10+
To read the core documentation, see the [`CasePathsCore`](../casepathscore) module.
1211

13-
- ``CaseKeyPath``
12+
## Topics
1413

1514
### Creating case paths
1615

1716
- ``CasePathable()``
1817

19-
### Swift support
20-
21-
- ``Swift/Optional``
22-
- ``Swift/Result``
23-
24-
### XCTest support
25-
26-
- ``XCTModify(_:case:_:_:file:line:)-94qma``
27-
28-
### Guides
29-
30-
- <doc:Swift59>
31-
3218
### Deprecated interfaces
3319

3420
- <doc:Deprecations>

Sources/CasePaths/Documentation.docc/Deprecations.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,17 @@ Avoid using deprecated APIs in your app. See the replacement that you should use
1414
- ``extract(case:from:)-ylkc``
1515
- ``extract(_:)-34fjh``
1616
- ``extract(_:)-3twft``
17+
18+
### Creating paths
19+
20+
- ``CasePathsCore/AnyCasePath``
21+
22+
### Type aliases
23+
24+
- ``CasePath``
25+
26+
### Test helpers
27+
28+
- ``XCTModify(_:case:_:_:file:line:)-14526``
29+
- ``XCTModify(_:case:_:_:file:line:)-1pef3``
30+
- ``XCTModify(_:_:_:file:line:)``

0 commit comments

Comments
 (0)