etl/.github/workflows/clang-format.yaml
Roland Reichwein c536a39f0a Treefmt config
2026-04-02 08:19:45 +01:00

44 lines
1.4 KiB
YAML

name: clang-format
on:
push:
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master, development, pull-request/* ]
types: [opened, synchronize, reopened]
jobs:
clang-format:
name: clang-format
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install clang-format and git
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends git clang-format
clang-format --version
- name: Run clang-format on added/changed files
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
BEFORE="origin/${{ github.base_ref }}"
elif [ "${{ github.event_name }}" = "push" ]; then
BEFORE="${{ github.event.before }}"
else
echo "Unsupported event: ${{ github.event_name }}"
echo "This is likely a bug in the workflow configuration. Please report it to the maintainers."
exit 1
fi
git diff --name-only -z --diff-filter=AMCR "$BEFORE"..HEAD -- \
'*.c' '*.cc' '*.cxx' '*.cpp' \
'*.h' '*.hh' '*.hpp' '*.hxx' \
'*.ipp' '*.inl' \
':(exclude)include/etl/generators/*' \
':(exclude)include/etl/private/*_cpp03.h' \
| xargs -0 --no-run-if-empty clang-format --Werror -n --style=file