Skip to content

Commit 9781bbb

Browse files
committed
Migration
1 parent e3d7288 commit 9781bbb

28 files changed

Lines changed: 1959 additions & 126 deletions

.github/workflows/pull-request.yml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: Pull request
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize, ready_for_review]
6+
push:
7+
branches:
8+
- main
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
env:
15+
XCODE_VERSION: "16.3"
16+
17+
jobs:
18+
prepare:
19+
runs-on: macos-15
20+
outputs:
21+
platforms: ${{ steps.platforms.outputs.platforms }}
22+
scheme: ${{ steps.scheme.outputs.scheme }}
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Setup Xcode
26+
run: sudo xcode-select -s /Applications/Xcode_$XCODE_VERSION.app
27+
28+
- name: Setup mise
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
run: |
32+
curl https://mise.run | sh
33+
mise install
34+
- name: Run linters
35+
run: mise lint
36+
37+
- name: Extract platforms
38+
id: platforms
39+
run: |
40+
platforms=$(swift package dump-package | jq -r '[.platforms[].platformName] | unique | @json')
41+
echo "Platforms: $platforms"
42+
echo "platforms=$platforms" >> $GITHUB_OUTPUT
43+
44+
- name: Extract scheme
45+
id: scheme
46+
run: |
47+
repo=$(basename $GITHUB_REPOSITORY)
48+
schemes=$(xcodebuild -list)
49+
echo "$schemes"
50+
51+
if echo "$schemes" | grep -q "$repo-Package"; then
52+
scheme="$repo-Package"
53+
elif echo "$schemes" | grep -q "$repo"; then
54+
scheme="$repo"
55+
else
56+
echo "Unable to select a scheme"
57+
exit 1
58+
fi
59+
60+
echo "Selected scheme: $scheme"
61+
echo "scheme=$scheme" >> $GITHUB_OUTPUT
62+
63+
build-and-test:
64+
needs: prepare
65+
runs-on: macos-15
66+
strategy:
67+
fail-fast: false
68+
matrix:
69+
platform: ${{ fromJSON(needs.prepare.outputs.platforms) }}
70+
steps:
71+
- uses: actions/checkout@v4
72+
- name: Setup Xcode
73+
run: sudo xcode-select -s /Applications/Xcode_$XCODE_VERSION.app
74+
75+
- name: Map destinations
76+
if: ${{ matrix.platform != 'macos' }}
77+
id: destination
78+
run: |
79+
case "${{ matrix.platform }}" in
80+
maccatalyst)
81+
destination="platform=macOS,variant=Mac Catalyst"
82+
;;
83+
ios)
84+
destination="platform=iOS Simulator,name=iPhone 16 Pro Max,OS=latest"
85+
;;
86+
tvos)
87+
destination="platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=latest"
88+
;;
89+
watchos)
90+
destination="platform=watchOS Simulator,name=Apple Watch Series 10 (46mm),OS=latest"
91+
;;
92+
visionos)
93+
destination="platform=visionOS Simulator,name=Apple Vision Pro,OS=latest"
94+
;;
95+
*)
96+
echo "Unknown platform: ${{ matrix.platform }}"
97+
exit 1
98+
;;
99+
esac
100+
echo "destination=$destination" >> $GITHUB_OUTPUT
101+
102+
- name: Build (SPM)
103+
if: ${{ matrix.platform == 'macos' }}
104+
run: swift build
105+
106+
- name: Build (Xcode)
107+
if: ${{ matrix.platform != 'macos' }}
108+
run: |
109+
set -o pipefail
110+
xcodebuild build \
111+
-scheme ${{ needs.prepare.outputs.scheme }} \
112+
-destination "${{ steps.destination.outputs.destination }}" | \
113+
xcbeautify --renderer github-actions
114+
115+
- name: Test (SPM)
116+
if: ${{ matrix.platform == 'macos' }}
117+
run: |
118+
set -o pipefail
119+
swift test --enable-code-coverage | xcbeautify --renderer github-actions
120+
TEST_BUNDLE=$(find .build/debug/ -name "*.xctest" | head -n 1)
121+
TEST_EXECUTABLE="$TEST_BUNDLE/Contents/MacOS/$(basename "$TEST_BUNDLE" .xctest)"
122+
xcrun llvm-cov export -format="lcov" \
123+
-instr-profile .build/debug/codecov/default.profdata \
124+
"$TEST_EXECUTABLE" > info.lcov
125+
126+
- name: Test (Xcode)
127+
if: ${{ matrix.platform != 'macos' }}
128+
run: |
129+
set -o pipefail
130+
xcodebuild test \
131+
-scheme ${{ needs.prepare.outputs.scheme }} \
132+
-destination "${{ steps.destination.outputs.destination }}" | \
133+
xcbeautify --renderer github-actions
134+
135+
- name: Check coverage (SPM)
136+
if: ${{ matrix.platform == 'macos' }}
137+
uses: codecov/codecov-action@v5
138+
with:
139+
fail_ci_if_error: true

