Skip to content

refactor: инкапсуляция глобального состояния pam_pmm в структуру pam_pmm_state (Этап 10.1, Issue #205) #439

refactor: инкапсуляция глобального состояния pam_pmm в структуру pam_pmm_state (Этап 10.1, Issue #205)

refactor: инкапсуляция глобального состояния pam_pmm в структуру pam_pmm_state (Этап 10.1, Issue #205) #439

Workflow file for this run

name: CI
on:
push:
branches: ["**"]
paths-ignore:
- "**/*.md"
- ".gitkeep"
pull_request:
branches: ["**"]
paths-ignore:
- "**/*.md"
- ".gitkeep"
jobs:
# ─── Code formatting check ───────────────────────────────────────────────────
format:
name: clang-format check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install clang-format
run: sudo apt-get install -y clang-format
- name: Check formatting
run: |
find . \( -name '*.cpp' -o -name '*.h' \) \
! -path './third_party/*' \
! -path './deps/*' -print0 \
| xargs -0 clang-format --dry-run --Werror
# ─── Static analysis ─────────────────────────────────────────────────────────
static-analysis:
name: cppcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install cppcheck
run: sudo apt-get install -y cppcheck
- name: Run cppcheck
run: |
cppcheck \
--enable=warning,performance \
--std=c++20 \
--error-exitcode=1 \
--suppress=missingIncludeSystem \
--suppress=unmatchedSuppression \
--suppress=throwInNoexceptFunction \
--suppress=uninitMemberVarPrivate \
--suppress='*:deps/*' \
-I . -I utils -I deps/pmm \
$(find . -name '*.cpp' ! -path './third_party/*' ! -path './deps/*')
# ─── File size limits ─────────────────────────────────────────────────────────
file-size:
name: File size check (<= 1500 lines)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check file size limits
run: |
MAX_LINES=1500
FAILED=0
while IFS= read -r -d '' file; do
lines=$(wc -l < "$file")
if [ "$lines" -gt "$MAX_LINES" ]; then
echo "FAIL: $file has $lines lines (max $MAX_LINES)"
FAILED=1
fi
done < <(find . \( -name '*.cpp' -o -name '*.h' \) \
! -path './third_party/*' \
! -path './deps/*' -print0)
exit $FAILED
# ─── Build and test ──────────────────────────────────────────────────────────
build-and-test:
name: ${{ matrix.os }} / ${{ matrix.compiler }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
compiler: gcc
cc: gcc
cxx: g++
build_type: Debug
coverage: true
- os: ubuntu-latest
compiler: clang
cc: clang
cxx: clang++
build_type: Release
coverage: false
- os: macos-latest
compiler: clang
cc: clang
cxx: clang++
build_type: Release
coverage: false
- os: windows-latest
compiler: msvc
cc: cl
cxx: cl
build_type: Release
coverage: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Configure CMake (Linux / macOS, without coverage)
if: runner.os != 'Windows' && !matrix.coverage
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_C_COMPILER=${{ matrix.cc }} \
-DCMAKE_CXX_COMPILER=${{ matrix.cxx }}
- name: Configure CMake (Linux, with coverage)
if: runner.os != 'Windows' && matrix.coverage
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_C_COMPILER=${{ matrix.cc }} \
-DCMAKE_CXX_COMPILER=${{ matrix.cxx }} \
-DCMAKE_CXX_FLAGS="--coverage" \
-DCMAKE_C_FLAGS="--coverage"
- name: Configure CMake (Windows)
if: runner.os == 'Windows'
run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
- name: Build
run: cmake --build build --config ${{ matrix.build_type }}
- name: Test
run: ctest --test-dir build --build-config ${{ matrix.build_type }} --output-on-failure
- name: Generate coverage report
if: matrix.coverage
run: |
sudo apt-get install -y lcov
lcov --capture --directory build --output-file coverage.info \
--ignore-errors mismatch,source
lcov --remove coverage.info \
'/usr/*' '*/third_party/*' '*/catch2-build/*' \
--output-file coverage.info \
--ignore-errors unused
lcov --list coverage.info
- name: Upload coverage to Codecov
if: matrix.coverage
uses: codecov/codecov-action@v4
with:
files: coverage.info
fail_ci_if_error: false