Skip to content

Commit

Permalink
Jacoco reports badge
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperStep committed Feb 28, 2024
1 parent 4b366a1 commit 7b32bd8
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
36 changes: 32 additions & 4 deletions .github/workflows/assemble.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Build Gradle project
on:
push:
branches:
- '!master'
jobs:
build-gradle-project:
runs-on: ubuntu-latest
Expand All @@ -15,5 +13,35 @@ jobs:
java-version: 17
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Run build with Gradle Wrapper
run: ./gradlew assemble

- name: Run Test Coverage
run: ./gradlew jacocoTestReport
- name: Generate JaCoCo Badge
uses: cicirello/jacoco-badge-generator@v2
with:
generate-branches-badge: true
jacoco-csv-file: build/reports/jacoco/test/jacocoTestReport.csv

- name: Log coverage percentage
run: |
echo "coverage = ${{ steps.jacoco.outputs.coverage }}"
echo "branch coverage = ${{ steps.jacoco.outputs.branches }}"
- name: Commit the badge (if it changed)
run: |
if [[ `git status --porcelain` ]]; then
git config --global user.name 'Gordeev Egor'
git config --global user.email 'SuperStep@users.noreply.github.com'
git add -A
git commit -m "Generated JaCoCo coverage badge"
git push
fi
- name: Upload JaCoCo coverage report
uses: actions/upload-artifact@v2
with:
name: jacoco-report
path: target/site/jacoco/

# - name: Run build with Gradle Wrapper
# run: ./gradlew assemble
16 changes: 15 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id 'org.springframework.boot' version '3.2.2'
id 'io.spring.dependency-management' version '1.1.4'
id 'org.siouan.frontend-jdk17' version '8.0.0'
id 'jacoco'
}

ext {
Expand Down Expand Up @@ -79,4 +80,17 @@ tasks.named('test') {
testLogging {
events "passed"
}
}
}

test {
finalizedBy jacocoTestReport // report is always generated after tests run
}

jacocoTestReport {
dependsOn test
reports {
xml.required = false
html.required = false
csv.required = true
}
}

0 comments on commit 7b32bd8

Please sign in to comment.