Copilot commented on code in PR #7781:
URL: https://github.com/apache/incubator-seata/pull/7781#discussion_r2525473621
##########
.github/workflows/build.yml:
##########
@@ -84,7 +84,13 @@ jobs:
-Dpmd.skip=false -Dlicense.skip=false -DredisCaseEnabled=true
-DnacosCaseEnabled=true \
-e -B \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
\
- -Dorg.slf4j.simpleLogger.log.net.sourceforge.pmd=error;
+ -Dorg.slf4j.simpleLogger.log.net.sourceforge.pmd=info \
+ 2>&1 | tee build.log | while read line; do
+ echo "$line"
+ if [[ "$line" == *"PMD Failure"* ]]; then
+ echo "::error::PMD Violations Detected! Check Details
Above!"
+ fi
+ done
Review Comment:
The pipe to `while read` loop creates a subshell that can mask the Maven
command's exit code. If Maven fails (including PMD failures), the workflow step
might still succeed because the exit code of the last command in the pipeline
(the while loop) is returned instead of Maven's exit code.
To fix this, you should:
1. Set `set -o pipefail` to ensure the pipeline fails if Maven fails
2. Capture and preserve the Maven exit code explicitly
Suggested fix:
```bash
set -o pipefail
./mvnw -T 4C clean test \
-Dpmd.skip=false -Dlicense.skip=false -DredisCaseEnabled=true
-DnacosCaseEnabled=true \
-e -B \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
\
-Dorg.slf4j.simpleLogger.log.net.sourceforge.pmd=info \
2>&1 | tee build.log | while read line; do
echo "$line"
if [[ "$line" == *"PMD Failure"* ]]; then
echo "::error::PMD Violations Detected! Check Details Above!"
fi
done
exit_code=${PIPESTATUS[0]}
exit $exit_code
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]