-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (95 loc) · 2.81 KB
/
ci-coverage.yml
File metadata and controls
115 lines (95 loc) · 2.81 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
115
name: CI with Coverage
# This workflow runs tests and generates code coverage reports
# To use this instead of ci.yml:
# 1. Rename this file to ci.yml
# 2. Backup or delete the current ci.yml
# 3. (Optional) Set up Codecov for coverage badges
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
test-with-coverage:
name: Test with Coverage
runs-on: ubuntu-latest
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
- name: Run tests with coverage
run: mvn -B clean test jacoco:report
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: target/surefire-reports/**/*.xml
- name: Upload test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: test-reports
path: target/surefire-reports/
- name: Upload coverage reports
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-reports
path: target/site/jacoco/
- name: Add coverage comment to PR
if: github.event_name == 'pull_request'
uses: madrapps/jacoco-report@v1.6.1
with:
paths: target/site/jacoco/jacoco.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 50
min-coverage-changed-files: 50
# Optional: Upload to Codecov
# Uncomment if you want to use Codecov for coverage tracking
# - name: Upload to Codecov
# uses: codecov/codecov-action@v4
# with:
# file: target/site/jacoco/jacoco.xml
# token: ${{ secrets.CODECOV_TOKEN }}
check-coverage:
name: Check Coverage Threshold
runs-on: ubuntu-latest
needs: test-with-coverage
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
- name: Verify coverage threshold
run: mvn -B verify
build:
name: Build Application
runs-on: ubuntu-latest
needs: [test-with-coverage, check-coverage]
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
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
- name: Build with Maven
run: mvn -B clean package -DskipTests
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: library-management-jar
path: target/*.jar
retention-days: 7