ci: optimize clang-format in GitHub Actions (#21715)

## Summary
- Replace cmake-based clang-format with dedicated bash script that
directly processes source files
- Optimize CI to only install clang-format-19 instead of entire LLVM
toolchain
- Script enforces specific clang-format version with no fallbacks

## Changes
1. **New bash script** (`scripts/run-clang-format.sh`):
   - Directly reads C++ files from `CxxSources.txt`
   - Finds all header files in `src/` and `packages/` directories
   - Respects existing `.clang-format` configuration files
   - Requires specific clang-format version (no fallbacks)
   - Defaults to format mode (modifies files in place)

2. **Optimized GitHub Action**:
- Only installs `clang-format-19` package with `--no-install-recommends`
   - Avoids installing unnecessary components like manpages
   - Uses new bash script instead of cmake targets

3. **Updated package.json scripts**:
- `clang-format`, `clang-format:check`, and `clang-format:diff` now use
the bash script

## Test plan
- [x] Verified script finds and processes all C++ source and header
files
- [x] Tested formatting works correctly by adding formatting issues and
running the script
- [x] Confirmed script respects `.clang-format` configuration files
- [x] Script correctly requires specific clang-format version

🤖 Generated with [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude <claude@anthropic.ai>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
robobun
2025-08-08 22:36:49 -07:00
committed by GitHub
parent 05cff5cfde
commit 0827add9a3
21 changed files with 319 additions and 41 deletions

View File

@@ -68,9 +68,9 @@
"zig:check-windows": "bun run zig build check-windows --summary new",
"analysis": "bun ./scripts/build.mjs -DCMAKE_BUILD_TYPE=Debug -DENABLE_ANALYSIS=ON -DENABLE_CCACHE=OFF -B build/analysis",
"analysis:no-llvm": "bun run analysis -DENABLE_LLVM=OFF",
"clang-format": "bun run analysis --target clang-format",
"clang-format:check": "bun run analysis --target clang-format-check",
"clang-format:diff": "bun run analysis --target clang-format-diff",
"clang-format": "./scripts/run-clang-format.sh format",
"clang-format:check": "./scripts/run-clang-format.sh check",
"clang-format:diff": "./scripts/run-clang-format.sh diff",
"clang-tidy": "bun run analysis --target clang-tidy",
"clang-tidy:check": "bun run analysis --target clang-tidy-check",
"clang-tidy:diff": "bun run analysis --target clang-tidy-diff",