Skip to content

Commit 14fc580

Browse files
committed
Update configuration of quality monitor for the upcoming v4 release
1 parent 471fee2 commit 14fc580

File tree

6 files changed

+285
-18
lines changed

6 files changed

+285
-18
lines changed

.github/quality-gates-pr.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"qualityGates": [
3+
{
4+
"metric": "test-success-rate",
5+
"name": "Overall Tests Success Rate",
6+
"threshold": 100.0,
7+
"criticality": "FAILURE"
8+
},
9+
{
10+
"metric": "line",
11+
"name": "Line Coverage in New Code",
12+
"scope": "new",
13+
"threshold": 90.0,
14+
"criticality": "UNSTABLE"
15+
},
16+
{
17+
"metric": "branch",
18+
"name": "Branch Coverage in New Code",
19+
"scope": "new",
20+
"threshold": 90.0,
21+
"criticality": "UNSTABLE"
22+
},
23+
{
24+
"metric": "mutation",
25+
"name": "Mutation Coverage in New Code",
26+
"scope": "new",
27+
"threshold": 90.0,
28+
"criticality": "UNSTABLE"
29+
},
30+
{
31+
"metric": "bugs",
32+
"name": "Potential Bugs in Whole Project",
33+
"threshold": 0.0,
34+
"criticality": "FAILURE"
35+
},
36+
{
37+
"metric": "style",
38+
"name": "Style Violation in Whole Project",
39+
"threshold": 0.0,
40+
"criticality": "FAILURE"
41+
}
42+
]
43+
}

.github/quality-gates.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
},
99
{
1010
"metric": "line",
11+
"name": "Line Coverage",
1112
"threshold": 80.0,
1213
"criticality": "UNSTABLE"
1314
},
1415
{
1516
"metric": "branch",
17+
"name": "Branch Coverage",
1618
"threshold": 75.0,
1719
"criticality": "UNSTABLE"
1820
},

.github/quality-monitor-pr.json

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
{
2+
"tests": {
3+
"name": "Tests",
4+
"tools": [
5+
{
6+
"id": "junit",
7+
"name": "Unit Tests",
8+
"pattern": "**/target/surefire-reports/TEST*.xml"
9+
},
10+
{
11+
"id": "junit",
12+
"icon": "no_entry",
13+
"name": "Architecture Tests",
14+
"pattern": "**/target/archunit-reports/TEST*.xml"
15+
}
16+
]
17+
},
18+
"analysis": [
19+
{
20+
"name": "Style",
21+
"id": "style",
22+
"tools": [
23+
{
24+
"id": "checkstyle",
25+
"pattern": "**/target/**checkstyle-result.xml"
26+
},
27+
{
28+
"id": "pmd",
29+
"pattern": "**/target/pmd-*/pmd.xml"
30+
},
31+
{
32+
"id": "java",
33+
"icon": "coffee",
34+
"pattern": "**/maven.log"
35+
}
36+
]
37+
},
38+
{
39+
"name": "Bugs",
40+
"id": "bugs",
41+
"icon": "bug",
42+
"tools": [
43+
{
44+
"id": "spotbugs",
45+
"sourcePath": "src/main/java",
46+
"pattern": "**/target/spotbugsXml.xml"
47+
},
48+
{
49+
"id": "error-prone",
50+
"pattern": "**/maven.log"
51+
}
52+
]
53+
},
54+
{
55+
"name": "API Problems",
56+
"id": "api",
57+
"icon": "no_entry_sign",
58+
"tools": [
59+
{
60+
"id": "revapi",
61+
"sourcePath": "src/main/java",
62+
"pattern": "**/target/revapi-result.json"
63+
}
64+
]
65+
},
66+
{
67+
"name": "Vulnerabilities",
68+
"id": "vulnerabilities",
69+
"icon": "shield",
70+
"tools": [
71+
{
72+
"id": "owasp-dependency-check",
73+
"icon": "shield",
74+
"pattern": "**/target/dependency-check-report.json"
75+
}
76+
]
77+
}
78+
],
79+
"coverage": [
80+
{
81+
"name": "Coverage for New Code",
82+
"tools": [
83+
{
84+
"id": "jacoco",
85+
"metric": "line",
86+
"scope": "new",
87+
"sourcePath": "src/main/java",
88+
"pattern": "**/target/site/jacoco/jacoco.xml"
89+
},
90+
{
91+
"id": "jacoco",
92+
"metric": "branch",
93+
"scope": "new",
94+
"sourcePath": "src/main/java",
95+
"pattern": "**/target/site/jacoco/jacoco.xml"
96+
},
97+
{
98+
"id": "pit",
99+
"scope": "new",
100+
"metric": "mutation",
101+
"sourcePath": "src/main/java",
102+
"pattern": "**/target/pit-reports/mutations.xml"
103+
},
104+
{
105+
"id": "pit",
106+
"metric": "test-strength",
107+
"scope": "new",
108+
"sourcePath": "src/main/java",
109+
"pattern": "**/target/pit-reports/mutations.xml"
110+
}
111+
]
112+
},
113+
{
114+
"name": "Coverage for Whole Project",
115+
"tools": [
116+
{
117+
"id": "jacoco",
118+
"metric": "line",
119+
"sourcePath": "src/main/java",
120+
"pattern": "**/target/site/jacoco/jacoco.xml"
121+
},
122+
{
123+
"id": "jacoco",
124+
"metric": "branch",
125+
"sourcePath": "src/main/java",
126+
"pattern": "**/target/site/jacoco/jacoco.xml"
127+
},
128+
{
129+
"id": "pit",
130+
"metric": "mutation",
131+
"sourcePath": "src/main/java",
132+
"pattern": "**/target/pit-reports/mutations.xml"
133+
},
134+
{
135+
"id": "pit",
136+
"metric": "test-strength",
137+
"sourcePath": "src/main/java",
138+
"pattern": "**/target/pit-reports/mutations.xml"
139+
}
140+
]
141+
}
142+
],
143+
"metrics": {
144+
"name": "Software Metrics",
145+
"tools": [
146+
{
147+
"id": "metrics",
148+
"pattern": "**/metrics/pmd.xml",
149+
"metric": "CYCLOMATIC_COMPLEXITY"
150+
},
151+
{
152+
"id": "metrics",
153+
"pattern": "**/metrics/pmd.xml",
154+
"metric": "COGNITIVE_COMPLEXITY"
155+
},
156+
{
157+
"id": "metrics",
158+
"pattern": "**/metrics/pmd.xml",
159+
"metric": "NPATH_COMPLEXITY"
160+
},
161+
{
162+
"id": "metrics",
163+
"pattern": "**/metrics/pmd.xml",
164+
"metric": "LOC"
165+
},
166+
{
167+
"id": "metrics",
168+
"pattern": "**/metrics/pmd.xml",
169+
"metric": "NCSS"
170+
},
171+
{
172+
"id": "metrics",
173+
"pattern": "**/metrics/pmd.xml",
174+
"metric": "COHESION"
175+
},
176+
{
177+
"id": "metrics",
178+
"pattern": "**/metrics/pmd.xml",
179+
"metric": "WEIGHT_OF_CLASS"
180+
}
181+
]
182+
}
183+
}

