Skip to content

⚗️ First attempt on extracting Kover coverage badge #38

⚗️ First attempt on extracting Kover coverage badge

⚗️ First attempt on extracting Kover coverage badge #38

Workflow file for this run

# This file was generated using Kotlin DSL (.github/workflows/kover.main.kts).
# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file.
# Generated with https://github.com/typesafegithub/github-workflows-kt
name: 'Kover Coverage'
on:
push:
branches:
- 'main'
pull_request: {}
jobs:
check_yaml_consistency:
name: 'Check YAML consistency'
runs-on: 'ubuntu-latest'
steps:
- id: 'step-0'
name: 'Check out'
uses: 'actions/checkout@v4'
- id: 'step-1'
name: 'Execute script'
run: 'rm ''.github/workflows/kover.yaml'' && ''.github/workflows/kover.main.kts'''
- id: 'step-2'
name: 'Consistency check'
run: 'git diff --exit-code ''.github/workflows/kover.yaml'''
analyse:
runs-on: 'ubuntu-latest'
needs:
- 'check_yaml_consistency'
steps:
- id: 'step-0'
name: 'Set up JDK'
uses: 'actions/setup-java@v4'
with:
java-version: '17'
distribution: 'adopt'
- id: 'step-1'
uses: 'actions/checkout@v4'
- id: 'step-2'
uses: 'gradle/gradle-build-action@v3'
with:
arguments: 'koverHtmlReport'
- id: 'step-3'
run: 'cat app/build/reports/kover/html/index.html >> $GITHUB_STEP_SUMMARY'
- id: 'step-4'
uses: 'gradle/gradle-build-action@v3'
with:
arguments: 'koverXmlReport'
- id: 'step-5'
name: 'Generate coverage output'
run: |-
COVERAGE=$(${{ github.workspace }}/gradlew -q printLineCoverage)
echo "Extracted Coverage: $COVERAGE"
echo "COVERAGE=$COVERAGE" >> $GITHUB_ENV
- id: 'step-6'
name: 'Generate Coverage Badge'
run: "\n git fetch origin gh-pages || true\n git checkout gh-pages 2>/dev/null || git checkout --orphan gh-pages\n\n echo \"COVERAGE=$COVERAGE\"\n mkdir -p badge\n curl \"https://img.shields.io/badge/Coverage-${COVERAGE}%25-$( [ \"$COVERAGE\" -ge 90 ] && echo brightgreen || ( [ \"$COVERAGE\" -ge 70 ] && echo yellow ) || echo red )\" -o badge/coverage-badge.svg\n mkdir -p badge\n\n git config --global user.name \"github-actions[bot]\"\n git config --global user.email \"41898282+github-actions[bot]@users.noreply.github.com\"\n\n git add badge/\n if ! git diff --cached --quiet; then\n git commit -m \"Update coverage badge\"\n git push \"https://github-actions:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git\" gh-pages\n else\n echo \"No coverage changes to commit\"\n fi\n "
- id: 'step-7'
name: 'Deploy Badge to GitHub Pages'
uses: 'peaceiris/actions-gh-pages@v3'
with:
github_token: '${{ secrets.GITHUB_TOKEN }}'
publish_dir: 'badge'