Skip to content

Commit 7553740

Browse files
committed
docs: standardize package with README, CI/CD, and validation tests
1 parent 97d93f5 commit 7553740

File tree

18 files changed

+1049
-231
lines changed

18 files changed

+1049
-231
lines changed

.github/workflows/ci.yml

Lines changed: 64 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,64 +2,80 @@ name: CI
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches:
6+
- main
67
pull_request:
7-
branches: [ main ]
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
concurrency:
13+
group: ci-${{ github.ref }}
14+
cancel-in-progress: true
815

916
jobs:
10-
macos:
11-
name: macOS (Xcode 16.0, Swift 6.0)
12-
runs-on: macos-15
17+
# Primary development workflow: Latest Swift on macOS with debug build
18+
macos-latest:
19+
name: macOS (Swift 6.2, debug)
20+
runs-on: macos-26
1321
steps:
14-
- uses: actions/checkout@v4
15-
- name: Select Xcode 16.0
16-
run: sudo xcode-select -s /Applications/Xcode_16.0.app
17-
- name: Swift version
22+
- uses: actions/checkout@v5
23+
24+
- name: Select Xcode 26.0
25+
run: sudo xcode-select -s /Applications/Xcode_26.0.app
26+
27+
- name: Print Swift version
1828
run: swift --version
19-
- name: Build
20-
run: swift build
21-
- name: Run tests
22-
run: swift test
2329

24-
macos-swift-6-2:
25-
name: macOS (Xcode 16.2, Swift 6.2)
26-
runs-on: macos-15
30+
- name: Cache Swift packages
31+
uses: actions/cache@v4
32+
with:
33+
path: .build
34+
key: ${{ runner.os }}-spm-${{ hashFiles('Package.swift') }}
35+
restore-keys: |
36+
${{ runner.os }}-spm-
37+
38+
# Note: swift test builds automatically, no separate build step needed
39+
- name: Test
40+
run: swift test -c debug
41+
42+
- name: Validate Package.swift
43+
run: swift package dump-package
44+
45+
# Production validation: Latest Swift on Linux with release build
46+
linux-latest:
47+
name: Ubuntu (Swift 6.2, release)
48+
runs-on: ubuntu-latest
49+
container: swift:6.2
2750
steps:
28-
- uses: actions/checkout@v4
29-
- name: Select Xcode 16.2
30-
run: sudo xcode-select -s /Applications/Xcode_16.2.app
31-
- name: Swift version
32-
run: swift --version
33-
- name: Build
34-
run: swift build
35-
- name: Run tests
36-
run: swift test
51+
- uses: actions/checkout@v5
52+
53+
- name: Cache Swift packages
54+
uses: actions/cache@v4
55+
with:
56+
path: .build
57+
key: ${{ runner.os }}-spm-${{ hashFiles('Package.swift') }}
58+
restore-keys: ${{ runner.os }}-spm-
59+
60+
# Note: swift test builds automatically in release mode
61+
- name: Test (release)
62+
run: swift test -c release
3763

38-
linux:
39-
name: Linux (Swift 6.0)
64+
# Compatibility check: Minimum supported Swift version (6.0)
65+
linux-compat:
66+
name: Ubuntu (Swift 6.0, compatibility)
4067
runs-on: ubuntu-latest
4168
container: swift:6.0
4269
steps:
43-
- uses: actions/checkout@v4
44-
- name: Swift version
45-
run: swift --version
46-
- name: Build
47-
run: swift build
48-
- name: Run tests
49-
run: swift test
70+
- uses: actions/checkout@v5
5071

51-
windows:
52-
name: Windows (Swift 6.0)
53-
runs-on: windows-latest
54-
steps:
55-
- uses: actions/checkout@v4
56-
- uses: compnerd/gha-setup-swift@main
72+
- name: Cache Swift packages
73+
uses: actions/cache@v4
5774
with:
58-
branch: swift-6.0-release
59-
tag: 6.0-RELEASE
60-
- name: Swift version
61-
run: swift --version
62-
- name: Build
63-
run: swift build
64-
- name: Run tests
65-
run: swift test
75+
path: .build
76+
key: ${{ runner.os }}-swift60-spm-${{ hashFiles('Package.swift') }}
77+
restore-keys: ${{ runner.os }}-swift60-spm-
78+
79+
# Note: swift test builds automatically
80+
- name: Test (Swift 6.0)
81+
run: swift test -c release

