Skip to content

Commit b325bf3

Browse files
committed
Add code quality pipeline and coverage reporting
Implemented comprehensive code quality infrastructure with automated testing, coverage reporting, and quality badges. Changes: 1. pom.xml: - Added JaCoCo plugin (v0.8.11) for code coverage - Configured coverage minimum threshold (50%) - Automatic report generation on test phase 2. GitHub Actions (.github/workflows/code-quality.yml): - New workflow for code quality checks - Three jobs: test-and-coverage, code-analysis, build-quality - Automated coverage upload to Codecov - PR comments with coverage reports - Artifact archiving for reports and builds 3. Codecov configuration (codecov.yml): - Project coverage target: 50% - Patch coverage target: 60% - Automatic PR comments with coverage diff - Ignore test files from coverage calculation 4. README.md: - Added Code Quality workflow badge - Added Codecov coverage badge - Updated CI/CD section with quality checks info - Mentioned 55 unit tests in features Features: ✅ Automated test execution on push/PR ✅ Code coverage reporting with JaCoCo ✅ Codecov integration for visual coverage tracking ✅ PR comments with coverage delta ✅ Coverage badges in README ✅ Artifact archiving (reports + JAR) ✅ Multi-job pipeline (test → analyze → build) Benefits: - Prevents regressions with automated testing - Enforces minimum 50% code coverage - Visual feedback on PRs with coverage reports - Historical coverage tracking via Codecov - Professional quality badges for repository Note: Codecov token needs to be added to GitHub secrets as CODECOV_TOKEN
1 parent 9576cc4 commit b325bf3

4 files changed

Lines changed: 204 additions & 1 deletion

File tree

