Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gersemirc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# gersemi is an opinionated formatter and does not support the same
# level of configuration as cmake-format. The previous settings from
# .cmake-format.json (dangle_align and dangle_parens) are not
# supported and have no direct equivalents.
28 changes: 5 additions & 23 deletions .github/workflows/cmake-format-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,33 +74,15 @@ jobs:
with:
python-version: '3.x'

- name: Install cmake-format
run: pip install cmakelang
- name: Install gersemi
run: pip install gersemi

- name: Check CMake formatting
run: |
echo "➡️ Checking CMake file formatting..."
cd phlex-src

cmake_files=$(find . -type f \( -name "CMakeLists.txt" -o -name "CMakeLists.txt.in" -o -name "*.cmake" -o -name "*.cmake.in" \) ! -path "*/build/*" ! -path "*/_deps/*")

if [ -z "$cmake_files" ]; then
echo "No CMake files found to check"
exit 0
fi

echo "::group::Running cmake-format --check"
format_errors=0
for file in $cmake_files; do
if ! cmake-format --check "$file"; then
format_errors=$((format_errors + 1))
fi
done
echo "::endgroup::"

if [ $format_errors -gt 0 ]; then
echo "::error::Found $format_errors file(s) with formatting issues."
echo "::error::Run 'cmake-format -i <file>' locally or comment '@phlexbot format' on the PR to auto-fix."
if ! gersemi --check phlex-src; then
echo "::error::Found files with formatting issues."
echo "::error::Run 'gersemi -i <file>' locally or comment '@phlexbot format' on the PR to auto-fix."
exit 1
else
echo "✅ All CMake files are properly formatted."
Expand Down
20 changes: 3 additions & 17 deletions .github/workflows/cmake-format-fix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,13 @@ jobs:
with:
python-version: '3.x'

- name: Install cmake-format
run: pip install cmakelang
- name: Install gersemi
run: pip install gersemi

- name: Apply CMake formatting
run: |
cd phlex-src
echo "Applying CMake formatting..."

# Find all CMake files
cmake_files=$(find . -type f \( -name "CMakeLists.txt" -o -name "CMakeLists.txt.in" -o -name "*.cmake" -o -name "*.cmake.in" \) ! -path "*/build/*" ! -path "*/_deps/*")

if [ -z "$cmake_files" ]; then
echo "No CMake files found to format"
exit 0
fi

# Format each file
for file in $cmake_files; do
echo "Formatting $file..."
cmake-format -i "$file"
done
gersemi -i phlex-src

- name: Handle fix commit
uses: ./phlex-src/.github/actions/handle-fix-commit
Expand Down
Loading