.github/workflows/swift-format.yml

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,44 @@ name: Swift Format
22

33
on:
44
push:
5-
branches: [ main ]
6-
pull_request:
7-
branches: [ main ]
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: format-${{ github.ref }}
10+
cancel-in-progress: true
811

912
jobs:
10-
swift-format:
11-
name: Swift Format Check
12-
runs-on: macos-15
13+
swift_format:
14+
name: swift-format
15+
runs-on: ubuntu-latest
16+
container: swift:6.0
17+
permissions:
18+
contents: write
1319
steps:
14-
- uses: actions/checkout@v4
15-
- name: Select Xcode 16.0
16-
run: sudo xcode-select -s /Applications/Xcode_16.0.app
20+
- uses: actions/checkout@v5
21+
22+
- name: Cache swift-format
23+
id: cache-swift-format
24+
uses: actions/cache@v4
25+
with:
26+
path: /usr/local/bin/swift-format
27+
key: ${{ runner.os }}-swift-format-${{ hashFiles('.github/workflows/swift-format.yml') }}
28+
1729
- name: Install swift-format
30+
if: steps.cache-swift-format.outputs.cache-hit != 'true'
1831
run: |
19-
brew install swift-format
20-
- name: Run swift-format
21-
run: |
22-
swift-format lint --recursive Sources Tests
32+
git clone --depth 1 --branch main https://github.com/apple/swift-format.git
33+
cd swift-format
34+
swift build -c release
35+
cp .build/release/swift-format /usr/local/bin/
36+
cd ..
37+
rm -rf swift-format
38+
39+
- name: Format
40+
run: swift-format format --ignore-unparsable-files --recursive --in-place Sources Tests
41+
42+
- uses: stefanzweifel/git-auto-commit-action@v7
43+
with:
44+
commit_message: Run swift-format
45+
branch: 'main'

.github/workflows/swiftlint.yml

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,47 @@ name: SwiftLint
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches:
6+
- main
67
pull_request:
7-
branches: [ main ]
8+
branches:
9+
- main
10+
11+
concurrency:
12+
group: swiftlint-${{ github.ref }}
13+
cancel-in-progress: true
814

915
jobs:
10-
swiftlint:
11-
name: SwiftLint Check
12-
runs-on: macos-15
16+
lint:
17+
name: SwiftLint
18+
runs-on: ubuntu-latest
19+
container: swift:6.2
1320
steps:
14-
- uses: actions/checkout@v4
15-
- name: Install SwiftLint
16-
run: brew install swiftlint
17-
- name: Run SwiftLint
18-
run: swiftlint lint --strict
21+
- uses: actions/checkout@v5
22+
23+
- name: Restore swiftlint cache
24+
id: cache-swiftlint-restore
25+
uses: actions/cache/restore@v4
26+
with:
27+
path: /usr/local/bin/swiftlint
28+
key: ${{ runner.os }}-swiftlint-0.62.2
29+
30+
- name: Install swiftlint
31+
if: steps.cache-swiftlint-restore.outputs.cache-hit != 'true'
32+
run: |
33+
git clone --depth 1 --branch 0.62.2 https://github.com/realm/SwiftLint.git
34+
cd SwiftLint
35+
swift build -c release
36+
cp .build/release/swiftlint /usr/local/bin/
37+
cd ..
38+
rm -rf SwiftLint
39+
40+
- name: Lint
41+
run: swiftlint lint --strict --reporter github-actions-logging
42+
43+
- name: Save swiftlint cache
44+
uses: actions/cache/save@v4
45+
if: always() && steps.cache-swiftlint-restore.outputs.cache-hit != 'true'
46+
with:
47+
path: /usr/local/bin/swiftlint
48+
key: ${{ runner.os }}-swiftlint-0.62.2