.github/workflows/code-quality.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Code Quality
2+
3+
on:
4+
push:
5+
branches: [ "main", "develop" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
permissions:
10+
contents: read
11+
pull-requests: write
12+
13+
jobs:
14+
test-and-coverage:
15+
name: Unit Tests & Code Coverage
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0 # Full history for better analysis
23+
24+
- name: Set up JDK 21
25+
uses: actions/setup-java@v4
26+
with:
27+
java-version: '21'
28+
distribution: 'temurin'
29+
cache: maven
30+
31+
- name: Run tests with coverage
32+
run: mvn -B clean test jacoco:report
33+
34+
- name: Generate coverage report
35+
run: mvn jacoco:report
36+
37+
- name: Upload coverage to Codecov
38+
uses: codecov/codecov-action@v4
39+
with:
40+
token: ${{ secrets.CODECOV_TOKEN }}
41+
files: ./target/site/jacoco/jacoco.xml
42+
flags: unittests
43+
name: codecov-umbrella
44+
fail_ci_if_error: false
45+
verbose: true
46+
47+
- name: Archive coverage report
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: coverage-report
51+
path: target/site/jacoco/
52+
retention-days: 30
53+
54+
- name: Comment coverage on PR
55+
if: github.event_name == 'pull_request'
56+
uses: madrapps/jacoco-report@v1.6.1
57+
with:
58+
paths: ${{ github.workspace }}/target/site/jacoco/jacoco.xml
59+
token: ${{ secrets.GITHUB_TOKEN }}
60+
min-coverage-overall: 50
61+
min-coverage-changed-files: 60
62+
title: '📊 Code Coverage Report'
63+
update-comment: true
64+
65+
code-analysis:
66+
name: Static Code Analysis
67+
runs-on: ubuntu-latest
68+
needs: test-and-coverage
69+
70+
steps:
71+
- name: Checkout repository
72+
uses: actions/checkout@v4
73+
74+
- name: Set up JDK 21
75+
uses: actions/setup-java@v4
76+
with:
77+
java-version: '21'
78+
distribution: 'temurin'
79+
cache: maven
80+
81+
- name: Compile project
82+
run: mvn -B compile test-compile
83+
84+
- name: Run Maven verify
85+
run: mvn -B verify -DskipTests
86+
87+
build-quality:
88+
name: Build Quality Check
89+
runs-on: ubuntu-latest
90+
needs: [test-and-coverage, code-analysis]
91+
92+
steps:
93+
- name: Checkout repository
94+
uses: actions/checkout@v4
95+
96+
- name: Set up JDK 21
97+
uses: actions/setup-java@v4
98+
with:
99+
java-version: '21'
100+
distribution: 'temurin'
101+
cache: maven
102+
103+
- name: Full build with all checks
104+
run: mvn -B clean package
105+
106+
- name: Archive artifacts
107+
uses: actions/upload-artifact@v4
108+
with:
109+
name: build-artifacts
110+
path: |
111+
target/*.jar
112+
target/site/jacoco/
113+
retention-days: 7

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Android Emulator Manager
22

33
[![Java CI with Maven](https://github.com/NmurtasDev/AndroidEmulatorManager/actions/workflows/maven.yml/badge.svg)](https://github.com/NmurtasDev/AndroidEmulatorManager/actions/workflows/maven.yml)
4+
[![Code Quality](https://github.com/NmurtasDev/AndroidEmulatorManager/actions/workflows/code-quality.yml/badge.svg)](https://github.com/NmurtasDev/AndroidEmulatorManager/actions/workflows/code-quality.yml)
5+
[![codecov](https://codecov.io/gh/NmurtasDev/AndroidEmulatorManager/branch/main/graph/badge.svg)](https://codecov.io/gh/NmurtasDev/AndroidEmulatorManager)
46
[![CodeQL](https://github.com/NmurtasDev/AndroidEmulatorManager/actions/workflows/codeql.yml/badge.svg)](https://github.com/NmurtasDev/AndroidEmulatorManager/actions/workflows/codeql.yml)
57
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
68
[![Java Version](https://img.shields.io/badge/Java-21-blue.svg)](https://www.oracle.com/java/technologies/javase/jdk21-archive-downloads.html)
@@ -169,11 +171,14 @@ This version introduces major architectural improvements over previous versions:
169171
-**Dark theme support** with automatic system theme detection
170172
-**Rename AVD functionality** directly from UI
171173

172-
### CI/CD
174+
### CI/CD & Quality
173175
-**Automated releases** via GitHub Actions on tag push
174176
-**Multi-platform builds** (JAR, Windows EXE)
175177
-**Pre-release support** for beta/RC versions
176178
-**CodeQL security scanning** on every commit
179+
-**Automated code coverage** with JaCoCo and Codecov
180+
-**Code quality checks** on every PR
181+
-**Unit test execution** with detailed coverage reports (55 tests)
177182

178183
## Release Pipeline
179184

codecov.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
codecov:
2+
require_ci_to_pass: yes
3+
notify:
4+
wait_for_ci: yes
5+
6+
coverage:
7+
precision: 2
8+
round: down
9+
range: "50...100"
10+
11+
status:
12+
project:
13+
default:
14+
target: 50%
15+
threshold: 5%
16+
if_ci_failed: error
17+
18+
patch:
19+
default:
20+
target: 60%
21+
threshold: 10%
22+
23+
changes:
24+
default:
25+
if_ci_failed: error
26+
27+
comment:
28+
layout: "reach,diff,flags,tree,footer"
29+
behavior: default
30+
require_changes: false
31+
require_base: no
32+
require_head: yes
33+
34+
ignore:
35+
- "src/test/**"
36+
- "**/*Test.java"
37+
- "**/test/**"
38+
39+
flags:
40+
unittests:
41+
paths:
42+
- src/main/java/
43+
carryforward: true

pom.xml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,48 @@
9999
<version>3.2.2</version>
100100
</plugin>
101101

102+
<!-- JaCoCo Plugin for Code Coverage -->
103+
<plugin>
104+
<groupId>org.jacoco</groupId>
105+
<artifactId>jacoco-maven-plugin</artifactId>
106+
<version>0.8.11</version>
107+
<executions>
108+
<execution>
109+
<id>prepare-agent</id>
110+
<goals>
111+
<goal>prepare-agent</goal>
112+
</goals>
113+
</execution>
114+
<execution>
115+
<id>report</id>
116+
<phase>test</phase>
117+
<goals>
118+
<goal>report</goal>
119+
</goals>
120+
</execution>
121+
<execution>
122+
<id>jacoco-check</id>
123+
<goals>
124+
<goal>check</goal>
125+
</goals>
126+
<configuration>
127+
<rules>
128+
<rule>
129+
<element>PACKAGE</element>
130+
<limits>
131+
<limit>
132+
<counter>LINE</counter>
133+
<value>COVEREDRATIO</value>
134+
<minimum>0.50</minimum>
135+
</limit>
136+
</limits>
137+
</rule>
138+
</rules>
139+
</configuration>
140+
</execution>
141+
</executions>
142+
</plugin>
143+
102144
<!-- Fat JAR con dipendenze -->
103145
<plugin>
104146
<groupId>org.apache.maven.plugins</groupId>

0 commit comments

Comments
 (0)