From dbfd03b74473759adcc31560a96a485e6a96bdd7 Mon Sep 17 00:00:00 2001 From: FL33TW00D Date: Tue, 25 Mar 2025 15:28:21 +0000 Subject: [PATCH] chore: add back workflow --- .github/workflows/format.yml | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/format.yml diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..1b199f7 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,49 @@ +name: Swift Format +on: + pull_request: + paths: + - '**.swift' + workflow_dispatch: +jobs: + swift-format: + name: Check Swift Formatting + runs-on: macos-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install SwiftFormat + run: brew install swiftformat + + - name: Check formatting + run: | + found_issues=false + files_with_issues=() + + while IFS= read -r file; do + if ! swiftformat --config .swiftformat --lint "$file"; then + found_issues=true + files_with_issues+=("$file") + echo "❌ Formatting issues found in: $file" + fi + done < <(find . -name "*.swift" -type f) + + if [ "$found_issues" = true ]; then + echo "❌ The following files need formatting:" + printf '%s\n' "${files_with_issues[@]}" + exit 1 + else + echo "✅ All Swift files are properly formatted!" + fi + + - name: Suggest fixes (if check fails) + if: failure() + run: | + echo "### Here's how to fix the formatting locally:" >> $GITHUB_STEP_SUMMARY + echo '```bash' >> $GITHUB_STEP_SUMMARY + echo "# Install SwiftFormat if you haven't already" >> $GITHUB_STEP_SUMMARY + echo "brew install swiftformat" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "# Format all Swift files" >> $GITHUB_STEP_SUMMARY + echo 'swiftformat --config .swiftformat .' >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY