From 5705b17c4b043817d214a7ffe2166105bb8a89d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20M=C3=B6rling?= Date: Tue, 19 May 2026 20:30:19 +0200 Subject: [PATCH] ci: add coverage summary printed to job log Adds a step after backend coverage that parses the JaCoCo XML report and prints a formatted table showing line and branch coverage with pass/fail status against thresholds (70% lines, 60% branches). The frontend coverage is already visible from Vitest's built-in text reporter which prints during npm run test:coverage. Both HTML reports remain downloadable as artifacts (backend-coverage and frontend-coverage ZIPs). Result: coverage numbers are visible at a glance in the CI job log without needing to download and unzip artifacts. --- .forgejo/workflows/ci.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index efb48b9..65af685 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -42,6 +42,39 @@ jobs: - name: Backend coverage run: ./gradlew :backend:jacocoTestCoverageVerification + - name: Print coverage summary + run: | + node -e " + const fs = require('fs'); + const xml = fs.readFileSync('backend/build/reports/jacoco/test/jacocoTestReport.xml', 'utf8'); + const lineMatch = xml.match(//g); + const branchMatch = xml.match(//g); + if (lineMatch && branchMatch) { + const lastLine = lineMatch[lineMatch.length - 1].match(/missed=\"(\d+)\" covered=\"(\d+)\"/); + const lastBranch = branchMatch[branchMatch.length - 1].match(/missed=\"(\d+)\" covered=\"(\d+)\"/); + const lineMissed = +lastLine[1], lineCovered = +lastLine[2]; + const branchMissed = +lastBranch[1], branchCovered = +lastBranch[2]; + const linePct = (lineCovered / (lineMissed + lineCovered) * 100).toFixed(1); + const branchPct = (branchCovered / (branchMissed + branchCovered) * 100).toFixed(1); + const lineStatus = linePct >= 70 ? '✅' : '❌'; + const branchStatus = branchPct >= 60 ? '✅' : '❌'; + console.log(''); + console.log('╔══════════════════════════════════════════════════════╗'); + console.log('║ Coverage Summary — Bilhej ║'); + console.log('╠══════════════════════╦══════════╦══════════╦═════════╣'); + console.log('║ Layer │ Lines │ Branch │ Status ║'); + console.log('╠══════════════════════╬══════════╬══════════╬═════════╣'); + console.log('║ Backend │ ' + linePct.padStart(6) + '% │ ' + branchPct.padStart(6) + '% │ ' + lineStatus + ' ' + branchStatus + ' ║'); + console.log('╠══════════════════════╬══════════╬══════════╬═════════╣'); + console.log('║ Thresholds │ 70.0% │ 60.0% │ ║'); + console.log('╚══════════════════════╩══════════╩══════════╩═════════╝'); + console.log(''); + console.log('Frontend coverage printed above by Vitest text reporter.'); + console.log('Download full HTML reports from the Artifacts tab.'); + console.log(''); + } + " + - name: Frontend coverage run: npm run test:coverage working-directory: frontend