Skip to content

Commit b71fb0f

Browse files
authored
chore: add back workflow (#195)
Co-authored-by: FL33TW00D <FL33TW00D@users.noreply.github.com>
1 parent f20149a commit b71fb0f

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

.github/workflows/format.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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 SwiftFormat
16+
run: brew install swiftformat
17+
18+
- name: Check formatting
19+
run: |
20+
found_issues=false
21+
files_with_issues=()
22+
23+
while IFS= read -r file; do
24+
if ! swiftformat --config .swiftformat --lint "$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+
39+
- name: Suggest fixes (if check fails)
40+
if: failure()
41+
run: |
42+
echo "### Here's how to fix the formatting locally:" >> $GITHUB_STEP_SUMMARY
43+
echo '```bash' >> $GITHUB_STEP_SUMMARY
44+
echo "# Install SwiftFormat if you haven't already" >> $GITHUB_STEP_SUMMARY
45+
echo "brew install swiftformat" >> $GITHUB_STEP_SUMMARY
46+
echo "" >> $GITHUB_STEP_SUMMARY
47+
echo "# Format all Swift files" >> $GITHUB_STEP_SUMMARY
48+
echo 'swiftformat --config .swiftformat .' >> $GITHUB_STEP_SUMMARY
49+
echo '```' >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)