-
Notifications
You must be signed in to change notification settings - Fork 1
114 lines (98 loc) · 3.53 KB
/
ci-reports.yml
File metadata and controls
114 lines (98 loc) · 3.53 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
name: CI Reports
on:
push:
branches:
- main
- 'features/**'
pull_request:
branches:
- main
jobs:
ci-reports:
runs-on: ubuntu-latest
env:
RUN_LIVE_E2E: "false"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
# ===== TESTING =====
- name: Run unit tests from module root
run: ./mvnw -B -ntp clean test
working-directory: .
# ===== CODE COVERAGE =====
- name: Generate JaCoCo coverage report
run: ./mvnw -B -ntp jacoco:report
# ===== STATIC ANALYSIS =====
- name: Generate PMD HTML report
run: ./mvnw -B -ntp pmd:pmd -Dpmd.failOnViolation=false
- name: Run Checkstyle
run: ./mvnw -B -ntp checkstyle:check
# ===== OPTIONAL LIVE E2E (requires LIVE_E2E env + external deps) =====
- name: Run live E2E (opt-in)
if: env.RUN_LIVE_E2E == 'true'
env:
LIVE_E2E: "true"
run: ./mvnw -B -ntp -Dtest=dev.coms4156.project.metadetect.e2e.ClientServiceLiveE2eTest test
# ===== CONVERT TO PNG =====
- name: Install wkhtmltopdf for report conversion
run: |
sudo apt-get update
sudo apt-get install -y wkhtmltopdf
- name: Make conversion script executable
run: chmod +x scripts/html_to_png.sh
- name: Convert HTML reports to PNG
run: bash scripts/html_to_png.sh
- name: Collect additional raw artifacts into /reports
if: always()
run: |
mkdir -p reports/test-results reports/raw
if [ -d "target/surefire-reports" ]; then
cp -R target/surefire-reports/. reports/test-results/
fi
if [ -f "target/pmd.xml" ]; then
cp target/pmd.xml reports/raw/pmd.xml
fi
if [ -f "target/checkstyle-result.xml" ]; then
cp target/checkstyle-result.xml reports/raw/checkstyle-result.xml
fi
if [ -f "target/site/jacoco/jacoco.xml" ]; then
cp target/site/jacoco/jacoco.xml reports/raw/jacoco.xml
fi
# ===== QUALITY GATES =====
- name: Enforce PMD violations
run: ./mvnw -B -ntp pmd:check
# ===== UPLOAD ARTIFACTS =====
- name: Upload CI reports (HTML, PNG, XML)
uses: actions/upload-artifact@v4
if: always()
with:
name: ci-reports
path: |
reports/
target/surefire-reports/
retention-days: 30
# ===== SUMMARY =====
- name: Generate CI Summary
if: always()
run: |
echo "## 📊 CI Report Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Test Results" >> $GITHUB_STEP_SUMMARY
if [ -d "target/surefire-reports" ]; then
TESTS=$(find target/surefire-reports -name "TEST-*.xml" | wc -l)
echo "- Test suites executed: $TESTS" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Available Reports" >> $GITHUB_STEP_SUMMARY
echo "- ✅ JaCoCo coverage (HTML + PNG snapshot)" >> $GITHUB_STEP_SUMMARY
echo "- ✅ PMD static analysis (HTML + PNG snapshot)" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Unit test XML results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 📥 Download Artifacts" >> $GITHUB_STEP_SUMMARY
echo "All consolidated under the 'ci-reports' artifact (reports/ + surefire XML)." >> $GITHUB_STEP_SUMMARY