Skip to content

fix: switch coverage badge to Codecov, drop direct badge commit #71

fix: switch coverage badge to Codecov, drop direct badge commit

fix: switch coverage badge to Codecov, drop direct badge commit #71

Workflow file for this run

name: CI
on:
push:
branches:
- main
pull_request:
permissions:
contents: read
jobs:
build:
name: Tests / ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Setup Java
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
distribution: temurin
java-version: "21"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # v6.2.0
with:
gradle-version: "8.10.2"
- name: Run tests and checks
run: ./gradlew check jacocoAllReport --stacktrace
- name: Publish coverage summary
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
report="build/reports/jacoco/jacocoAllReport/jacocoAllReport.csv"
awk -F, '
NR > 1 {
branchMissed += $6
branchCovered += $7
lineMissed += $8
lineCovered += $9
}
END {
lineTotal = lineMissed + lineCovered
branchTotal = branchMissed + branchCovered
lineCoverage = lineTotal == 0 ? 100 : (lineCovered * 100 / lineTotal)
branchCoverage = branchTotal == 0 ? 100 : (branchCovered * 100 / branchTotal)
print "### JaCoCo coverage"
print ""
print "| Metric | Coverage |"
print "| --- | ---: |"
printf "| Lines | %.2f%% |\n", lineCoverage
printf "| Branches | %.2f%% |\n", branchCoverage
}
' "$report" >> "$GITHUB_STEP_SUMMARY"
- name: Upload coverage report
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: jacoco-report-${{ github.run_id }}
path: build/reports/jacoco/jacocoAllReport/html
- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7
with:
files: build/reports/jacoco/jacocoAllReport/jacocoAllReport.xml
fail_ci_if_error: false