File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Swift Format
2
+ on :
3
+ pull_request :
4
+ paths :
5
+ - ' **.swift'
6
+ workflow_dispatch :
7
+ jobs :
8
+ swift-format :
9
+ name : Check Swift Formatting
10
+ runs-on : macos-latest
11
+
12
+ steps :
13
+ - uses : actions/checkout@v4
14
+
15
+ - name : Install swift-format
16
+ run : |
17
+ brew install swift-format
18
+ - name : Check formatting
19
+ run : |
20
+ found_issues=false
21
+ files_with_issues=()
22
+
23
+ while IFS= read -r file; do
24
+ if ! swift-format lint --strict "$file"; then
25
+ found_issues=true
26
+ files_with_issues+=("$file")
27
+ echo "❌ Formatting issues found in: $file"
28
+ fi
29
+ done < <(find . -name "*.swift" -type f)
30
+
31
+ if [ "$found_issues" = true ]; then
32
+ echo "❌ The following files need formatting:"
33
+ printf '%s\n' "${files_with_issues[@]}"
34
+ exit 1
35
+ else
36
+ echo "✅ All Swift files are properly formatted!"
37
+ fi
38
+ - name : Suggest fixes (if check fails)
39
+ if : failure()
40
+ run : |
41
+ echo "### Here's how to fix the formatting locally:" >> $GITHUB_STEP_SUMMARY
42
+ echo '```bash' >> $GITHUB_STEP_SUMMARY
43
+ echo "# Install swift-format if you haven't already" >> $GITHUB_STEP_SUMMARY
44
+ echo "brew install swift-format" >> $GITHUB_STEP_SUMMARY
45
+ echo "" >> $GITHUB_STEP_SUMMARY
46
+ echo "# Format all Swift files" >> $GITHUB_STEP_SUMMARY
47
+ echo 'find . -name "*.swift" -type f -exec swift-format format --in-place {} \;' >> $GITHUB_STEP_SUMMARY
48
+ echo '```' >> $GITHUB_STEP_SUMMARY
Original file line number Diff line number Diff line change
1
+ {
2
+ "version": 1,
3
+ "lineLength": 100,
4
+ }
You can’t perform that action at this time.
0 commit comments