Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.

format: update formatting workflows and files formatting #272

format: update formatting workflows and files formatting

format: update formatting workflows and files formatting #272

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: python-package
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
linting:
strategy:
matrix:
python-version: ["3.10", 3.11, 3.12, 3.13]
os: [ubuntu-latest, ubuntu-22.04]
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# flake8 options are defined in setup.cfg
flake8 . --count --statistics
formatting:
strategy:
matrix:
python-version: [3.13]
os: [ubuntu-latest, ubuntu-22.04]
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
# Add LLVM key and install clang-16
sudo apt-get update
sudo apt-get install -y software-properties-common wget gnupg
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
DISTRIB_CODENAME=$(lsb_release -sc)
echo "deb http://apt.llvm.org/${DISTRIB_CODENAME}/ llvm-toolchain-${DISTRIB_CODENAME}-16 main" | sudo tee /etc/apt/sources.list.d/llvm-16.list
sudo apt-get update
sudo apt-get install -y clang-format-16 2>/dev/null
- name: black format
run: |
black --diff --check .
- name: clang-format
run: |
set +e
FILES=$(find include src examples -type f | egrep '\.hpp$|\.cpp$|\.cpp\.in$')
FORMAT_OUT=$($CLANG_FORMAT -output-replacements-xml ${FILES})
RET=$(echo ${FORMAT_OUT} | grep -c '<replacement ')
if [ "${RET}" -ne 0 ]; then
echo -e "\nError! Code not formatted. Detected ${RET} lines\n"
$CLANG_FORMAT -i ${FILES}
git diff
exit ${RET}
fi