Feedback #79
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Measure coverage | |
on: | |
workflow_dispatch: | |
pull_request: | |
permissions: write-all | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ ubuntu-latest, macos-latest ] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: zulu | |
- name: Create Coverage Report | |
run: | | |
chmod +x gradlew | |
./gradlew jacocoTestReport | |
- if: matrix.os == 'ubuntu-latest' | |
name: Generate Jacoco Badge | |
uses: cicirello/jacoco-badge-generator@v2.11.0 | |
with: | |
jacoco-csv-file: lib/build/jacoco/report.csv | |
badges-directory: .github/badges | |
generate-coverage-badge: true | |
coverage-badge-filename: jacoco.svg | |
- name: Check for modified files | |
id: git-check | |
run: | | |
modified=$(git status --porcelain) | |
if [ -n "$modified" ]; then | |
echo "modified=true" >> $GITHUB_ENV | |
else | |
echo "modified=false" >> $GITHUB_ENV | |
fi | |
shell: bash | |
- name: Commit the badges (if they changed) | |
if: env.git-check == 'true' | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' | |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} | |
git add .github/badges/* | |
git commit -am "ci: autogenerate JaCoCo coverage badge" | |
git push | |
shell: bash | |