Skip to content

Commit 129e279

Browse files
authored
fix: stabilize SwiftFormat 0.62 lint (#103098)
1 parent 8021f35 commit 129e279

5 files changed

Lines changed: 40 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,7 +1830,11 @@ jobs:
18301830
- *platform_checkout_step
18311831

18321832
- name: Install XcodeGen / SwiftLint / SwiftFormat
1833-
run: brew install xcodegen swiftlint swiftformat
1833+
run: |
1834+
brew update
1835+
brew install xcodegen swiftlint swiftformat
1836+
brew upgrade swiftformat
1837+
swiftformat --version
18341838
18351839
- name: Detect Swift toolchain cache key
18361840
id: swift-toolchain
@@ -1978,7 +1982,11 @@ jobs:
19781982
install-bun: "false"
19791983

19801984
- name: Install iOS Swift tooling
1981-
run: brew install xcodegen swiftlint swiftformat
1985+
run: |
1986+
brew update
1987+
brew install xcodegen swiftlint swiftformat
1988+
brew upgrade swiftformat
1989+
swiftformat --version
19821990
19831991
- name: Build iOS app
19841992
run: pnpm ios:build

.github/workflows/ios-periphery.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ jobs:
9595
install-bun: "false"
9696

9797
- name: Install iOS Swift tooling
98-
run: brew install xcodegen swiftformat swiftlint periphery
98+
run: |
99+
brew update
100+
brew install xcodegen swiftformat swiftlint periphery
101+
brew upgrade swiftformat
102+
swiftformat --version
99103
100104
- name: Generate iOS project
101105
run: |

config/swiftformat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SwiftFormat configuration adapted from Peekaboo defaults (Swift 6 friendly)
22

33
--swiftversion 6.2
4+
--min-version 0.62.1
45

56
# Self handling
67
--self insert
@@ -34,6 +35,9 @@
3435
--wrapcollections before-first
3536
--closingparen same-line
3637

38+
# Preserve the established compact conditionals and SwiftUI groups across SwiftFormat releases.
39+
--disable wrapIfStatementBodies,wrapIfExpressionBodies,redundantSwiftUIGroup
40+
3741
# Organization
3842
--organizetypes class,struct,enum,extension
3943
--extensionmark "MARK: - %t + %p"

scripts/ci-changed-scope.mjs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ const DOCS_PATH_RE = /^(docs\/|.*\.mdx?$)/;
3434
const SKILLS_PYTHON_SCOPE_RE = /^(skills\/|skills\/pyproject\.toml$)/;
3535
const INSTALL_SMOKE_WORKFLOW_SCOPE_RE = /^\.github\/workflows\/install-smoke\.yml$/;
3636
const NATIVE_PROTOCOL_GEN_RE = /^apps\/shared\/OpenClawKit\/Sources\/OpenClawProtocol\//;
37+
const APPLE_SWIFT_CONFIG_RE = /^config\/(?:swiftformat|swiftlint\.yml)$/;
3738
const MACOS_NATIVE_RE =
3839
/^(apps\/macos\/|apps\/macos-mlx-tts\/|apps\/ios\/|apps\/shared\/|apps\/swabble\/|Swabble\/)/;
3940
const MACOS_SCRIPT_SCOPE_RE =
4041
/^(?:scripts\/(?:codesign-mac-app|create-dmg|notarize-mac-artifact|package-mac-app|package-mac-dist)\.sh|scripts\/lib\/(?:plistbuddy|swift-toolchain)\.sh|test\/scripts\/(?:codesign-mac-app|create-dmg|notarize-mac-artifact|package-mac-app|package-mac-dist)\.test\.ts)$/;
4142
const IOS_BUILD_RE =
42-
/^(apps\/ios\/|apps\/shared\/|apps\/swabble\/|Swabble\/|config\/(?:swiftformat|swiftlint\.yml)$|scripts\/ios-(?:configure-signing|team-id|write-version-xcconfig)\.sh$|scripts\/ios-version\.ts$|scripts\/lib\/(?:ios-version\.ts|npm-publish-plan\.mjs|version-script-args\.ts)$)/;
43+
/^(apps\/ios\/|apps\/shared\/|apps\/swabble\/|Swabble\/|scripts\/ios-(?:configure-signing|team-id|write-version-xcconfig)\.sh$|scripts\/ios-version\.ts$|scripts\/lib\/(?:ios-version\.ts|npm-publish-plan\.mjs|version-script-args\.ts)$)/;
4344
const ANDROID_NATIVE_RE = /^(apps\/android\/|apps\/shared\/)/;
4445
const NODE_SCOPE_RE =
4546
/^(src\/|test\/|extensions\/|packages\/|scripts\/|ui\/|\.github\/|openclaw\.mjs$|package\.json$|pnpm-lock\.yaml$|pnpm-workspace\.yaml$|tsconfig.*\.json$|vitest.*\.ts$|tsdown\.config\.ts$|\.oxlintrc\.json$|\.oxfmtrc\.jsonc$)/;
@@ -100,6 +101,8 @@ export function detectChangedScope(changedPaths) {
100101
continue;
101102
}
102103

104+
const isAppleSwiftConfig = APPLE_SWIFT_CONFIG_RE.test(path);
105+
103106
if (DOCS_PATH_RE.test(path)) {
104107
continue;
105108
}
@@ -116,12 +119,12 @@ export function detectChangedScope(changedPaths) {
116119

117120
if (
118121
!NATIVE_PROTOCOL_GEN_RE.test(path) &&
119-
(MACOS_NATIVE_RE.test(path) || MACOS_SCRIPT_SCOPE_RE.test(path))
122+
(MACOS_NATIVE_RE.test(path) || MACOS_SCRIPT_SCOPE_RE.test(path) || isAppleSwiftConfig)
120123
) {
121124
runMacos = true;
122125
}
123126

124-
if (IOS_BUILD_RE.test(path)) {
127+
if (IOS_BUILD_RE.test(path) || isAppleSwiftConfig) {
125128
runIosBuild = true;
126129
}
127130

src/scripts/ci-changed-scope.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,21 @@ describe("detectChangedScope", () => {
223223
});
224224
});
225225

226+
it("runs both Apple lanes for shared Swift lint configuration", () => {
227+
for (const configPath of ["config/swiftformat", "config/swiftlint.yml"]) {
228+
expect(detectChangedScope([configPath])).toEqual({
229+
runNode: true,
230+
runMacos: true,
231+
runIosBuild: true,
232+
runAndroid: false,
233+
runWindows: false,
234+
runSkillsPython: false,
235+
runChangedSmoke: false,
236+
runControlUiI18n: false,
237+
});
238+
}
239+
});
240+
226241
it("enables the iOS build lane for iOS build helper changes", () => {
227242
for (const helperPath of [
228243
"scripts/ios-team-id.sh",

0 commit comments

Comments
 (0)