.github/workflows/release.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
env:
9+
XCODE_VERSION: "16.3"
10+
11+
jobs:
12+
release:
13+
runs-on: macos-15
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
- name: Setup Xcode
19+
run: sudo xcode-select -s /Applications/Xcode_$XCODE_VERSION.app
20+
21+
- name: Verify changes
22+
run: |
23+
current_tag=${GITHUB_REF#refs/tags/}
24+
previous_tag=$(git tag --sort=-v:refname | head -n 2 | tail -n 1)
25+
26+
current_major=$(echo "$current_tag" | cut -d '.' -f 1)
27+
previous_major=$(echo "$previous_tag" | cut -d '.' -f 1)
28+
echo "Comparing $current_tag with $previous_tag..."
29+
30+
if [ "$current_major" -gt "$previous_major" ]; then
31+
swift package diagnose-api-breaking-changes "$previous_tag" || true
32+
else
33+
swift package diagnose-api-breaking-changes "$previous_tag"
34+
fi
35+
36+
- name: Draft release
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
run: |
40+
current_tag=${GITHUB_REF#refs/tags/}
41+
gh release create "$current_tag" \
42+
--repo="$GITHUB_REPOSITORY" \
43+
--generate-notes \
44+
--draft

.mise.toml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[vars]
2+
sources = "Sources"
3+
tests = "Tests"
4+
swiftlint = '~/.local/bin/mise x -- swiftlint'
5+
swiftformat = '~/.local/bin/mise x -- swiftformat'
6+
7+
[tools]
8+
swiftlint = "0.58.2"
9+
swiftformat = "0.55.5"
10+
11+
[tasks.lint]
12+
description = 'Run all linters'
13+
depends = ["swiftlint:*", "swiftformat"]
14+
15+
[tasks."swiftlint:sources"]
16+
description = 'Run SwiftLint for source files'
17+
quiet = true
18+
run = """
19+
{{ vars.swiftlint }} lint \
20+
--config .swiftlint.yml \
21+
--strict \
22+
{{ vars.sources }}
23+
"""
24+
25+
[tasks."swiftlint:tests"]
26+
description = 'Run SwiftLint for test files'
27+
quiet = true
28+
run = """
29+
{{ vars.swiftlint }} lint \
30+
--config .swiftlint.yml \
31+
--config .swiftlint.tests.yml \
32+
--strict \
33+
{{ vars.tests }}
34+
"""
35+
36+
[tasks.swiftformat]
37+
description = 'Run SwiftFormat for all files'
38+
quiet = true
39+
run = "{{ vars.swiftformat }} . --lint"

.swift-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.0

.swiftformat

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
--acronyms ID,URL,UUID
2+
--allman false
3+
--anonymousforeach convert
4+
--assetliterals visual-width
5+
--asynccapturing
6+
--beforemarks
7+
--binarygrouping 4,8
8+
--callsiteparen default
9+
--categorymark "MARK: %c"
10+
--classthreshold 0
11+
--closingparen default
12+
--closurevoid remove
13+
--commas inline
14+
--complexattrs prev-line
15+
--computedvarattrs prev-line
16+
--condassignment always
17+
--conflictmarkers reject
18+
--dateformat system
19+
--decimalgrouping 3,6
20+
--doccomments before-declarations
21+
--elseposition same-line
22+
--emptybraces no-space
23+
--enumnamespaces always
24+
--enumthreshold 0
25+
--exponentcase lowercase
26+
--exponentgrouping disabled
27+
--extensionacl on-declarations
28+
--extensionlength 0
29+
--extensionmark "MARK: - %t + %c"
30+
--fractiongrouping disabled
31+
--fragment false
32+
--funcattributes prev-line
33+
--generictypes
34+
--groupblanklines true
35+
--groupedextension "MARK: %c"
36+
--guardelse next-line
37+
--header ignore
38+
--hexgrouping 4,8
39+
--hexliteralcase uppercase
40+
--ifdef indent
41+
--importgrouping testable-first
42+
--indent 4
43+
--indentcase false
44+
--indentstrings false
45+
--inferredtypes always
46+
--initcodernil false
47+
--inlinedforeach ignore
48+
--lifecycle
49+
--lineaftermarks true
50+
--linebreaks lf
51+
--markcategories true
52+
--markextensions always
53+
--marktypes always
54+
--maxwidth none
55+
--modifierorder
56+
--nevertrailing
57+
--nilinit remove
58+
--noncomplexattrs
59+
--nospaceoperators
60+
--nowrapoperators
61+
--octalgrouping 4,8
62+
--operatorfunc spaced
63+
--organizationmode visibility
64+
--organizetypes actor,class,enum,struct
65+
--patternlet hoist
66+
--preservedecls
67+
--preservedsymbols Package
68+
--propertytypes inferred
69+
--ranges spaced
70+
--self init-only
71+
--selfrequired
72+
--semicolons inline
73+
--shortoptionals always
74+
--smarttabs enabled
75+
--someany true
76+
--sortedpatterns
77+
--storedvarattrs prev-line
78+
--stripunusedargs always
79+
--structthreshold 0
80+
--tabwidth unspecified
81+
--throwcapturing
82+
--timezone system
83+
--trailingclosures
84+
--trimwhitespace always
85+
--typeattributes prev-line
86+
--typeblanklines preserve
87+
--typedelimiter space-after
88+
--typemark "MARK: - %t"
89+
--typemarks
90+
--typeorder
91+
--visibilitymarks
92+
--visibilityorder
93+
--voidtype void
94+
--wraparguments before-first
95+
--wrapcollections before-first
96+
--wrapconditions after-first
97+
--wrapeffects preserve
98+
--wrapenumcases always
99+
--wrapparameters before-first
100+
--wrapreturntype preserve
101+
--wrapternary before-operators
102+
--wraptypealiases after-first
103+
--xcodeindentation enabled
104+
--yodaswap always
105+
--disable enumNamespaces,fileHeader,headerFileName,redundantInternal,wrap,wrapMultilineStatementBraces,wrapSingleLineComments
106+
--enable acronyms,blankLinesBetweenImports,blockComments,docComments,isEmpty,propertyTypes,redundantProperty,sortSwitchCases,unusedPrivateDeclarations,wrapConditionalBodies,wrapEnumCases

.swiftlint.tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
disabled_rules:
2+
- function_body_length
3+
- no_magic_numbers

0 commit comments

Comments
 (0)