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.
- Loading branch information
1 parent
9441016
commit be0f418
Showing
2 changed files
with
79 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,18 @@ | ||
name: Check non-i18n logging | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'test-1' | ||
|
||
jobs: | ||
check-logging: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Run logging check | ||
run: sh 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,61 @@ | ||
#!/bin/sh | ||
|
||
DIFF=$(git diff origin/main...HEAD || true) | ||
|
||
if [ -z "$DIFF" ]; then | ||
echo "No diff found to analyze." | ||
exit 0 | ||
fi | ||
|
||
# Define patterns as a single string instead of an array | ||
PATTERNS=".info( .infof( .warn( .warnf( .error( .errorf( .fatal( .fatalf( System.out.print System.err.print .printStackTrace)" | ||
|
||
ERRORS="" | ||
CURRENT_FILE="" | ||
|
||
# Use echo instead of printf for pattern matching | ||
echo "$DIFF" | while IFS= read -r line; do | ||
# Update the current file if a new diff starts | ||
case "$line" in | ||
diff\ --git\ a/*\ b/*) | ||
CURRENT_FILE=$(echo "$line" | awk '{print $3}' | sed 's/^a\///') | ||
;; | ||
esac | ||
|
||
case "$line" in | ||
+[^+]*) | ||
# Ignore lines in the test directories | ||
case "$CURRENT_FILE" in | ||
*src/test/*|*testsuite/*|*check_logging.sh*) | ||
continue | ||
;; | ||
esac | ||
|
||
# Check for any of the patterns, ensuring "//" doesn't precede them | ||
for pattern in $PATTERNS; do | ||
case "$line" in | ||
*"$pattern"*) | ||
# Ensure the pattern is not commented out with "//" | ||
case "$line" in | ||
*"//"*) | ||
;; | ||
*) | ||
# Capture the error line and its context | ||
ERRORS="$ERRORS$line\nFile: $CURRENT_FILE\n\n" | ||
;; | ||
esac | ||
;; | ||
esac | ||
done | ||
;; | ||
esac | ||
done | ||
|
||
if [ -n "$ERRORS" ]; then | ||
echo "Logging statements found that should be internationalized or converted to a lower log level:\n" | ||
echo "$ERRORS" | ||
exit 1 | ||
else | ||
echo "No problematic logging statements found." | ||
exit 0 | ||
fi |