From 9f78559cc88b9b276a97a8e1e32bf132a74708f2 Mon Sep 17 00:00:00 2001 From: Paul Dreik Date: Tue, 3 Nov 2020 20:41:19 +0100 Subject: [PATCH] detect trailing whitespace in a CI job (#1268) --- .github/workflows/fix-trailing-whitespace.yml | 33 +++++++++++++++++++ scripts/remove_trailing_whitespace.sh | 19 +++++++++++ 2 files changed, 52 insertions(+) create mode 100644 .github/workflows/fix-trailing-whitespace.yml create mode 100755 scripts/remove_trailing_whitespace.sh 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!" +