.swift-format

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,51 @@
44
"indentation": {
55
"spaces": 4
66
},
7+
"tabWidth": 8,
78
"maximumBlankLines": 1,
89
"respectsExistingLineBreaks": true,
910
"lineBreakBeforeControlFlowKeywords": false,
10-
"lineBreakBeforeEachArgument": false
11+
"lineBreakBeforeEachArgument": true,
12+
"lineBreakBeforeEachGenericRequirement": false,
13+
"prioritizeKeepingFunctionOutputTogether": true,
14+
"indentConditionalCompilationBlocks": true,
15+
"lineBreakAroundMultilineExpressionChainComponents": false,
16+
"fileScopedDeclarationPrivacy": {
17+
"accessLevel": "private"
18+
},
19+
"rules": {
20+
"AllPublicDeclarationsHaveDocumentation": false,
21+
"AlwaysUseLowerCamelCase": true,
22+
"AmbiguousTrailingClosureOverload": true,
23+
"BeginDocumentationCommentWithOneLineSummary": false,
24+
"DoNotUseSemicolons": true,
25+
"DontRepeatTypeInStaticProperties": true,
26+
"FileScopedDeclarationPrivacy": true,
27+
"FullyIndirectEnum": true,
28+
"GroupNumericLiterals": true,
29+
"IdentifiersMustBeASCII": true,
30+
"NeverForceUnwrap": false,
31+
"NeverUseForceTry": false,
32+
"NeverUseImplicitlyUnwrappedOptionals": false,
33+
"NoAccessLevelOnExtensionDeclaration": true,
34+
"NoBlockComments": true,
35+
"NoCasesWithOnlyFallthrough": true,
36+
"NoEmptyTrailingClosureParentheses": true,
37+
"NoLabelsInCasePatterns": true,
38+
"NoLeadingUnderscores": false,
39+
"NoParensAroundConditions": true,
40+
"NoVoidReturnOnFunctionSignature": true,
41+
"OneCasePerLine": true,
42+
"OneVariableDeclarationPerLine": true,
43+
"OnlyOneTrailingClosureArgument": true,
44+
"OrderedImports": true,
45+
"ReturnVoidInsteadOfEmptyTuple": true,
46+
"UseLetInEveryBoundCaseVariable": true,
47+
"UseShorthandTypeNames": true,
48+
"UseSingleLinePropertyGetter": true,
49+
"UseSynthesizedInitializer": true,
50+
"UseTripleSlashForDocumentationComments": true,
51+
"UseWhereClausesInForLoops": false,
52+
"ValidateDocumentationComments": false
53+
}
1154
}

.swiftlint.yml

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,64 @@
11
disabled_rules:
2-
- trailing_comma
3-
- todo
42
- line_length
3+
- trailing_comma
4+
- redundant_discardable_let
55

66
opt_in_rules:
7+
- explicit_init
8+
- closure_spacing
79
- empty_count
810
- empty_string
11+
- fatal_error_message
12+
- first_where
13+
- joined_default_parameter
14+
- operator_usage_whitespace
15+
- overridden_super_call
16+
17+
included:
18+
- Sources
19+
- Tests
920

1021
excluded:
1122
- .build
12-
- .swiftpm
23+
- Carthage
24+
- Pods
25+
- fastlane
26+
27+
# Type body length settings
28+
type_body_length:
29+
warning: 500
30+
error: 600
31+
32+
# File length settings
33+
file_length:
34+
warning: 800
35+
error: 1000
36+
ignore_comment_only_lines: true
37+
38+
# Function body length settings
39+
function_body_length:
40+
warning: 100
41+
error: 120
42+
43+
# Function parameter count
44+
function_parameter_count:
45+
warning: 6
46+
error: 8
1347

14-
line_length:
15-
warning: 120
16-
error: 200
48+
# Cyclomatic complexity
49+
cyclomatic_complexity:
50+
warning: 15
51+
error: 20
1752

53+
# Identifier name settings
1854
identifier_name:
1955
min_length:
20-
warning: 1
21-
error: 1
56+
warning: 2
57+
max_length:
58+
warning: 50
59+
error: 60
60+
excluded:
61+
- id
62+
- URL
63+
- to
64+
- db

0 commit comments

Comments
 (0)