From 9887ad9ad9e9378369f6be16052d40192c8fd674 Mon Sep 17 00:00:00 2001 From: bappisinsane <108801304+bappisinsane@users.noreply.github.com> Date: Thu, 15 Oct 2026 13:40:58 +0600 Subject: [PATCH] ci: add GitHub Actions workflow to check for trailing spaces Add a GitHub Actions workflow that runs on pull requests and pushes to main, checking for trailing whitespace in all code files. The check fails with a clear error message listing offending files. Closes #104 --- .github/workflows/trailing-spaces.yml | 50 +++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/trailing-spaces.yml diff --git a/.github/workflows/trailing-spaces.yml b/.github/workflows/trailing-spaces.yml new file mode 100644 index 00000000..cf10df3a --- /dev/null +++ b/.github/workflows/trailing-spaces.yml @@ -0,0 +1,50 @@ +name: Check Trailing Spaces + +on: + pull_request: + types: [opened, synchronize, reopened] + push: + branches: + - main + +jobs: + trailing-spaces: + name: Check for trailing spaces + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Check for trailing spaces + run: | + echo "Checking for trailing whitespace in code files..." + + # Find files with trailing spaces, excluding binary files and common non-code directories + # File types to check: source code, config, docs, scripts + TRAILING_FILES=$(grep -rIl '[[:blank:]]$' \ + --exclude-dir=.git \ + --exclude-dir=node_modules \ + --exclude-dir=vendor \ + --exclude-dir=dist \ + --exclude-dir=build \ + --exclude-dir=__pycache__ \ + --exclude-dir=.venv \ + --exclude-dir=venv \ + --exclude='*.lock' \ + --exclude='*.min.js' \ + --exclude='*.min.css' \ + . 2>/dev/null || true) + + if [ -n "$TRAILING_FILES" ]; then + echo "" + echo "❌ Trailing whitespace found in the following files:" + echo "" + echo "$TRAILING_FILES" + echo "" + echo "Please remove trailing whitespace from these files." + echo "You can use: sed -i 's/[[:blank:]]*$//' " + echo "" + exit 1 + else + echo "✅ No trailing whitespace found. All clean!" + fi