Skip to content

ci: build library and run CTest host suite #63

ci: build library and run CTest host suite

ci: build library and run CTest host suite #63

Workflow file for this run

name: Code Quality
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
quality:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Analysis Tools
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq cppcheck clang-format
- name: Run Cppcheck
run: |
echo "Running cppcheck static analysis..."
SRC_DIRS=()
for d in core imgproc board device wrapper; do
[ -d "$d" ] && SRC_DIRS+=("$d")
done
if [ ${#SRC_DIRS[@]} -eq 0 ]; then
echo "No source directories found for cppcheck"
exit 1
fi
INCLUDE_ARGS=()
for d in "${SRC_DIRS[@]}"; do
INCLUDE_ARGS+=("-I" "$d")
done
cppcheck \
--enable=warning,performance,portability \
--error-exitcode=1 \
--inline-suppr \
--suppress=missingIncludeSystem \
--suppress=unusedFunction \
--suppress=unmatchedSuppression \
--std=c11 \
--force \
"${INCLUDE_ARGS[@]}" \
"${SRC_DIRS[@]}" \
--xml \
2> cppcheck-report.xml
- name: Run Cppcheck Style Report
continue-on-error: true
run: |
echo "Running cppcheck style analysis (non-blocking)..."
SRC_DIRS=()
for d in core imgproc board device wrapper; do
[ -d "$d" ] && SRC_DIRS+=("$d")
done
if [ ${#SRC_DIRS[@]} -eq 0 ]; then
echo "No source directories found for cppcheck style scan"
exit 0
fi
INCLUDE_ARGS=()
for d in "${SRC_DIRS[@]}"; do
INCLUDE_ARGS+=("-I" "$d")
done
cppcheck \
--enable=style \
--inline-suppr \
--suppress=missingIncludeSystem \
--suppress=unusedFunction \
--suppress=unmatchedSuppression \
--std=c11 \
--force \
"${INCLUDE_ARGS[@]}" \
"${SRC_DIRS[@]}" \
--xml \
2> cppcheck-style-report.xml || true
- name: Check Code Formatting
run: |
echo "Checking code formatting..."
if [ ! -f .clang-format ]; then
cat > .clang-format << 'FMT'
---
BasedOnStyle: LLVM
IndentWidth: 4
ColumnLimit: 100
PointerAlignment: Left
AllowShortIfStatementsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
IndentCaseLabels: true
BreakBeforeBraces: Allman
FMT
fi
# Fail if any file is not properly formatted
SRC_DIRS=()
for d in core imgproc board device wrapper; do
[ -d "$d" ] && SRC_DIRS+=("$d")
done
if [ ${#SRC_DIRS[@]} -eq 0 ]; then
echo "No source directories found for format check"
exit 1
fi
find "${SRC_DIRS[@]}" \( -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" \) \
-print0 | xargs -0 clang-format --dry-run --Werror
- name: Upload Cppcheck Report
if: always()
uses: actions/upload-artifact@v4
with:
name: cppcheck-report
path: cppcheck-report.xml
retention-days: 30
if-no-files-found: warn
- name: Upload Cppcheck Style Report
if: always()
uses: actions/upload-artifact@v4
with:
name: cppcheck-style-report
path: cppcheck-style-report.xml
retention-days: 30
if-no-files-found: warn