Skip to content

Commit 066711e

Browse files
committed
WIP: add whitespace check
1 parent bdb52bb commit 066711e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

.github/workflows/whitespace.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Whitespace Check
2+
# Run only on pull requests
3+
on:
4+
pull_request:
5+
jobs:
6+
check-whitespace:
7+
name: Check Whitespace
8+
runs-on: ubuntu-latest
9+
steps:
10+
- run: | # adapted from https://github.com/JuliaLang/julia/blob/f5ce7c4cb9b3e2140819b6b089530ee69aea3d2f/contrib/check-whitespace.sh
11+
set -f # disable glob expansion in this script
12+
file_patterns='
13+
*.jl
14+
*.md
15+
*.toml
16+
*.yml
17+
'
18+
19+
# TODO: Look also for trailing empty lines, and missing '\n' after the last line
20+
if git --no-pager grep --color -n --full-name -e ' $' -- $file_patterns; then
21+
echo "Error: trailing whitespace found in source file(s)"
22+
echo ""
23+
echo "This can often be fixed with:"
24+
echo " git rebase --whitespace=fix HEAD~1"
25+
echo "or"
26+
echo " git rebase --whitespace=fix master"
27+
echo "and then a forced push of the correct branch"
28+
exit 1
29+
fi
30+
31+
echo "Whitespace check found no issues"

0 commit comments

Comments
 (0)