Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/trailing-whitespace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Check for trailing whitespace
run-name: Check for trailing whitespace

on:
pull_request:

jobs:
check-for-trailing-whitespace:
uses: department-of-veterans-affairs/vsp-github-actions/trailing-whitespace@94236ddb87d2433988668100164716f40a908368
33 changes: 33 additions & 0 deletions trailing-whitespace/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "Comment a Plan on a PR"

on:
pull_request:

jobs:
setup:
name: Check for trailing whitespace
runs-on: ubuntu-latest
steps:
- id: trailing-whitespace
run: |
excludes=':(exclude)*.crt :(exclude)*.csv :(exclude)*/.terraform.lock.hcl'
git_flags='--name-only --diff-filter=AM'
file_list=($(git diff $git_flags $excludes) $(git diff --staged $git_flags $excludes))

printf 'Checking:\n'
printf '\u2023 %s\n' "${file_list[@]}"

# Check for trailing whitespace
trailing_whitespace=($(grep --perl-regexp --binary-files=without-match --files-with-match '\s+$' "${file_list[@]}"))

# Redirect output to stderr.
exec 1>&2

if [[ ${#trailing_whitespace[@]} != 0 ]] ; then
printf '\n\u2716 Trailing whitespace(s) found\n'
grep --perl-regexp --binary-files=without-match --line-number --with-filename '\s+$' "${trailing_whitespace[@]}"
exit 1
else
printf '\n\u2714 No trailing whitespace detected\n\n'
exit 0
fi