From 6cbe5678b471477f91371fdd734fd5bc407204bc Mon Sep 17 00:00:00 2001 From: Simeon Schaub Date: Tue, 21 Sep 2021 17:41:18 -0400 Subject: [PATCH] WIP: add whitespace check --- .github/workflows/whitespace.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/whitespace.yml diff --git a/.github/workflows/whitespace.yml b/.github/workflows/whitespace.yml new file mode 100644 index 000000000..f865fdeb5 --- /dev/null +++ b/.github/workflows/whitespace.yml @@ -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"