From a0be1c15102e7d087d979cb5df96ad22467bccb2 Mon Sep 17 00:00:00 2001 From: Dirk Bolte Date: Sun, 12 Nov 2023 21:32:12 +0100 Subject: [PATCH] chore: adding coverage (#100) ## References - TODO ## 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) --- .github/workflows/build-and-test.yml | 37 +++++++++++++++++++++++++++- README.md | 4 ++- build.gradle | 12 +++++++++ 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 2465894..b67de42 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -23,9 +23,14 @@ jobs: env: JDK_VERSION: ${{ matrix.jdk }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Checkout badges branch dedicated to storing badges only + uses: actions/checkout@v4 + with: + ref: badges + path: badges - name: Set up JDK uses: actions/setup-java@v3 with: @@ -35,3 +40,33 @@ jobs: uses: gradle/gradle-build-action@v2 with: arguments: build check + - name: Generate coverage badges + if: ${{ matrix.os == 'ubuntu-latest' && matrix.jdk == '11' }} + uses: cicirello/jacoco-badge-generator@v2 + with: + badges-directory: badges + generate-coverage-badge: true + generate-branches-badge: true + coverage-badge-filename: line-coverage.svg + branches-badge-filename: branches-coverage.svg + generate-summary: true + coverage-label: line coverage + branches-label: branch coverage + jacoco-csv-file: build/reports/jacoco/test/jacocoTestReport.csv + - name: Commit and push + if: ${{ matrix.os == 'ubuntu-latest' && matrix.jdk == '11' && github.event_name != 'pull_request' }} + run: | + cd badges + if [[ `git status --porcelain *.svg` ]]; then + git config --global user.name 'github-actions' + git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' + git add *.svg + git commit -m "Autogenerated JaCoCo coverage badge" *.svg + git push + fi + + - name: Upload Jacoco coverage report + uses: actions/upload-artifact@v3 + with: + name: jacoco-report + path: build/reports/jacoco/ \ No newline at end of file diff --git a/README.md b/README.md index 26e8dfa..afe4ef5 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ # WireMock State extension [![GitHub release (latest by date)](https://img.shields.io/github/v/release/wiremock/wiremock-state-extension)](https://github.com/wiremock/wiremock-state-extension/releases) -[![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) +[![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) [![Slack](https://img.shields.io/badge/slack-slack.wiremock.org-brightgreen?style=flat&logo=slack)](https://slack.wiremock.org/) [![GitHub contributors](https://img.shields.io/github/contributors/wiremock/wiremock-state-extension)](https://github.com/wiremock/wiremock-state-extension/graphs/contributors) +![Line Coverage](../badges/line-coverage.svg) +![Branches Coverage](../badges/branches-coverage.svg)

diff --git a/build.gradle b/build.gradle index 64f297b..b4c7209 100644 --- a/build.gradle +++ b/build.gradle @@ -77,6 +77,18 @@ shadowJar { exclude 'handlebars-*.js' } +test { + finalizedBy jacocoTestReport +} +jacocoTestReport { + dependsOn test + reports { + xml.required = true + csv.required = true + html.required = true + } +} + group 'org.wiremock.extensions' version gitVersion()