Skip to content

test/docs: use latest Maven Central version dynamically #7

test/docs: use latest Maven Central version dynamically

test/docs: use latest Maven Central version dynamically #7

name: Coverage Tests
on:
push:
branches:
- '**'
pull_request:
permissions:
contents: read
pages: write
id-token: write
jobs:
coverage-tests:
name: Coverage Tests (Java 25)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Java 25
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 25
cache: maven
- name: Run tests with JaCoCo (excluding online integration)
run: mvn --batch-mode --errors --fail-at-end --show-version -Djava.release=25 -Dtest='!Online*IntegrationTest' clean test
- name: Print core coverage
if: always()
run: |
if [ -f target/site/jacoco/jacoco.csv ]; then
awk -F',' 'NR>1 && $2 == "com.DeathByCaptcha" { missed += $4; covered += $5 } END { total = missed + covered; pct = (total > 0 ? (covered * 100.0 / total) : 0); printf "Coverage (core): %.2f%%\n", pct }' target/site/jacoco/jacoco.csv
else
echo "Coverage (core): N/A (jacoco.csv not found)"
fi
- name: Build dynamic coverage badge JSON
if: always()
run: |
set -e
mkdir -p badge
if [ -f target/site/jacoco/jacoco.csv ]; then
pct=$(awk -F',' 'NR>1 && $2 == "com.DeathByCaptcha" { missed += $4; covered += $5 } END { total = missed + covered; pct = (total > 0 ? (covered * 100.0 / total) : 0); printf "%.2f", pct }' target/site/jacoco/jacoco.csv)
color="red"
awk -v p="$pct" 'BEGIN { exit !(p >= 80) }' && color="brightgreen" || true
awk -v p="$pct" 'BEGIN { exit !(p >= 60 && p < 80) }' && color="yellow" || true
awk -v p="$pct" 'BEGIN { exit !(p < 60) }' && color="red" || true
cat > badge/coverage-badge.json <<EOF
{"schemaVersion":1,"label":"coverage","message":"${pct}%","color":"${color}"}
EOF
else
cat > badge/coverage-badge.json <<EOF
{"schemaVersion":1,"label":"coverage","message":"n/a","color":"lightgrey"}
EOF
fi
- name: Upload coverage reports
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report-java-25
path: |
target/site/jacoco/
target/jacoco.exec
target/surefire-reports/
- name: Upload Pages artifact (coverage badge)
if: always() && github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
uses: actions/upload-pages-artifact@v3
with:
path: badge
deploy-coverage-badge:
name: Deploy coverage badge to GitHub Pages
if: github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
needs: coverage-tests
runs-on: ubuntu-latest
environment:
name: github-pages
steps:
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4