Add JaCoCo for test coverage and update Drone CI settings
All checks were successful
continuous-integration/drone/push Build is passing

Integrate JaCoCo to enforce and report test coverage with a minimum threshold of 65%. Update Drone CI configuration to use a new Docker registry (rubble.se:5000) and add support for authentication with secrets.
This commit is contained in:
Urban Modig
2025-10-05 10:20:50 +02:00
parent aef0a4c98f
commit 7cb6265125
2 changed files with 40 additions and 4 deletions

View File

@ -16,12 +16,16 @@ steps:
- name: build-image - name: build-image
image: plugins/docker image: plugins/docker
settings: settings:
registry: registry.local:5000 registry: rubble.se:5000
repo: registry.local:5000/hemhub/api repo: rubble.se:5000/hemhub/api
tags: tags:
- ${DRONE_BRANCH/\//-}-${DRONE_COMMIT_SHA:0:7} - ${DRONE_BRANCH/\//-}-${DRONE_COMMIT_SHA:0:7}
- latest - latest
dockerfile: Dockerfile dockerfile: Dockerfile
username:
from_secret: docker_username
password:
from_secret: docker_password
when: when:
branch: branch:
include: [ main, develop ] include: [ main, develop ]
@ -31,11 +35,15 @@ steps:
- name: publish-tag - name: publish-tag
image: plugins/docker image: plugins/docker
settings: settings:
registry: registry.local:5000 registry: rubble.se:5000
repo: registry.local:5000/hemhub/api repo: rubble.se:5000/hemhub/api
tags: tags:
- ${DRONE_TAG} - ${DRONE_TAG}
dockerfile: Dockerfile dockerfile: Dockerfile
username:
from_secret: docker_username
password:
from_secret: docker_password
when: when:
event: event:
include: [ tag ] include: [ tag ]

View File

@ -2,6 +2,7 @@ plugins {
id 'java' id 'java'
id 'org.springframework.boot' version '3.3.4' id 'org.springframework.boot' version '3.3.4'
id 'io.spring.dependency-management' version '1.1.6' id 'io.spring.dependency-management' version '1.1.6'
id 'jacoco'
} }
group = 'se.urmo' group = 'se.urmo'
@ -21,4 +22,31 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.boot:spring-boot-starter-test'
} }
test {
useJUnitPlatform()
finalizedBy jacocoTestReport
}
jacocoTestReport {
dependsOn test
reports {
xml.required = true
html.required = true
}
}
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
counter = 'LINE'
value = 'COVEREDRATIO'
minimum = 0.65 // börja rimligt (65%), höj senare
}
}
}
}
check.dependsOn jacocoTestCoverageVerification
tasks.test { useJUnitPlatform() } tasks.test { useJUnitPlatform() }