Skip to content

enforce formatting of C++ code #188

enforce formatting of C++ code

enforce formatting of C++ code #188

Workflow file for this run

name: Test Linux
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
inputs:
generateDocx:
description: 'Generate docx report'
required: false
type: boolean
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
pybmds:
runs-on: ubuntu-22.04
env:
generateDocx: ${{ inputs.generateDocx }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- name: Install dependencies
run: |
echo "generateDocx: $generateDocx"
source ./tools/linux_ci_setup.sh
if [ "$generateDocx" = "true" ]; then
sudo apt-get install -y pandoc
fi
- name: Build pybmds
run: |
source ./tools/linux_ci_env.sh
python -m pip install -U pip wheel
python -m pip install -e ".[dev,docs]"
stubgen -p pybmds.bmdscore -o src
ruff format src/pybmds/bmdscore.pyi
python -c "import pybmds; print(pybmds.bmdscore.version())"
- name: Check linked files
run: |
ls -lah src/pybmds
ldd src/pybmds/bmdscore*.so
- name: loc
run: |
sudo apt-get install -y cloc
echo "# Lines of Code Report" >> $GITHUB_STEP_SUMMARY
make loc >> $GITHUB_STEP_SUMMARY
- name: Check linting
run: |
make lint
- name: Test with pytest
run: |
coverage run -m pytest
echo "# Python coverage report" >> $GITHUB_STEP_SUMMARY
coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
coverage html -d coverage -i
- name: Build documentation
run: |
make docs
if [ "$generateDocx" = "true" ]; then
make docs-docx
rm -rf docs/build/singlehtml
fi
- name: Upload Documentation
uses: actions/upload-artifact@v4
with:
name: docs
path: docs/build/
retention-days: 14
- name: Upload Coverage Report
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage
retention-days: 14
bmdscore:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
source ./tools/linux_ci_setup.sh
- name: Run clang-format
run: |
apt-get install -y clang-format
make format-cpp
git diff --exit-code --compact-summary || { echo "Code formatting failed; run 'make format-cpp'"; exit 1; }
- name: Build bmdscore
run: |
source ./tools/linux_ci_env.sh
mkdir -p src/build
cd src/build
cmake ..
make -j$(nproc)
- name: Run tests and generate report
run: |
source ./tools/linux_ci_env.sh
cd src/build
make run_tests_with_coverage
- uses: actions/upload-artifact@v4
with:
name: cpp-coverage
path: |
./src/build/coverage/*