diff --git a/.gersemirc b/.gersemirc new file mode 100644 index 00000000..88c0e857 --- /dev/null +++ b/.gersemirc @@ -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. diff --git a/.github/workflows/cmake-format-check.yaml b/.github/workflows/cmake-format-check.yaml index 69fb0fab..07fc9d40 100644 --- a/.github/workflows/cmake-format-check.yaml +++ b/.github/workflows/cmake-format-check.yaml @@ -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 ' 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 ' locally or comment '@phlexbot format' on the PR to auto-fix." exit 1 else echo "✅ All CMake files are properly formatted." diff --git a/.github/workflows/cmake-format-fix.yaml b/.github/workflows/cmake-format-fix.yaml index 53cbab5b..088e72c1 100644 --- a/.github/workflows/cmake-format-fix.yaml +++ b/.github/workflows/cmake-format-fix.yaml @@ -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