Coverage of lib/ by the host tests, and badges in the README
CI / build (push) Successful in 9m9s

scripts/coverage.sh builds the host tests with coverage counters and
reports with gcovr: 94.6% of the 3,193 lines of lib/ today (lib/SD and
src/ have no host tests and aren't counted). CI runs it on every push,
puts the figure in the job's summary, and on main publishes a coverage
badge and a latest-release badge to the branch 'badges'. The README shows
them next to Gitea's own badge for the workflow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
2026-10-06 13:56:08 +02:00
co-authored by Claude Opus 5.5
parent edc140e30c
commit 5ecd5d003f
7 changed files with 110 additions and 4 deletions
+23 -3
View File
@@ -1,5 +1,6 @@
# CI and releases (docs/milestones/R1.md).
# Any push: host tests, then the release firmware and the Debug Build.
# Any push: host tests, the release firmware and the Debug Build, then the tests'
# coverage of lib/; on main, its badge is published to the branch `badges`.
# A tag v*: the same, then a Gitea release with the signed Update File.
# Run by hand: the release of a tag that exists already (the ones from before CI).
#
@@ -9,7 +10,7 @@
name: CI
on:
push:
branches: ['**']
branches: ['**', '!badges'] # badges holds what CI itself publishes: the coverage badge
tags: ['v*']
workflow_dispatch:
inputs:
@@ -32,7 +33,7 @@ jobs:
run: |
apt-get update -qq
apt-get install -y -qq --no-install-recommends git build-essential openssl >/dev/null
pip install -q --no-cache-dir --root-user-action=ignore platformio
pip install -q --no-cache-dir --root-user-action=ignore platformio gcovr
pio --version; df -h /pio | tail -1; ls /pio | head
- name: Check out
@@ -49,6 +50,25 @@ jobs:
if: github.event_name == 'push'
run: scripts/ci.sh
- name: Coverage of lib/ by the host tests
if: github.event_name == 'push'
run: scripts/coverage.sh
# The README's badges are files on a branch of their own, replaced at each push to main.
- name: Publish the badges
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/coverage')
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: |
rm -rf /tmp/badges && mkdir /tmp/badges
cp .pio/coverage/coverage.svg .pio/coverage/summary.json /tmp/badges/
scripts/coverage_badge.py --plain release "$(git describe --tags --abbrev=0)" /tmp/badges/release.svg
cd /tmp/badges
git init -q -b badges .
git add .
git -c user.name="roro9stack CI" -c user.email="ci@git.twis.la" commit -q -m "Coverage of ${{ github.ref_name }} at ${{ github.sha }}"
git push -q --force "$(echo "${{ github.server_url }}" | sed "s#://#://ci:${GITEA_TOKEN}@#")/${{ github.repository }}.git" badges
- name: Which release
id: release
run: |