Skip to content

Commit

Permalink
WIP: add whitespace check
Browse files Browse the repository at this point in the history
  • Loading branch information
simeonschaub committed Sep 21, 2021
1 parent bdb52bb commit 6cbe567
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/whitespace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Whitespace Check
# Run only on pull requests
on:
pull_request:
jobs:
check-whitespace:
name: Check Whitespace
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: | # adapted from https://github.com/JuliaLang/julia/blob/f5ce7c4cb9b3e2140819b6b089530ee69aea3d2f/contrib/check-whitespace.sh
set -f # disable glob expansion in this script
file_patterns='
*.jl
*.md
*.toml
*.yml
'
# TODO: Look also for trailing empty lines, and missing '\n' after the last line
if git --no-pager grep --color -n --full-name -e ' $' -- $file_patterns; then
echo "Error: trailing whitespace found in source file(s)"
echo ""
echo "This can often be fixed with:"
echo " git rebase --whitespace=fix HEAD~1"
echo "or"
echo " git rebase --whitespace=fix master"
echo "and then a forced push of the correct branch"
exit 1
fi
echo "Whitespace check found no issues"

0 comments on commit 6cbe567

Please sign in to comment.