Skip to content

Add automatic CMakeLists formatting similar to current clang-format. #3

Add automatic CMakeLists formatting similar to current clang-format.

Add automatic CMakeLists formatting similar to current clang-format. #3

Workflow file for this run

name: Formatting via cmake- and clang-format
# only trigger this action on specific events
on:
push:
branches:
- main
pull_request:
jobs:
format:
runs-on: ubuntu-24.04
steps:
# checkout repository
- name: "Checkout PLSSVM"
uses: actions/[email protected]
with:
path: PLSSVM
# install dependencies
- name: "Dependencies"
run: |
sudo apt install libomp-dev clang-format
pip install "git+https://github.com/vancraar/cmake_format@master"
# install new CMake version
- name: "Install cmake 3.31.0"
uses: lukka/[email protected]
# configure project via CMake
- name: "Configure"
run: |
cd PLSSVM
cmake --preset all -DPLSSVM_TARGET_PLATFORMS="cpu" -DPLSSVM_ENABLE_FORMATTING=ON
# check source file formatting
- name: "Check source file formatting via clang-format"
run: |
set +e
cd PLSSVM
cmake --build --preset all --target check-clang-format
status=$?
if [ $status -ne 0 ]; then
echo "clang-format formatting errors found!"
cmake --build --preset all --target clang-format > clang-format-patch.txt 2>&1
exit $status
else
echo "No clang-format formatting errors found!"
fi
# upload the clang-format git patch, if available
- name: "Upload clang-format patch"
if: always()
uses: actions/upload-artifact@v4
with:
name: clang-format-patch
path: PLSSVM/clang-format-patch.txt
if-no-files-found: ignore
# check CMake formatting
- name: "Check CMake formatting via cmake-format"
run: |
set +e
cd PLSSVM
cmake --build --preset all --target check-cmake-format
status=$?
if [ $status -ne 0 ]; then
echo "cmake-format formatting errors found!"
cmake --build --preset all --target cmake-format > cmake-format-patch.txt 2>&1
exit $status
else
echo "No cmake-format formatting errors found!"
fi
# upload the cmake-format git patch, if available
- name: "Upload cmake-format patch"
if: always()
uses: actions/upload-artifact@v4
with:
name: cmake-format-patch
path: PLSSVM/cmake-format-patch.txt
if-no-files-found: ignore