-
Notifications
You must be signed in to change notification settings - Fork 0
Docs #4
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
Docs #4
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,112 @@ | ||
name: Pull request | ||
on: pull_request | ||
|
||
env: | ||
XCODE_VERSION: "16.3" | ||
|
||
jobs: | ||
pull-request: | ||
prepare: | ||
runs-on: macos-15 | ||
|
||
outputs: | ||
platforms: ${{ steps.platforms.outputs.platforms }} | ||
scheme: ${{ steps.scheme.outputs.scheme }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Xcode | ||
run: sudo xcode-select -s /Applications/Xcode_$XCODE_VERSION.app | ||
|
||
- name: Setup | ||
- name: Setup mise | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
curl https://mise.run | sh | ||
mise install | ||
|
||
- name: Lint | ||
- name: Run linters | ||
run: mise lint | ||
|
||
- name: Build | ||
run: swift build | ||
- name: Extract platforms | ||
id: platforms | ||
run: | | ||
platforms=$(swift package dump-package | jq -r '[.platforms[].platformName] | unique | @json') | ||
echo "Platforms: $platforms" | ||
echo "platforms=$platforms" >> $GITHUB_OUTPUT | ||
|
||
- name: Test | ||
run: swift test | ||
- name: Extract scheme | ||
id: scheme | ||
run: | | ||
repo=$(basename $GITHUB_REPOSITORY) | ||
schemes=$(xcodebuild -list) | ||
echo "$schemes" | ||
|
||
if echo "$schemes" | grep -q "$repo-Package"; then | ||
scheme="$repo-Package" | ||
elif echo "$schemes" | grep -q "$repo"; then | ||
scheme="$repo" | ||
else | ||
echo "Unable to select a scheme" | ||
exit 1 | ||
fi | ||
|
||
echo "Selected scheme: $scheme" | ||
echo "scheme=$scheme" >> $GITHUB_OUTPUT | ||
|
||
build-and-test: | ||
needs: prepare | ||
runs-on: macos-15 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
platform: ${{ fromJSON(needs.prepare.outputs.platforms) }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Xcode | ||
run: sudo xcode-select -s /Applications/Xcode_$XCODE_VERSION.app | ||
|
||
- name: Map destinations | ||
if: ${{ matrix.platform != 'macos' }} | ||
id: destination | ||
run: | | ||
case "${{ matrix.platform }}" in | ||
ios) | ||
destination="platform=iOS Simulator,name=iPhone 16 Pro Max,OS=latest" | ||
;; | ||
maccatalyst) | ||
destination="platform=macOS,variant=Mac Catalyst" | ||
;; | ||
tvos) | ||
destination="platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=latest" | ||
;; | ||
visionos) | ||
destination="platform=visionOS Simulator,name=Apple Vision Pro,OS=latest" | ||
;; | ||
watchos) | ||
destination="platform=watchOS Simulator,name=Apple Watch Series 10 (46mm),OS=latest" | ||
;; | ||
*) | ||
echo "Unknown platform: ${{ matrix.platform }}" | ||
exit 1 | ||
;; | ||
esac | ||
echo "destination=$destination" >> $GITHUB_OUTPUT | ||
|
||
- name: Build (SPM) | ||
if: ${{ matrix.platform == 'macos' }} | ||
run: swift build | xcbeautify --renderer github-actions | ||
- name: Build (Xcode) | ||
if: ${{ matrix.platform != 'macos' }} | ||
run: | | ||
xcodebuild build \ | ||
-scheme ${{ needs.prepare.outputs.scheme }} \ | ||
-destination "${{ steps.destination.outputs.destination }}" | \ | ||
xcbeautify --renderer github-actions | ||
|
||
- name: Test (SPM) | ||
if: ${{ matrix.platform == 'macos' }} | ||
run: swift test | xcbeautify --renderer github-actions | ||
- name: Test (Xcode) | ||
if: ${{ matrix.platform != 'macos' }} | ||
run: | | ||
xcodebuild test \ | ||
-scheme ${{ needs.prepare.outputs.scheme }} \ | ||
-destination "${{ steps.destination.outputs.destination }}" | \ | ||
xcbeautify --renderer github-actions |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
// swift-tools-version: 6.0 | ||
// swift-tools-version: 6.1 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "PrincipleMacros", | ||
platforms: [ | ||
.macOS(.v13), | ||
.macCatalyst(.v16), | ||
.iOS(.v16), | ||
.tvOS(.v16), | ||
.watchOS(.v9), | ||
.visionOS(.v1) | ||
.macOS(.v15), | ||
.macCatalyst(.v18), | ||
.iOS(.v18), | ||
.tvOS(.v18), | ||
.watchOS(.v11), | ||
.visionOS(.v2) | ||
], | ||
Comment on lines
+9
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very restrictive platform requirements The platform requirements have increased significantly - most by 2 major versions. This will exclude users on older OS versions and potentially reduce your user base considerably. Consider whether these high minimum requirements are necessary for your functionality, or if you could support a wider range of devices with lower minimums. |
||
products: [ | ||
.library( | ||
|
@@ -22,7 +22,7 @@ let package = Package( | |
dependencies: [ | ||
.package( | ||
url: "https://github.com/NSFatalError/Principle", | ||
from: "0.0.1" | ||
from: "1.0.0" | ||
), | ||
.package( | ||
url: "https://github.com/swiftlang/swift-syntax", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,19 @@ | ||
# PrincipleMacros | ||
|
||
 | ||
|
||
Essential tools that extend the capabilities of `SwiftSyntax`, simplifying the implementation of custom macros. | ||
|
||
> [!WARNING] | ||
> This package is considered an implementation detail of some of my other open-source projects. | ||
> While it follows semantic versioning rules and has decent test coverage, it is currently undocumented, | ||
> and future releases may introduce multiple breaking changes. Use it at your own discretion. | ||
## Installation | ||
|
||
```swift | ||
.package( | ||
url: "https://github.com/NSFatalError/PrincipleMacros", | ||
from: "1.0.0" | ||
) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// | ||
// EnumCaseCallExprBuilderTests.swift | ||
// PrincipleMacros | ||
// | ||
// Created by Kamil Strzelecki on 05/04/2025. | ||
// Copyright © 2025 Kamil Strzelecki. All rights reserved. | ||
// | ||
|
||
@testable import PrincipleMacros | ||
import Testing | ||
|
||
internal struct EnumCaseCallExprBuilderTests { | ||
|
||
func makeEnumCase(from decl: DeclSyntax) throws -> EnumCase { | ||
let enumCaseDecl = try #require(EnumCaseDeclSyntax(decl)) | ||
let enumElement = try #require(enumCaseDecl.elements.first) | ||
return EnumCase(declaration: enumCaseDecl, element: enumElement) | ||
} | ||
|
||
@Test | ||
func testCallWithoutAssociatedValues() throws { | ||
let enumCase = try makeEnumCase(from: "case first") | ||
let builder = EnumCaseCallExprBuilder(for: enumCase) { _ in | ||
Issue.record() | ||
return "" as ExprSyntax | ||
} | ||
#expect(builder.build().description == ".first") | ||
} | ||
|
||
@Test | ||
func testCallWithUnnamedAssociatedValue() throws { | ||
let enumCase = try makeEnumCase(from: "case second(Int)") | ||
let builder = EnumCaseCallExprBuilder(for: enumCase) { _ in | ||
"123" as ExprSyntax | ||
} | ||
#expect(builder.build().description == ".second(123)") | ||
} | ||
|
||
@Test | ||
func testCallWithMultipleAssociatedValues() throws { | ||
let enumCase = try makeEnumCase(from: "case third(arg: String, Int)") | ||
let builder = EnumCaseCallExprBuilder(for: enumCase) { associatedValue in | ||
if associatedValue.standardizedName.description == "arg" { | ||
"argument" as ExprSyntax | ||
} else { | ||
"123" as ExprSyntax | ||
} | ||
} | ||
#expect(builder.build().description == ".third(arg: argument, 123)") | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// SwitchExprBuilderTests.swift | ||
// PrincipleMacros | ||
// | ||
// Created by Kamil Strzelecki on 05/04/2025. | ||
// Copyright © 2025 Kamil Strzelecki. All rights reserved. | ||
// | ||
|
||
@testable import PrincipleMacros | ||
import Testing | ||
|
||
internal struct SwitchExprBuilderTests { | ||
|
||
func makeEnumCase(from decl: DeclSyntax) throws -> EnumCase { | ||
let enumCaseDecl = try #require(EnumCaseDeclSyntax(decl)) | ||
let enumElement = try #require(enumCaseDecl.elements.first) | ||
return EnumCase(declaration: enumCaseDecl, element: enumElement) | ||
} | ||
|
||
@Test | ||
func testSwitchExpression() throws { | ||
let enumCases = try EnumCasesList([ | ||
makeEnumCase(from: "case first"), | ||
makeEnumCase(from: "case second(Int)"), | ||
makeEnumCase(from: "case third(arg: String, Int)") | ||
]) | ||
|
||
let builder = SwitchExprBuilder(for: enumCases, over: "subject") { enumCase in | ||
"return \(raw: enumCase.associatedValues.count)" | ||
} | ||
|
||
let expectation = """ | ||
switch subject { | ||
case .first: | ||
return 0 | ||
case let .second(_0): | ||
return 1 | ||
case let .third(arg, _1): | ||
return 2 | ||
} | ||
""" | ||
|
||
#expect(builder.build().description == expectation) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swift Tools Version Upgrade Impact
Upgrading from Swift 6.0 to 6.1 will require contributors and users to update their Swift toolchain. Ensure this aligns with your adoption timeline and that any new Swift 6.1 features you're using are documented.
🧰 Tools
🪛 SwiftLint (0.57.0)
[Warning] 1-1: Header comments should be consistent with project patterns
(file_header)