diff --git a/.github/workflows/fix-trailing-whitespace.yml b/.github/workflows/fix-trailing-whitespace.yml new file mode 100644 index 000000000..1e18ead1a --- /dev/null +++ b/.github/workflows/fix-trailing-whitespace.yml @@ -0,0 +1,33 @@ +name: Detect trailing whitespace + +on: [pull_request] + +jobs: + whitespace: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - name: Remove whitespace and check the diff + run: | + set -eu + scripts/remove_trailing_whitespace.sh + git diff >whitespace.patch + if [ $(wc -c all_files.null.txt + +for suffix in cpp cmake h hpp js md py rb sh ; do + echo "removing trailing whitespace from files with suffix $suffix" + cat all_files.null.txt | grep -z '\.'$suffix'$' |xargs -n1 --null sed -i 's/[ \t]*$//' +done +rm all_files.null.txt +echo "done!" +