Skip to content

ci: add linters

ci: add linters #10

Workflow file for this run

# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: (C) 2025 Siemens
#
# Authors:
# Eugen Kremer <[email protected]>
name: Build and Test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build-and-test:
runs-on: ubuntu-latest
container:
image: gcc:14.2.0-bookworm
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
run: |
apt update --fix-missing
apt install -y --no-install-recommends cmake ccache lcov \
libp11-kit-dev \
bsdextrautils opensc libengine-pkcs11-openssl dumpasn1 gnutls-bin squashfs-tools rauc python3-pip
pip3 install reuse --break-system-packages
- name: Configure and build
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build -j $(nproc)
- name: Run tests
run: ./tests/runner.sh
- name: Generate coverage report and badge
if: success()
run: |
lcov --capture --directory build --output-file coverage.info
lcov --remove coverage.info '/usr/*' --output-file coverage.info
lcov --list coverage.info
COVERAGE=$(lcov --summary coverage.info 2>&1 | grep "lines......" | awk '{print $2}' | sed 's/%//')
echo "Coverage: $COVERAGE%"
# Determine badge color using awk
COLOR=$(awk -v cov="$COVERAGE" 'BEGIN {
if (cov >= 80) print "brightgreen"
else if (cov >= 60) print "yellow"
else print "red"
}')
# Download SVG badge from shields.io
mkdir -p badge
curl -o badge/coverage.svg "https://img.shields.io/badge/coverage-${COVERAGE}%25-${COLOR}"
- name: Deploy badge to GitHub Pages
if: success() && github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./badge
destination_dir: badge
keep_files: true