-
Notifications
You must be signed in to change notification settings - Fork 3
121 lines (105 loc) · 3.39 KB
/
spotbugs.yml
File metadata and controls
121 lines (105 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: SpotBugs Analysis
on:
push:
branches:
- "**"
pull_request:
branches: [ master ]
permissions:
checks: write
contents: write
jobs:
spotbugs:
runs-on: ubuntu-latest
name: SpotBugs Static Analysis
steps:
- uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Create plugin dirs
run: |
mkdir -p ~/vstar_plugins
mkdir -p ~/vstar_plugin_libs
- name: Run SpotBugs
run: ant -noinput -buildfile build.xml spotbugs
- name: Extract bug counts
if: always()
id: sb-counts
run: |
XML="test_report/spotbugs/spotbugsXml.xml"
if [ -f "$XML" ]; then
TOTAL=$(grep -c '<BugInstance' "$XML" || true)
HIGH=$(grep -c 'priority="1"' "$XML" || true)
MEDIUM=$(grep -c 'priority="2"' "$XML" || true)
LOW=$(grep -c 'priority="3"' "$XML" || true)
echo "found=true" >> "$GITHUB_OUTPUT"
echo "total=$TOTAL" >> "$GITHUB_OUTPUT"
echo "high=$HIGH" >> "$GITHUB_OUTPUT"
echo "medium=$MEDIUM" >> "$GITHUB_OUTPUT"
echo "low=$LOW" >> "$GITHUB_OUTPUT"
else
echo "found=false" >> "$GITHUB_OUTPUT"
fi
- name: Post step summary
if: always() && steps.sb-counts.outputs.found == 'true'
run: |
cat >> "$GITHUB_STEP_SUMMARY" <<EOF
## SpotBugs Analysis
| Priority | Count |
|----------|-------|
| **Total** | **${{ steps.sb-counts.outputs.total }}** |
| High | ${{ steps.sb-counts.outputs.high }} |
| Medium | ${{ steps.sb-counts.outputs.medium }} |
| Low | ${{ steps.sb-counts.outputs.low }} |
EOF
- name: Upload SpotBugs report
if: always()
uses: actions/upload-artifact@v4
with:
name: spotbugs-report
path: test_report/spotbugs/
- name: Annotate PR with SpotBugs findings
if: always()
uses: lcollins/spotbugs-github-action@v3.2.0
with:
path: '**/spotbugsXml.xml'
fail-on-violation: false
- name: Checkout gh-pages
if: >-
github.event_name == 'push' &&
github.ref == 'refs/heads/master' &&
steps.sb-counts.outputs.found == 'true'
uses: actions/checkout@v4
with:
ref: gh-pages
path: _site
- name: Publish to dashboard
if: >-
github.event_name == 'push' &&
github.ref == 'refs/heads/master' &&
steps.sb-counts.outputs.found == 'true'
run: |
DATE=$(date -u +%Y-%m-%d)
cat > _site/data/spotbugs.json <<DATAJSON
{
"updated": "${DATE}",
"total": ${{ steps.sb-counts.outputs.total }},
"high": ${{ steps.sb-counts.outputs.high }},
"medium": ${{ steps.sb-counts.outputs.medium }},
"low": ${{ steps.sb-counts.outputs.low }}
}
DATAJSON
cd _site
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add -A
git diff --cached --quiet && exit 0
git commit -m "Update SpotBugs data [${DATE}]"
for i in 1 2 3; do
git pull --rebase origin gh-pages && git push origin gh-pages && break
echo "Push attempt $i failed, retrying in $((i * 5))s..."
sleep $((i * 5))
done