Skip to content

feat: teacher overview classroom and status #284

feat: teacher overview classroom and status

feat: teacher overview classroom and status #284

Workflow file for this run

name: Backend CI
on:
push:
branches:
- main
pull_request:
jobs:
test:
runs-on:
group: NTNU Common Runners
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Java 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
cache: gradle
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
- name: Check formatting
run: ./gradlew spotlessCheck --no-daemon
- name: Run backend tests with coverage
run: ./gradlew test jacocoTestReport --no-daemon
- name: Publish backend coverage summary
run: |
python3 - <<'PY'
import os
import xml.etree.ElementTree as ET
report_path = "build/reports/jacoco/test/jacocoTestReport.xml"
tree = ET.parse(report_path)
root = tree.getroot()
wanted = ["INSTRUCTION", "BRANCH", "LINE", "METHOD", "CLASS"]
rows = []
for metric in wanted:
counter = root.find(f"./counter[@type='{metric}']")
if counter is None:
raise SystemExit(f"Missing JaCoCo counter: {metric}")
missed = int(counter.attrib["missed"])
covered = int(counter.attrib["covered"])
total = missed + covered
pct = 0.0 if total == 0 else covered * 100.0 / total
rows.append((metric.title(), pct))
summary_path = os.environ["GITHUB_STEP_SUMMARY"]
with open(summary_path, "a", encoding="utf-8") as f:
f.write("## Backend coverage\n")
f.write("| Metric | Coverage |\n")
f.write("| --- | --- |\n")
for name, pct in rows:
f.write(f"| {name} | {pct:.1f}% |\n")
PY
- name: Upload backend coverage report
if: always()
uses: actions/upload-artifact@v3
with:
name: backend-jacoco-report
path: build/reports/jacoco/test
if-no-files-found: ignore
retention-days: 14