Skip to content

Merge pull request #3 from ZaTribune/docs/enhance_readme_and_structure #13

Merge pull request #3 from ZaTribune/docs/enhance_readme_and_structure

Merge pull request #3 from ZaTribune/docs/enhance_readme_and_structure #13

Workflow file for this run

name: Code Coverage
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
code-coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin' # Specify the Java distribution here
- name: Build with Maven
run: mvn clean install
- name: Install xmllint
run: sudo apt-get install -y libxml2-utils
- name: Display jacoco.xml contents
run: cat target/site/jacoco/jacoco.xml
- name: Extract coverage percentage
id: extract-coverage
run: |
COVERAGE=$(xmllint --xpath "string(//report/@lineCoverage)" target/site/jacoco/jacoco.xml)
echo "Coverage Percentage: $COVERAGE"
echo "coverage=$COVERAGE" >> $GITHUB_ENV
- name: Update README with Coverage Badge
run: |
COVERAGE=${{ steps.extract-coverage.outputs.coverage }}
echo "Updating README with coverage badge..."
BADGE_URL="https://img.shields.io/badge/coverage-${COVERAGE}%25-green"
sed -i "s|https://img.shields.io/badge/coverage-.*-green|$BADGE_URL|g" README.md
git config --local user.name "github-actions"
git config --local user.email "[email protected]"
# Create a new branch for the changes
git checkout -b update-coverage-badge
git add README.md
git commit -m "Update coverage badge to $COVERAGE%"
git push --set-upstream origin update-coverage-badge
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}