-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (114 loc) · 4.07 KB
/
test-and-quality-analysis.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
name: Test and Quality Analysis
on:
pull_request:
permissions:
pull-requests: write
contents: read
actions: read
checks: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Java and Gradlew
uses: ./.github/actions/setup-java-and-gradlew
with:
java-distribution: 'liberica'
java-version: '21'
java-package: 'jdk'
- name: Run tests with Gradle
run: ./gradlew test jacocoTestReport --info --parallel
env:
SPRING_PROFILES_ACTIVE: test
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: '**/build/reports/tests/test/*'
- name: Upload coverage results
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: '**/build/reports/jacoco/test/jacocoTestReport.xml'
- name: Test Reporter
id: reporter
uses: dorny/test-reporter@v1
if: always()
with:
name: Spring Boot Tests
path: '**/build/test-results/test/*.xml'
reporter: java-junit
only-summary: false
list-suites: all
list-tests: all
max-annotations: 50
fail-on-error: true
fail-on-empty: true
- name: Compute Metrics
if: always()
run: |
total=$(( ${PASSED:-0} + ${FAILED:-0} + ${SKIPPED:-0} ))
time_in_seconds=$(echo "scale=2; ${TIME_MS:-0} / 1000" | bc)
echo "total=$total" >> $GITHUB_ENV
echo "time_in_seconds=$time_in_seconds" >> $GITHUB_ENV
env:
PASSED: ${{ steps.reporter.outputs.passed }}
FAILED: ${{ steps.reporter.outputs.failed }}
SKIPPED: ${{ steps.reporter.outputs.skipped }}
TIME_MS: ${{ steps.reporter.outputs.time }}
- name: Post Test Results to PR
uses: marocchino/sticky-pull-request-comment@v2
if: always()
with:
header: Test Results
recreate: true
message: |
## 🛠️ Test Summary (${{ steps.reporter.outputs.conclusion }})
📄 **[View Detailed Test Logs](${{ steps.reporter.outputs.url_html }})**
| **Metrics** | **Test Result Details** |
|-----------------------|---------------------------------------|
| **Total Tests** | ${{ env.total }} |
| ✅ **Tests Passed** | ${{ steps.reporter.outputs.passed }} |
| ❌ **Tests Failed** | ${{ steps.reporter.outputs.failed }} |
| ⚠️ **Tests Skipped** | ${{ steps.reporter.outputs.skipped }} |
| ⏱️ **Execution Time** | ${{ env.time_in_seconds }}s |
code_quality_analysis:
runs-on: ubuntu-latest
needs: test
if: always()
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download test results
uses: actions/download-artifact@v4
with:
name: test-results
- name: Download coverage report
uses: actions/download-artifact@v4
with:
name: coverage-report
- name: Setup Java and Gradlew
uses: ./.github/actions/setup-java-and-gradlew
with:
java-distribution: 'liberica'
java-version: '21'
java-package: 'jdk'
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Run Checkstyle
run: ./gradlew checkstyleMain checkstyleTest -x test --info
- name: Run JaCoCo Test Coverage Verification
run: ./gradlew jacocoTestCoverageVerification -x test -x jacocoTestReport --info
continue-on-error: true
- name: Run SonarCloud Analysis
run: ./gradlew sonar --info
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}