.github/quality-monitor.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
{
7878
"icon": "shield",
7979
"id": "owasp-dependency-check",
80-
"icon": "shield",
8180
"pattern": "**/target/dependency-check-report.json"
8281
}
8382
]
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: 'Quality Monitor Comment PR'
2+
3+
on:
4+
workflow_run:
5+
workflows: [ "Quality Monitor Build" ]
6+
types: [ completed ]
7+
8+
permissions:
9+
actions: read
10+
contents: read
11+
pull-requests: write
12+
checks: write
13+
14+
jobs:
15+
comment:
16+
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' }}
17+
runs-on: ubuntu-latest
18+
name: Comment on PR
19+
20+
steps:
21+
- name: Extract PR number and SHA
22+
id: pr
23+
run: |
24+
pr_number='${{ github.event.workflow_run.pull_requests[0].number }}'
25+
echo "number=$pr_number" >> "$GITHUB_OUTPUT"
26+
sha='${{ github.event.workflow_run.head_sha }}'
27+
echo "sha=$sha" >> "$GITHUB_OUTPUT"
28+
- name: Checkout PR
29+
uses: actions/checkout@v6
30+
with:
31+
ref: ${{ steps.pr.outputs.sha }}
32+
- name: Download PR Quality Reports from Quality Monitor Build workflow
33+
uses: dawidd6/action-download-artifact@v11
34+
with:
35+
run_id: ${{ github.event.workflow_run.id }}
36+
name: quality-reports
37+
- name: Read Quality Monitor Configuration
38+
id: quality-monitor
39+
run: echo "json=$(jq -c . .github/quality-monitor-pr.json)" >> "$GITHUB_OUTPUT"
40+
- name: Read Quality Gates Configuration
41+
id: quality-gates
42+
run: echo "json=$(jq -c . .github/quality-gates-pr.json)" >> "$GITHUB_OUTPUT"
43+
- name: Run Quality Monitor and Comment on PR
44+
uses: uhafner/quality-monitor@main
45+
with:
46+
sha: ${{ steps.pr.outputs.sha }}
47+
config: ${{ steps.quality-monitor.outputs.json }}
48+
quality-gates: ${{ steps.quality-gates.outputs.json }}
49+
pr-number: ${{ steps.pr.outputs.number }}
50+
comments-strategy: REMOVE
51+
show-headers: true
52+
title-metric: none

.github/workflows/quality-monitor-comment.yml

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,15 @@ permissions:
1313

1414
jobs:
1515
comment:
16-
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' }}
16+
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' && github.event.workflow_run.head_branch == 'main' }}
1717
runs-on: ubuntu-latest
18-
name: Comment on PR
18+
name: Comment main branch
1919

2020
steps:
21-
- name: Extract PR number and SHA
22-
id: pr
23-
run: |
24-
pr_number='${{ github.event.workflow_run.pull_requests[0].number }}'
25-
echo "number=$pr_number" >> "$GITHUB_OUTPUT"
26-
sha='${{ github.event.workflow_run.head_sha }}'
27-
echo "sha=$sha" >> "$GITHUB_OUTPUT"
28-
- name: Checkout PR
21+
- name: Checkout main branch
2922
uses: actions/checkout@v6
30-
with:
31-
ref: ${{ steps.pr.outputs.sha }}
32-
- name: Download PR Quality Reports from Quality Monitor Build workflow
33-
uses: dawidd6/action-download-artifact@v12
23+
- name: Download Quality Reports from Quality Monitor Build workflow
24+
uses: dawidd6/action-download-artifact@v11
3425
with:
3526
run_id: ${{ github.event.workflow_run.id }}
3627
name: quality-reports
@@ -43,10 +34,7 @@ jobs:
4334
- name: Run Quality Monitor and Comment on PR
4435
uses: uhafner/quality-monitor@main
4536
with:
46-
sha: ${{ steps.pr.outputs.sha }}
4737
config: ${{ steps.quality-monitor.outputs.json }}
4838
quality-gates: ${{ steps.quality-gates.outputs.json }}
49-
pr-number: ${{ steps.pr.outputs.number }}
50-
comments-strategy: REMOVE
5139
show-headers: true
5240
title-metric: none

0 commit comments

Comments
 (0)