Files
clice/.github/workflows/check-format.yml
2025-08-17 11:47:44 +08:00

48 lines
1.3 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: format
on:
push:
branches: [main]
paths:
- .clang-format
- "include/**"
- "src/**"
- "tests/**"
pull_request:
branches: [main]
paths:
- .clang-format
- "include/**"
- "src/**"
- "tests/**"
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install clang-format
run: |
wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/llvm.asc
echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-20 main" | sudo tee /etc/apt/sources.list.d/llvm20.list
echo "deb-src http://apt.llvm.org/noble/ llvm-toolchain-noble-20 main" | sudo tee -a /etc/apt/sources.list.d/llvm20.list
sudo apt-get update && sudo apt-get install -y clang-format-20
clang-format-20 --version
- name: Run clang-format check
run: |
FILES=$(find ./ -type f | grep -P '^\.\/(src|include)(\/[^\/]+)*\/[^\/]+\.(h|cpp|cc)$')
UNFORMATTED=$(clang-format-20 --dry-run --Werror $FILES)
if [ $? -ne 0 ]; then
echo "× Some files are not properly formatted. Run clang-format to fix them."
exit 1
else
echo "✓ All files are properly formatted."
fi