-
Notifications
You must be signed in to change notification settings - Fork 146
161 lines (135 loc) · 6.33 KB
/
GHA-Spotbugs.yml
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# GHA to run Spotbugs against top level Java agent projects. Both HTML and XML files are generated for each project
# and attached to the workflow run page under the "Artifacts" section. The files are downloaded as a zip (per project).
# The XML file can be analyzed inside the Spotbugs GUI: https://spotbugs.readthedocs.io/en/stable/running.html
name: Execute Spotbugs
on:
workflow_dispatch:
inputs:
agent-ref:
description: 'The ref (branch, SHA, tag) to run spotbugs on'
required: false
default: 'main'
type: string
schedule:
- cron: '0 9 * * *'
jobs:
spotbugs:
timeout-minutes: 15
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # pin@v4
with:
ref: ${{ inputs.agent-ref || github.ref || 'main' }}
- name: Configure AWS Credentials
if: ${{ env.AWS_KEY != '' }}
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # pin@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Setup environment
uses: ./.github/actions/setup-environment
- name: Build newrelicJar
run: ./gradlew $GRADLE_OPTIONS clean jar
- name: Execute Spotbugs
run: ./gradlew $GRADLE_OPTIONS spotbugsMain
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # pin@v4
with:
name: all-spotbugs-results
path: '**/build/spotbugs/main.*'
retention-days: 5
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # pin@v4
with:
name: newrelic-agent-spotbugs-results
path: 'newrelic-agent/build/spotbugs/main.*'
retention-days: 5
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # pin@v4
with:
name: newrelic-weaver-spotbugs-results
path: 'newrelic-weaver/build/spotbugs/main.*'
retention-days: 5
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # pin@v4
with:
name: agent-bridge-spotbugs-results
path: 'agent-bridge/build/spotbugs/main.*'
retention-days: 5
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # pin@v4
with:
name: agent-model-spotbugs-results
path: 'agent-model/build/spotbugs/main.*'
retention-days: 5
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # pin@v4
with:
name: newrelic-api-spotbugs-results
path: 'newrelic-api/build/spotbugs/main.*'
retention-days: 5
publish:
needs: spotbugs
runs-on: ubuntu-20.04
concurrency: gh-pages
env:
BRANCH_NAME: ${{ inputs.agent-ref || 'main' }}
steps:
- name: Checkout GhPages branch
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # pin@v4
with:
ref: 'gh-pages'
path: 'gh-pages'
- name: Configure Git
run: |
git config --global user.name "GitHub Actions Bot"
git config --global user.email "[email protected]"
- name: Clear any artifacts from previous runs
run: |
rm -rf gh-pages/spotbugs/${{ env.BRANCH_NAME }}
# Download reports
- name: Download spotbugs reports 1
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # pin@v4
with:
name: newrelic-agent-spotbugs-results
path: gh-pages/spotbugs/${{ env.BRANCH_NAME }}/newrelic-agent-spotbugs-results
- name: Download spotbugs reports 2
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # pin@v4
with:
name: newrelic-weaver-spotbugs-results
path: gh-pages/spotbugs/${{ env.BRANCH_NAME }}/newrelic-weaver-spotbugs-results
- name: Download spotbugs reports 3
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # pin@v4
with:
name: agent-bridge-spotbugs-results
path: gh-pages/spotbugs/${{ env.BRANCH_NAME }}/agent-bridge-spotbugs-results
- name: Download spotbugs reports 4
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # pin@v4
with:
name: agent-model-spotbugs-results
path: gh-pages/spotbugs/${{ env.BRANCH_NAME }}/agent-model-spotbugs-results
- name: Download spotbugs reports 5
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # pin@v4
with:
name: newrelic-api-spotbugs-results
path: gh-pages/spotbugs/${{ env.BRANCH_NAME }}/newrelic-api-spotbugs-results
# By default, GH-Pages only recognizes index.html files as landing pages.
# This can be reconfigured at the repository level, but not at the directory level.
# So copy the main.html files generated by spotbugs into index.html files.
- name: Copy the main.html files into index.html files
run: |
cd gh-pages/spotbugs/${{ env.BRANCH_NAME }}
cp newrelic-agent-spotbugs-results/main.html newrelic-agent-spotbugs-results/index.html
cp newrelic-weaver-spotbugs-results/main.html newrelic-weaver-spotbugs-results/index.html
cp agent-bridge-spotbugs-results/main.html agent-bridge-spotbugs-results/index.html
cp agent-model-spotbugs-results/main.html agent-model-spotbugs-results/index.html
cp newrelic-api-spotbugs-results/main.html newrelic-api-spotbugs-results/index.html
- name: Generate index page
run: |
python gh-pages/utils/writeIndexPage.py gh-pages/spotbugs/${{ env.BRANCH_NAME }}
# Used for cleanup and to ensure a file is always changed so the commit succeeds.
- name: Add date file
run: echo $(date -u +%s) > gh-pages/spotbugs/${{ env.BRANCH_NAME }}/date.txt
- name: Commit and push test reports to gh-pages
run: |
cd gh-pages
git add -f spotbugs/*
git commit -m "Update test reports spotbugs project"
git push
- name: Summary step
run: echo "[View spotbugs results](https://newrelic.github.io/newrelic-java-agent/spotbugs/${{ env.BRANCH_NAME }})" >> $GITHUB_STEP_SUMMARY