Skip to content

Commit 2125a4c

Browse files
committed
GitHub Action: Add error prone static analysis
1 parent 6a324da commit 2125a4c

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

.github/workflows/errorprone.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: Error Prone Analysis
19+
20+
on:
21+
push:
22+
branches: [ main ]
23+
pull_request:
24+
branches: [ main ]
25+
26+
concurrency:
27+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
28+
cancel-in-progress: true
29+
30+
permissions:
31+
contents: read
32+
33+
jobs:
34+
errorprone:
35+
runs-on: ubuntu-22.04
36+
steps:
37+
- uses: actions/checkout@v4
38+
39+
- name: Set up JDK 11
40+
uses: actions/setup-java@v4
41+
with:
42+
java-version: '11'
43+
distribution: 'adopt'
44+
architecture: x64
45+
cache: maven
46+
47+
- name: Run Error Prone Static Analysis
48+
run: |
49+
echo "::group::Error Prone Analysis"
50+
mvn clean compile -DskipTests -T$(nproc) 2>&1 | tee errorprone.log
51+
echo "::endgroup::"
52+
continue-on-error: true
53+
54+
- name: Check for Error Prone Issues
55+
id: check-errors
56+
run: |
57+
if grep -q "error: \[" errorprone.log; then
58+
echo "has_errors=true" >> $GITHUB_OUTPUT
59+
echo "::error::Error Prone found issues in the code"
60+
echo ""
61+
echo "=== Error Prone Issues Found ==="
62+
grep -B 2 "error: \[" errorprone.log | head -50
63+
echo ""
64+
65+
# Create job summary
66+
echo "## ⚠️ Error Prone Analysis Failed" >> $GITHUB_STEP_SUMMARY
67+
echo "" >> $GITHUB_STEP_SUMMARY
68+
echo "Error Prone static analysis detected issues in this PR." >> $GITHUB_STEP_SUMMARY
69+
echo "" >> $GITHUB_STEP_SUMMARY
70+
echo "### Issues Found (first 50):" >> $GITHUB_STEP_SUMMARY
71+
echo '```' >> $GITHUB_STEP_SUMMARY
72+
grep -B 2 "error: \[" errorprone.log | head -50 >> $GITHUB_STEP_SUMMARY
73+
echo '```' >> $GITHUB_STEP_SUMMARY
74+
echo "" >> $GITHUB_STEP_SUMMARY
75+
echo "See the [Error Prone documentation](https://errorprone.info/) for details on each bug pattern." >> $GITHUB_STEP_SUMMARY
76+
else
77+
echo "has_errors=false" >> $GITHUB_OUTPUT
78+
echo "✅ No Error Prone issues found"
79+
80+
# Create success summary
81+
echo "## ✅ Error Prone Analysis Passed" >> $GITHUB_STEP_SUMMARY
82+
echo "" >> $GITHUB_STEP_SUMMARY
83+
echo "No issues detected by Error Prone static analysis." >> $GITHUB_STEP_SUMMARY
84+
fi
85+
86+
87+
- name: Fail if errors found
88+
if: steps.check-errors.outputs.has_errors == 'true'
89+
run: exit 1

0 commit comments

Comments
 (0)