Skip to content

Commit

Permalink
Merge pull request #2033 from kylemhall/fix_check_tabs_vs_spaces
Browse files Browse the repository at this point in the history
Fix the check_tabs_vs_spaces GitHub Action
  • Loading branch information
mdnoble73 authored Sep 3, 2024
2 parents d3fd983 + 0968966 commit 73444d2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
31 changes: 24 additions & 7 deletions .github/workflows/pull_request_qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Check Pull Request for QA Issues

on:
pull_request:
push:

jobs:
check_release_notes:
Expand Down Expand Up @@ -58,16 +59,32 @@ jobs:
# Loop through each file and check for spaces used instead of tabs
EXIT_CODE=0
declare -A RESULTS
for file in $MODIFIED_FILES; do
echo "Found modified file: $file";
if [[ $file == *.php || $file == *.js || $file == *.java ]]; then
#echo "Checking $file for whitespace issues"
DIFF=$(git diff official/$DEFAULT_BRANCH HEAD -- $file | grep "^\+\s* {2,}")
if [[ $file == *.php || $file == *.js || $file == *.java ]]; then
DIFF=$(git diff official/$DEFAULT_BRANCH HEAD -- $file)
#echo "DIFF: $DIFF"
if [[ $DIFF =~ " " ]]; then
echo "Detected spaces instead of tabs in $file"
EXIT_CODE=1
fi
while IFS= read -r RAW_LINE; do
if [[ $RAW_LINE =~ ^\+ ]]; then
LINE=$(echo -e "$RAW_LINE" | sed 's/\t/_TAB_/g')
if [[ $LINE =~ ^\+(_TAB_)*[[:space:]][[:space:]]+ ]]; then
echo "Bad Line: $RAW_LINE"
RESULTS[$file]=1
EXIT_CODE=1
fi
fi
done <<< "$DIFF"
fi
done
if [ $EXIT_CODE -eq 1 ]; then
echo "FILES CONTAINING SPACES INSTEAD OF TABS:"
for key in "${!RESULTS[@]}"; do
echo "$key"
done
else
echo "NO SPACES FOUND!";
fi
exit $EXIT_CODE
3 changes: 2 additions & 1 deletion code/web/release_notes/24.09.00.MD
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
- Add GitHub Actions to check pull requests for release notes (*KMH*)
- Add GitHub Actions to check pull requests for spaces vs tabs (*KMH*)
- Prevent GitHub Actions from attempting to push Docker images unless the push is to the official rep (*KMH*)
- Fix GitHub Action to check pull request for spaces vs tabs (*KMH*)

// Liz Rea
### Other Updates
Expand Down Expand Up @@ -239,4 +240,4 @@
- Chloe Zermatten (CZ)

- Theke Solutions
- Lucas Montoya (LM)
- Lucas Montoya (LM)

0 comments on commit 73444d2

Please sign in to comment.