Skip to content

Commit 947856d

Browse files
committed
Split quality monitor into 2 separate actions
1 parent ba8b703 commit 947856d

File tree

5 files changed

+288
-191
lines changed

5 files changed

+288
-191
lines changed

.github/quality-gates.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"qualityGates": [
3+
{
4+
"metric": "tests-success-rate",
5+
"name": "Tests Success Rate",
6+
"threshold": 100.0,
7+
"criticality": "FAILURE"
8+
},
9+
{
10+
"metric": "line",
11+
"threshold": 80.0,
12+
"criticality": "UNSTABLE"
13+
},
14+
{
15+
"metric": "branch",
16+
"threshold": 80.0,
17+
"criticality": "UNSTABLE"
18+
},
19+
{
20+
"metric": "bugs",
21+
"name": "Potential Bugs",
22+
"threshold": 0.0,
23+
"criticality": "FAILURE"
24+
},
25+
{
26+
"metric": "style",
27+
"name": "Style Violations",
28+
"threshold": 0.0,
29+
"criticality": "FAILURE"
30+
}
31+
]
32+
}

.github/quality-monitor.json

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
{
2+
"tests": {
3+
"name": "Tests",
4+
"tools": [
5+
{
6+
"id": "junit",
7+
"name": "Unit Tests",
8+
"pattern": "**/target/surefire-reports/TEST*data*.xml"
9+
},
10+
{
11+
"id": "junit",
12+
"icon": "rocket",
13+
"name": "Integration Tests",
14+
"pattern": "**/target/failsafe-reports/TEST*.xml"
15+
},
16+
{
17+
"id": "junit",
18+
"icon": "no_entry",
19+
"name": "Architecture Tests",
20+
"pattern": "**/target/surefire-reports/TEST*archunit*.xml"
21+
}
22+
]
23+
},
24+
"analysis": [
25+
{
26+
"name": "Style",
27+
"id": "style",
28+
"tools": [
29+
{
30+
"id": "checkstyle",
31+
"pattern": "**/target/**checkstyle-result.xml"
32+
},
33+
{
34+
"id": "pmd",
35+
"pattern": "**/target/pmd-*/pmd.xml"
36+
},
37+
{
38+
"id": "java",
39+
"icon": "coffee",
40+
"pattern": "**/maven.log"
41+
}
42+
]
43+
},
44+
{
45+
"name": "Bugs",
46+
"id": "bugs",
47+
"icon": "bug",
48+
"tools": [
49+
{
50+
"id": "spotbugs",
51+
"sourcePath": "src/main/java",
52+
"pattern": "**/target/spotbugsXml.xml"
53+
},
54+
{
55+
"id": "error-prone",
56+
"pattern": "**/maven.log"
57+
}
58+
]
59+
},
60+
{
61+
"name": "API Problems",
62+
"id": "api",
63+
"icon": "no_entry_sign",
64+
"tools": [
65+
{
66+
"id": "revapi",
67+
"sourcePath": "src/main/java",
68+
"pattern": "**/target/revapi-result.json"
69+
}
70+
]
71+
},
72+
{
73+
"name": "Vulnerabilities",
74+
"id": "vulnerabilities",
75+
"icon": "shield",
76+
"tools": [
77+
{
78+
"icon": "shield",
79+
"id": "owasp-dependency-check",
80+
"icon": "shield",
81+
"pattern": "**/target/dependency-check-report.json"
82+
}
83+
]
84+
}
85+
],
86+
"coverage": [
87+
{
88+
"name": "Code Coverage",
89+
"tools": [
90+
{
91+
"id": "jacoco",
92+
"metric": "line",
93+
"sourcePath": "src/main/java",
94+
"pattern": "**/target/site/jacoco/jacoco.xml"
95+
},
96+
{
97+
"id": "jacoco",
98+
"metric": "branch",
99+
"sourcePath": "src/main/java",
100+
"pattern": "**/target/site/jacoco/jacoco.xml"
101+
}
102+
]
103+
}
104+
],
105+
"metrics": {
106+
"name": "Software Metrics",
107+
"tools": [
108+
{
109+
"id": "metrics",
110+
"pattern": "**/metrics/pmd.xml",
111+
"metric": "CYCLOMATIC_COMPLEXITY"
112+
},
113+
{
114+
"id": "metrics",
115+
"pattern": "**/metrics/pmd.xml",
116+
"metric": "COGNITIVE_COMPLEXITY"
117+
},
118+
{
119+
"id": "metrics",
120+
"pattern": "**/metrics/pmd.xml",
121+
"metric": "NPATH_COMPLEXITY"
122+
},
123+
{
124+
"id": "metrics",
125+
"pattern": "**/metrics/pmd.xml",
126+
"metric": "LOC"
127+
},
128+
{
129+
"id": "metrics",
130+
"pattern": "**/metrics/pmd.xml",
131+
"metric": "NCSS"
132+
},
133+
{
134+
"id": "metrics",
135+
"pattern": "**/metrics/pmd.xml",
136+
"metric": "COHESION"
137+
},
138+
{
139+
"id": "metrics",
140+
"pattern": "**/metrics/pmd.xml",
141+
"metric": "WEIGHT_OF_CLASS"
142+
}
143+
]
144+
}
145+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: 'Quality Monitor Build'
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
build:
8+
runs-on: [ubuntu-latest]
9+
name: Create quality reports
10+
11+
steps:
12+
- name: Checkout PR
13+
uses: actions/checkout@v5
14+
- name: Set up JDK 21
15+
uses: actions/setup-java@v5
16+
with:
17+
distribution: 'temurin'
18+
java-version: 21
19+
check-latest: true
20+
cache: 'maven'
21+
- name: Set up Maven
22+
uses: stCarolas/setup-maven@v5
23+
with:
24+
maven-version: 3.9.11
25+
- name: Cache the NVD database
26+
uses: actions/cache@v4
27+
with:
28+
path: ~/.m2/repository/org/owasp/dependency-check-data
29+
key: dependency-check
30+
- name: Check if quality monitor reports mutation coverage
31+
run: |
32+
FILE='.github/quality-monitor.json'
33+
PATTERN='target/pit-reports/mutations.xml'
34+
if [ -f "$FILE" ]; then
35+
if grep -q "$PATTERN" "$FILE"; then
36+
echo "PIT=-Ppit" >> "$GITHUB_ENV"
37+
fi
38+
fi
39+
- name: Build with Maven
40+
env:
41+
NVD_API_KEY: ${{ secrets.NVD_API_KEY }}
42+
OSS_INDEX_TOKEN: ${{ secrets.OSS_INDEX_TOKEN }}
43+
PIT: ${{ env.PIT }}
44+
BROWSER: chrome-container
45+
run: |
46+
mvn -V --color always -ntp clean verify $PIT -Pci -Powasp | tee maven.log
47+
if [ "${PIPESTATUS[0]}" != "0" ]; then
48+
exit 1;
49+
fi
50+
mv -fv maven.log target/maven.log
51+
- name: Upload Quality Reports
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: quality-reports
55+
path: |
56+
**/target/**/*.json
57+
**/target/**/*.xml
58+
**/target/**/*.log
59+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: 'Quality Monitor Comment'
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@v5
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.json)" >> "$GITHUB_OUTPUT"
40+
- name: Read Quality Gates Configuration
41+
id: quality-gates
42+
run: echo "json=$(jq -c . .github/quality-gates.json)" >> "$GITHUB_OUTPUT"
43+
- name: Run Quality Monitor and Comment on PR
44+
uses: uhafner/quality-monitor@v3
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

0 commit comments

Comments
 (0)