forked from wildfly/wildfly
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WFLY-19605 Add a CI job to check for non-i18n INFO/WARN/ERROR logging
- Loading branch information
1 parent
9441016
commit 987c363
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Check PR Logging | ||
|
||
on: | ||
push: | ||
branches: | ||
- WFLY-19605 | ||
|
||
jobs: | ||
check-logging: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Run logging check | ||
run: ./check_logging.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
|
||
# Fetch the PR diff | ||
DIFF=$(git diff origin/WFLY-19605...HEAD) | ||
|
||
# Define the patterns to search for | ||
PATTERNS=( | ||
".info(" | ||
".infof(" | ||
".warn(" | ||
".warnf(" | ||
".error(" | ||
".errorf(" | ||
".fatal(" | ||
".fatalf(" | ||
"System.out.print" | ||
"System.err.print" | ||
".printStackTrace" | ||
) | ||
|
||
# Loop through the diff and check for patterns | ||
ERROR_FOUND=0 | ||
while IFS= read -r line; do | ||
# Check if the line is an added line | ||
if [[ "$line" =~ ^\+[^+] ]]; then | ||
# Ignore test directories | ||
if [[ "$line" != *"src/test/"* ]] && [[ "$line" != *"testsuite/"* ]]; then | ||
# Ignore comments | ||
if [[ "$line" != *"//"* ]]; then | ||
# Check for any of the patterns | ||
for pattern in "${PATTERNS[@]}"; do | ||
if [[ "$line" == *"$pattern"* ]]; then | ||
ERROR_FOUND=1 | ||
break 2 | ||
fi | ||
done | ||
fi | ||
fi | ||
fi | ||
done <<< "$DIFF" | ||
|
||
# Fail if any patterns are found | ||
if [ "$ERROR_FOUND" -eq 1 ]; then | ||
echo "Logging statements found that should be internationalized or converted to a lower log level." | ||
exit 1 | ||
else | ||
echo "No problematic logging statements found." | ||
exit 0 | ||
fi |