Skip to content

Commit a0be1c1

Browse files
authored
chore: adding coverage (#100)
<!-- Please describe your pull request here. --> ## References - TODO <!-- References to relevant GitHub issues and pull requests, esp. upstream and downstream changes --> ## Submitter checklist - [ ] Recommended: Join [WireMock Slack](https://slack.wiremock.org/) to get any help in `#help-contributing` or a project-specific channel like `#wiremock-java` - [ ] Recommended: If you participate in Hacktoberfest 2023, make sure you're [signed up](https://wiremock.org/events/hacktoberfest/) there and in the WireMock form - [ ] The PR request is well described and justified, including the body and the references - [ ] The PR title represents the desired changelog entry - [ ] The repository's code style is followed (see the contributing guide) - [ ] Test coverage that demonstrates that the change works as expected - [ ] For new features, there's necessary documentation in this pull request or in a subsequent PR to [wiremock.org](https://github.com/wiremock/wiremock.org) <!-- Put an `x` into the [ ] to show you have filled the information. The template comes from https://github.com/wiremock/.github/blob/main/.github/pull_request_template.md You can override it by creating .github/pull_request_template.md in your own repository -->
1 parent 79d9ba3 commit a0be1c1

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

.github/workflows/build-and-test.yml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@ jobs:
2323
env:
2424
JDK_VERSION: ${{ matrix.jdk }}
2525
steps:
26-
- uses: actions/checkout@v3
26+
- uses: actions/checkout@v4
2727
with:
2828
fetch-depth: 0
29+
- name: Checkout badges branch dedicated to storing badges only
30+
uses: actions/checkout@v4
31+
with:
32+
ref: badges
33+
path: badges
2934
- name: Set up JDK
3035
uses: actions/setup-java@v3
3136
with:
@@ -35,3 +40,33 @@ jobs:
3540
uses: gradle/gradle-build-action@v2
3641
with:
3742
arguments: build check
43+
- name: Generate coverage badges
44+
if: ${{ matrix.os == 'ubuntu-latest' && matrix.jdk == '11' }}
45+
uses: cicirello/jacoco-badge-generator@v2
46+
with:
47+
badges-directory: badges
48+
generate-coverage-badge: true
49+
generate-branches-badge: true
50+
coverage-badge-filename: line-coverage.svg
51+
branches-badge-filename: branches-coverage.svg
52+
generate-summary: true
53+
coverage-label: line coverage
54+
branches-label: branch coverage
55+
jacoco-csv-file: build/reports/jacoco/test/jacocoTestReport.csv
56+
- name: Commit and push
57+
if: ${{ matrix.os == 'ubuntu-latest' && matrix.jdk == '11' && github.event_name != 'pull_request' }}
58+
run: |
59+
cd badges
60+
if [[ `git status --porcelain *.svg` ]]; then
61+
git config --global user.name 'github-actions'
62+
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
63+
git add *.svg
64+
git commit -m "Autogenerated JaCoCo coverage badge" *.svg
65+
git push
66+
fi
67+
68+
- name: Upload Jacoco coverage report
69+
uses: actions/upload-artifact@v3
70+
with:
71+
name: jacoco-report
72+
path: build/reports/jacoco/

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# WireMock State extension
22

33
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/wiremock/wiremock-state-extension)](https://github.com/wiremock/wiremock-state-extension/releases)
4-
[![Maven Central](https://img.shields.io/maven-central/v/org.wiremock.extensions/wiremock-state-extension)](https://img.shields.io/maven-central/v/org.wiremock.extensions/wiremock-state-extension)
4+
[![Maven Central](https://img.shields.io/maven-central/v/org.wiremock.extensions/wiremock-state-extension)](https://central.sonatype.com/artifact/org.wiremock.extensions/wiremock-state-extension)
55
[![Slack](https://img.shields.io/badge/slack-slack.wiremock.org-brightgreen?style=flat&logo=slack)](https://slack.wiremock.org/)
66
[![GitHub contributors](https://img.shields.io/github/contributors/wiremock/wiremock-state-extension)](https://github.com/wiremock/wiremock-state-extension/graphs/contributors)
7+
![Line Coverage](../badges/line-coverage.svg)
8+
![Branches Coverage](../badges/branches-coverage.svg)
79

810
<p align="center">
911
<a href="https://wiremock.org" target="_blank">

build.gradle

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ shadowJar {
7777
exclude 'handlebars-*.js'
7878
}
7979

80+
test {
81+
finalizedBy jacocoTestReport
82+
}
83+
jacocoTestReport {
84+
dependsOn test
85+
reports {
86+
xml.required = true
87+
csv.required = true
88+
html.required = true
89+
}
90+
}
91+
8092
group 'org.wiremock.extensions'
8193

8294
version gitVersion()

0 commit comments

Comments
 (0)