mirror of https://github.com/apache/cloudstack.git
Add support for errorprone 2.24.1 static analysis tool and Github Action to check for issues reported
This commit is contained in:
parent
5c1f9315ce
commit
3b70818567
|
|
@ -0,0 +1,93 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
name: Error Prone Analysis
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
errorprone:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '11'
|
||||
distribution: 'adopt'
|
||||
architecture: x64
|
||||
cache: maven
|
||||
|
||||
- name: Run Error Prone Static Analysis (Strict Mode)
|
||||
run: |
|
||||
echo "::group::Error Prone Analysis"
|
||||
# Temporarily remove -XepAllErrorsAsWarnings to run in strict mode
|
||||
sed -i 's/-Xplugin:ErrorProne -XepAllErrorsAsWarnings/-Xplugin:ErrorProne/g' pom.xml
|
||||
mvn clean compile -DskipTests -T$(nproc) 2>&1 | tee errorprone.log
|
||||
BUILD_RESULT=$?
|
||||
echo "::endgroup::"
|
||||
exit $BUILD_RESULT
|
||||
continue-on-error: true
|
||||
|
||||
- name: Check for Error Prone Issues
|
||||
id: check-errors
|
||||
run: |
|
||||
if grep -q "error: \[" errorprone.log; then
|
||||
echo "has_errors=true" >> $GITHUB_OUTPUT
|
||||
echo "::error::Error Prone found issues in the code"
|
||||
echo ""
|
||||
echo "=== Error Prone Issues Found ==="
|
||||
grep -B 2 "error: \[" errorprone.log | head -50
|
||||
echo ""
|
||||
|
||||
# Create job summary
|
||||
echo "## ⚠️ Error Prone Analysis Failed" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "Error Prone static analysis detected issues in this PR." >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "### Issues Found (first 50):" >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
grep -B 2 "error: \[" errorprone.log | head -50 >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "See the [Error Prone documentation](https://errorprone.info/) for details on each bug pattern." >> $GITHUB_STEP_SUMMARY
|
||||
else
|
||||
echo "has_errors=false" >> $GITHUB_OUTPUT
|
||||
echo "✅ No Error Prone issues found"
|
||||
|
||||
# Create success summary
|
||||
echo "## ✅ Error Prone Analysis Passed" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "No issues detected by Error Prone static analysis." >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
|
||||
- name: Fail if errors found
|
||||
if: steps.check-errors.outputs.has_errors == 'true'
|
||||
run: exit 1
|
||||
|
||||
19
pom.xml
19
pom.xml
|
|
@ -80,6 +80,7 @@
|
|||
<cs.surefire-plugin.version>2.22.2</cs.surefire-plugin.version>
|
||||
<cs.clover-maven-plugin.version>4.4.1</cs.clover-maven-plugin.version>
|
||||
<cs.exec-maven-plugin.version>3.2.0</cs.exec-maven-plugin.version>
|
||||
<cs.errorprone.version>2.24.1</cs.errorprone.version>
|
||||
|
||||
<!-- Logging versions -->
|
||||
<cs.log4j.version>2.19.0</cs.log4j.version>
|
||||
|
|
@ -1094,15 +1095,25 @@
|
|||
<configuration>
|
||||
<source>${cs.jdk.version}</source>
|
||||
<target>${cs.jdk.version}</target>
|
||||
<fork>true</fork>
|
||||
<meminitial>128m</meminitial>
|
||||
<maxmem>512m</maxmem>
|
||||
<encoding>UTF-8</encoding>
|
||||
<compilerArgs>
|
||||
<arg>-XDignore.symbol.file=true</arg>
|
||||
<arg>--add-opens=java.base/java.lang=ALL-UNNAMED</arg>
|
||||
<arg>--add-exports=java.base/sun.security.x509=ALL-UNNAMED</arg>
|
||||
<arg>--add-exports=java.base/sun.security.provider=ALL-UNNAMED</arg>
|
||||
<arg>-XDcompilePolicy=simple</arg>
|
||||
<arg>-Xplugin:ErrorProne -XepAllErrorsAsWarnings</arg>
|
||||
</compilerArgs>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>com.google.errorprone</groupId>
|
||||
<artifactId>error_prone_core</artifactId>
|
||||
<version>${cs.errorprone.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
<fork>true</fork>
|
||||
<meminitial>128m</meminitial>
|
||||
<maxmem>512m</maxmem>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
|
@ -1452,4 +1463,4 @@
|
|||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
</project>
|
||||
Loading…
Reference in New Issue