-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add support for errorprone 2.24.1 static analysis tool and Github Action to check for issues reported #12425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
+136
−3
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
76b0037
Add support for errorprone 2.24.1 static analysis tool and Github Act...
Pearl1594 4d7e8c5
add newline
Pearl1594 585da2d
temporarily add 4.20 and PR branch to gha
Pearl1594 7c644a2
Update gha
Pearl1594 683b7e5
fix newline and whitespace issues
Pearl1594 af22db2
Update gha
Pearl1594 076d250
temp: verification related change - needs revert
Pearl1594 15c1427
change pr branch on which this wf is run - needs to be reverted
Pearl1594 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
122 changes: 122 additions & 0 deletions
.github/workflows/errorprone.yml
This file contains hidden or 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,122 @@ | ||
| # 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: [ add-errorprone ] | ||
| pull_request: | ||
| branches: [ ghi11438-errorprone-fixes' ] | ||
|
|
||
| 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) | ||
| id: errorprone | ||
| 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 | ||
|
|
||
| set -o pipefail | ||
|
|
||
| # Use -fae (fail-at-end) to build all modules and report failures at the end | ||
| # Run 'test' phase to compile and test all modules | ||
| mvn -fae clean test -T$(nproc) 2>&1 | tee errorprone.log | ||
| MVN_EXIT=${PIPESTATUS[0]} | ||
|
|
||
| echo "mvn_exit=${MVN_EXIT}" >> $GITHUB_OUTPUT | ||
| echo "::endgroup::" | ||
|
|
||
| exit 0 | ||
| continue-on-error: true | ||
|
|
||
| - name: Check for Error Prone Issues | ||
| id: check-errors | ||
| run: | | ||
| HAS_ERRORS=false | ||
|
|
||
| if [ "${{ steps.errorprone.outputs.mvn_exit }}" != "0" ]; then | ||
| HAS_ERRORS=true | ||
| echo "Maven build exited with code ${{ steps.errorprone.outputs.mvn_exit }}" | ||
| fi | ||
|
|
||
| if grep -q "error: \[" errorprone.log; then | ||
| HAS_ERRORS=true | ||
| fi | ||
|
|
||
| if grep -q "^\[ERROR\]" errorprone.log; then | ||
| HAS_ERRORS=true | ||
| fi | ||
|
|
||
| if [ "$HAS_ERRORS" = "true" ]; then | ||
| echo "has_errors=true" >> $GITHUB_OUTPUT | ||
| echo "::error::Error Prone and/or compilation issues found in the code" | ||
| echo "" | ||
| echo "=== Error Prone Issues ===" | ||
| grep -n "error: \[" errorprone.log | head -50 || echo "No Error Prone specific issues" | ||
| echo "" | ||
| echo "=== Maven [ERROR] Lines ===" | ||
| grep -n "^\[ERROR\]" errorprone.log | head -50 || echo "No Maven errors" | ||
| echo "" | ||
|
|
||
| echo "## ⚠️ Error Prone Analysis Failed" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "Error Prone static analysis and/or compilation detected issues in this PR." >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "### Error Prone Issues (first 50):" >> $GITHUB_STEP_SUMMARY | ||
| echo '```' >> $GITHUB_STEP_SUMMARY | ||
| grep -n "error: \[" errorprone.log | head -50 >> $GITHUB_STEP_SUMMARY || echo "None" >> $GITHUB_STEP_SUMMARY | ||
| echo '```' >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "### Maven Compilation Errors (first 50):" >> $GITHUB_STEP_SUMMARY | ||
| echo '```' >> $GITHUB_STEP_SUMMARY | ||
| grep -n "^\[ERROR\]" errorprone.log | head -50 >> $GITHUB_STEP_SUMMARY || echo "None" >> $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" | ||
|
|
||
| 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 |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -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> | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.