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)