Skip to content

Commit cfffb56

Browse files
authored
Merge pull request #1 from zombieht/codeQuality
Code quality
2 parents 084ef21 + b6c9822 commit cfffb56

29 files changed

Lines changed: 3263 additions & 244 deletions

.github/workflows/ci.yml

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,54 @@ jobs:
3131
run: |
3232
xcodebuild -version
3333
34-
# 步骤 2.5:安装 create-dmg 以启用精美 DMG 打包布局
34+
# 步骤 2.4:校验代码风格。swift-format 随 Xcode 提供,无需额外安装依赖。
35+
# --strict 让任何风格告警都以非零退出码结束,把当前统一的排版固化为门禁。
36+
- name: Lint Formatting
37+
run: |
38+
xcrun swift-format lint \
39+
--configuration .swift-format \
40+
--recursive \
41+
--strict \
42+
BetterMenu BetterMenuFinderSync BetterMenuTests
43+
44+
# 步骤 2.5:运行安全通信、路径处理与设置迁移单元测试
45+
- name: Run Tests
46+
run: |
47+
TEST_DERIVED_DATA="$RUNNER_TEMP/BetterMenuTestsDerivedData"
48+
echo "TEST_DERIVED_DATA=$TEST_DERIVED_DATA" >> "$GITHUB_ENV"
49+
xcodebuild \
50+
-project BetterMenu.xcodeproj \
51+
-scheme BetterMenu \
52+
-configuration Debug \
53+
-destination 'platform=macOS' \
54+
-derivedDataPath "$TEST_DERIVED_DATA" \
55+
-resultBundlePath "$RUNNER_TEMP/BetterMenuTests.xcresult" \
56+
test
57+
58+
UNEXPECTED_PRODUCTS="$(
59+
find "$TEST_DERIVED_DATA/Build/Products" \
60+
-type d \
61+
\( -name 'BetterMenu.app' -o -name 'BetterMenuFinderSync.appex' \) \
62+
-print
63+
)"
64+
if [[ -n "$UNEXPECTED_PRODUCTS" ]]; then
65+
echo "单元测试不应构建或注册 BetterMenu App/Finder Sync 扩展:"
66+
echo "$UNEXPECTED_PRODUCTS"
67+
exit 1
68+
fi
69+
70+
# 步骤 2.55:无论测试通过与否都上传 xcresult 包,失败时可直接下载查看具体失败用例,
71+
# 不必再依赖日志尾部输出定位问题。
72+
- name: Upload Test Results
73+
if: always()
74+
uses: actions/upload-artifact@v7
75+
with:
76+
name: BetterMenu-TestResults
77+
path: ${{ runner.temp }}/BetterMenuTests.xcresult
78+
if-no-files-found: warn
79+
retention-days: 14
80+
81+
# 步骤 2.6:安装 create-dmg 以启用精美 DMG 打包布局
3582
- name: Install create-dmg
3683
run: |
3784
brew install create-dmg
@@ -42,6 +89,17 @@ jobs:
4289
chmod +x script/package.sh
4390
./script/package.sh > build.log 2>&1 || { echo "=== BUILD FAILED ==="; tail -n 200 build.log; exit 1; }
4491
92+
# 步骤 3.5:上传完整打包日志。tail -n 200 只能看到尾部,
93+
# 编译错误常出现在中段,因此把整份日志留作工件。
94+
- name: Upload Build Log
95+
if: always()
96+
uses: actions/upload-artifact@v7
97+
with:
98+
name: BetterMenu-BuildLog
99+
path: build.log
100+
if-no-files-found: warn
101+
retention-days: 14
102+
45103
# 步骤 4:当推送以 'v' 开头的 tag 时,下载 Sparkle 工具生成 appcast.xml 并对其签名
46104
- name: Generate Sparkle Appcast
47105
if: startsWith(github.ref, 'refs/tags/v')

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ dist/
2929
# 本地设计源文件或临时素材,不影响应用构建。
3030
docs/*
3131
!docs/screenshots/
32+
CLAUDE.md

.swift-format

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"version": 1,
3+
"lineLength": 100,
4+
"indentation": {
5+
"spaces": 2
6+
},
7+
"tabWidth": 2,
8+
"maximumBlankLines": 1,
9+
"respectsExistingLineBreaks": true,
10+
"lineBreakBeforeControlFlowKeywords": false,
11+
"lineBreakBeforeEachArgument": false,
12+
"lineBreakBeforeEachGenericRequirement": false,
13+
"lineBreakBetweenDeclarationAttributes": false,
14+
"prioritizeKeepingFunctionOutputTogether": false,
15+
"indentConditionalCompilationBlocks": false,
16+
"indentSwitchCaseLabels": false,
17+
"spacesAroundRangeFormationOperators": false,
18+
"multiElementCollectionTrailingCommas": true,
19+
"rules": {
20+
"AllPublicDeclarationsHaveDocumentation": false,
21+
"AlwaysUseLiteralForEmptyCollectionInit": false,
22+
"AlwaysUseLowerCamelCase": true,
23+
"AmbiguousTrailingClosureOverload": true,
24+
"BeginDocumentationCommentWithOneLineSummary": false,
25+
"DoNotUseSemicolons": true,
26+
"DontRepeatTypeInStaticProperties": true,
27+
"FileScopedDeclarationPrivacy": true,
28+
"FullyIndirectEnum": true,
29+
"GroupNumericLiterals": true,
30+
"IdentifiersMustBeASCII": true,
31+
"NeverForceUnwrap": false,
32+
"NeverUseForceTry": false,
33+
"NeverUseImplicitlyUnwrappedOptionals": false,
34+
"NoAccessLevelOnExtensionDeclaration": true,
35+
"NoAssignmentInExpressions": true,
36+
"NoBlockComments": false,
37+
"NoCasesWithOnlyFallthrough": true,
38+
"NoEmptyLinesOpeningClosingBraces": false,
39+
"NoEmptyTrailingClosureParentheses": true,
40+
"NoLabelsInCasePatterns": true,
41+
"NoLeadingUnderscores": false,
42+
"NoParensAroundConditions": true,
43+
"NoPlaygroundLiterals": true,
44+
"NoVoidReturnOnFunctionSignature": true,
45+
"OmitExplicitReturns": false,
46+
"OneCasePerLine": true,
47+
"OneVariableDeclarationPerLine": true,
48+
"OnlyOneTrailingClosureArgument": true,
49+
"OrderedImports": true,
50+
"ReplaceForEachWithForLoop": false,
51+
"ReturnVoidInsteadOfEmptyTuple": true,
52+
"TypeNamesShouldBeCapitalized": true,
53+
"UseEarlyExits": false,
54+
"UseLetInEveryBoundCaseVariable": false,
55+
"UseShorthandTypeNames": true,
56+
"UseSingleLinePropertyGetter": true,
57+
"UseSynthesizedInitializer": false,
58+
"UseTripleSlashForDocumentationComments": true,
59+
"UseWhereClausesInForLoops": false,
60+
"ValidateDocumentationComments": false
61+
}
62+
}

0 commit comments

Comments
 (0)